[wx-dev] #9524: a IMPLEMENT_DLLAPP macro like IMPLEMENT_APP

wxTrac noreply at wxsite.net
Mon Jun 2 07:17:28 PDT 2008


Ticket URL: <http://trac.wxwidgets.org/ticket/9524>

#9524: a IMPLEMENT_DLLAPP macro like IMPLEMENT_APP
---------------------------+------------------------------------------------
 Reporter:  ma_boehm       |       Owner:     
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:     
Component:  wxMSW          |     Version:     
 Keywords:  DllMain macro  |   Blockedby:     
    Patch:  0              |    Blocking:     
---------------------------+------------------------------------------------
 When i started to build a dll with wxWidgets code, i stumbled upon
 difficulties first because the global variabl wxTheApp was NULL in all
 code of the dll (wxTheApp particulary was needed of wxPlatformInfo, i
 always got an assert message originating in src/common/plafinfo.cpp, line
 171).
 After some searching i found at last, that you have to call wxEntryStartup
 when the dll loads and wxEntryCleanup when the dll unloads out of the
 DllMain function.
 My thought was, that for Dll's there should be a macro like IMPLEMENT_APP,
 for example IMPLEMENT_DLLAPP, which initializes the wxTheApp variable, and
 all other things needed, so you don't have to initialize all manually (and
 don't need to spend time for searching a solution).
 The macro could for example expand to the following code:

  extern "C"
 BOOL WINAPI DllMain(HINSTANCE, DWORD fdReason, LPVOID) {
         BOOL bResult = TRUE;
         int argc = 0;
         wxChar **argv = NULL;

         switch(fdReason) {
         case DLL_PROCESS_ATTACH:
                 bResult = ::wxEntryStart(argc, argv);
                 break;
         case DLL_PROCESS_DETACH:
                 ::wxEntryCleanup();
                 break;
         default:
                 break;
         }

         return bResult;
 }


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9524>


More information about the wx-dev mailing list