Problem with wxMSW and setting the module instance handle.

Jurko Gospodnetić jurko_for_boost at mail.inet.hr
Wed May 16 04:17:28 PDT 2007


   Hi.

   Just wanted to report that there is a bit problematic detail with
wxMSW application startup design. There wxEntry() sets the Windows
module instance handle using the internal wxWidgets wxSetInstance() API
found in the msw/private.h header. This means that in order for an
application to prepare an application using wxEntryStart() and
wxEntryCleanup() instead of wxEntry() on Windows it needs to include
this private header and know to call this function.

   I did not find this documented anywhere and I've noticed that if you
do not set this instance handle, wxWidgets does not complain anywhere
and only silently fails some WinAPI calls like loading resources stored
in the module (because the module's handle is stored as 0) as well as 
causing potential problems with registering Windows window classes in 
case of a wxWidgets application linking to a DLL using wxWidgets (their 
Windows window class registrations may overwrite each other due to 
conflicting HINSTANCE parameters).

   This bug affects the MFC/wxWidgets sample as well.

   Hope this helps...

   Best regards,
     Jurko Gospodnetić





More information about the wx-dev mailing list