Page 1 of 1

Accessing the HINSTANCE

Posted: Wed Jul 06, 2005 8:23 pm
by linuXfreak
I am using wxWindows 2.4.2 and Microsoft Visual C++ 6.0 for my application.
Another library I load wants the "HINSTANCE hInstance" to start up with windows (in linux it works fine) that is passed to WinMain on startup, but I start my app using wxApp. (I don't want to start with WinMain directly because the App should also work on linux)
Is there any way to access the hInstance from within wxWindows?

Posted: Wed Jul 06, 2005 10:18 pm
by NinjaNL
If you need to get to a Window Handle ( i.e. a HWND ) you can call wxWindow::GetHandle().

Getting the handle to the Application Instance is a little more involved... You need to include a header, and then you can call an undocumented function that is only on windows like this:

1. ifdef __WXMSW__
2. include "wx/msw/private.h"
3. endif


HINSTANCE hInstance = wxGetInstance();

Posted: Sat Jul 09, 2005 10:56 am
by linuXfreak

Btw, why did the search function not find that?

Posted: Sat Jul 09, 2005 12:20 pm
by NinjaNL
Don't know, I use google before I try anything else.