[gtkmm] Re: [Win32] Retrieving the HINSTANCE and HWND from gtkmm2.



Dirk Gerrits wrote:

I have not yet been able to try out gtkmm2 (see my previous posts in the
"Building libsigc++ under Win32 for use with Intel C++ Compiler 6.0"
thread). However I'm getting closer every day because of all the help
I'm getting. Thanks guys!

Anyway, in the meantime I have been speculating over how to do certain
things with gtkmm2. After some Googling and doc reading I came up with
this to retrieve the HINSTANCE of the application and the HWND of a
Gtk::Window called myWin:

// Retrieve GdkWindow part of myWin.
GdkWindow* gdkWinPtr = myWin.get_window()->gobj();

// Retrieve Win32 application instance handle and window handle.
HINSTANCE hInstance = static_cast<HINSTANCE>(GetModuleHandle(NULL));
HWND hWnd = static_cast<HWND>(GDK_WINDOW_XWINDOW(gdkWinPtr));

However, I have obviously not been able to test this. Is it correct?

Kind regards,
Dirk Gerrits


I have been able to try this now, thanks to some helpful mailinglist posters. However, it doesn't work: the macro GDK_WINDOW_XWINDOW is undefined. Doing some more research, I came up with this:

#include <gdk/gdkwin32.h>

// Retrieve GdkWindow part of myWin.
GdkWindow* gdkWinPtr = get_window()->gobj();

// Retrieve Win32 application instance handle and window handle.
HINSTANCE hInstance = static_cast<HINSTANCE>(GetModuleHandle(NULL));
HWND hWnd = static_cast<HWND>(GDK_WINDOW_HWND(gdkWinPtr));

This appears to work. Can anyone confirm this?

Dirk






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]