GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Apr 20, 2014 12:56 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Get Gtk window *from* HWND
PostPosted: Sun Oct 07, 2012 12:46 am 
Offline

Joined: Sun Oct 07, 2012 12:44 am
Posts: 3
Hello,

If my application is given an HWND, can I get a gtk window from that?

I'm looking for something along the lines of:

Code:
GtkWindow *wnd = gtkwindow_from_hwnd(hWnd);


Is this possible?

Thanks.


Top
 Profile  
 
 Post subject: Re: Get Gtk window *from* HWND
PostPosted: Sun Oct 07, 2012 10:50 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
That's part of the Windows API.
GTK is a cross-platform toolkit and does not include any platform specific code as you suggest. GDK however has some low level functions for each of the backends it supports, which is fortunate because windows doesn't believe in the existance of other OS's. You'll probably find a function call within this library, the exact function varies depending on yourversion of gdk and I've only seen examples for old versions.
However, the fact that you want such a function means its likely your going the wrong way about doing the coding. When using a cross-platform toolkit it is best to operate entirely within the margins of this environment (and as gtk is all encompassing enough in the various libraries available in the stack -- ATK, glib, cairo, pango, GIO, etc. -- this is really not that hard). If, on the other hand, you really really need a hWnd for whatever reason that may be then please make sure you code portably (otherwise you are wasting a lot of the advantage of using GTK in the first place). This means, e.g., having conditional compilation of your code where for every win32 backend specific portion there is also a corresponding non-win32 portion.


Top
 Profile  
 
 Post subject: Re: Get Gtk window *from* HWND
PostPosted: Mon Oct 08, 2012 2:32 am 
Offline

Joined: Sun Oct 07, 2012 12:44 am
Posts: 3
Perhaps I should have been more specific: I am coding a VST plugin in which I want to write a GUI for my audio effect. Part of the process is overriding a method called
Code:
open(void *ptr)
where
Code:
ptr
is platform-specific (HWND on windows; I-forget-what on Mac) (needless to say, this method is responsible for opening the plugin's GUI). For the time being, I am only interested in compiling my plugin on Windows, but I wanted to develop the application with cross-platform-ness in mind for the future. It seems unfortunate to me that the VST api is limiting in this way, but hey, who am I to complain (I agree with you that this seems like the wrong way of going about this).

wxWidgets has some platform-specific methods for reassigning an HWND to a wx::Frame, but that didn't seem to work to well when I tried it-- and I didn't try too hard because I prefer GTK if I can use it.


Top
 Profile  
 
 Post subject: Re: Get Gtk window *from* HWND
PostPosted: Tue Oct 09, 2012 6:01 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
I know you can get a hWnd from a Gdk Window if you include gdkwin32.h and use the GDK_WINDOW_HWND cast but as for going the other direction, I don't really see anything. Probably because GDK running on windows operates as a subset such that every gdk window can be given a hWnd but not every windows window is within the domain of gdk to be given a gdk window.
Might be better if someone with windows experience is able to jump in .


Top
 Profile  
 
 Post subject: Re: Get Gtk window *from* HWND
PostPosted: Wed Oct 10, 2012 5:59 am 
Offline

Joined: Sun Oct 07, 2012 12:44 am
Posts: 3
Well, thanks for the pointers so far. I agree with you that this is an awkward way to program and what I'm leaning toward is just using VSTGUI for the first window (as much as I hate it), and gtk/wxwindows for any popups (if any) that I want...what bugs me about that is I'm not certain VSTGUI supports linux, but then again, linux isn't one of the major players for VST plugins (yet!)...


Top
 Profile  
 
 Post subject: Re: Get Gtk window *from* HWND
PostPosted: Wed Oct 10, 2012 11:49 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
Sorry I can't be of more help. I have seen a few linux projects that use the VST plugin, but the majority are based around qt.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group