Accessing the HINSTANCE

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
linuXfreak
In need of some credit
In need of some credit
Posts: 2
Joined: Wed Jul 06, 2005 8:19 pm

Accessing the HINSTANCE

Post by linuXfreak » Wed Jul 06, 2005 8:23 pm

Hi,
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?

NinjaNL
Moderator
Moderator
Posts: 899
Joined: Sun Oct 03, 2004 10:33 am
Location: Oosterwolde, Netherlands

Post by NinjaNL » Wed Jul 06, 2005 10:18 pm

From http://wiki.wxwidgets.org/wiki.pl?WxMSW_Issues
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();
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/

linuXfreak
In need of some credit
In need of some credit
Posts: 2
Joined: Wed Jul 06, 2005 8:19 pm

Post by linuXfreak » Sat Jul 09, 2005 10:56 am

Thanks.

Btw, why did the search function not find that?

NinjaNL
Moderator
Moderator
Posts: 899
Joined: Sun Oct 03, 2004 10:33 am
Location: Oosterwolde, Netherlands

Post by NinjaNL » Sat Jul 09, 2005 12:20 pm

Don't know, I use google before I try anything else.
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/

Post Reply