A problem about a self-contained wx dll
Jin Huang
hj at cad.zju.edu.cn
Sat Jul 21 06:09:44 PDT 2007
I'm working on a Windows XP box with wxWidget 2.8.4, VC8+SP1.
I have two sub-projects for an application. The first one is used for
creating a customized control (it is derived from wxFrame), and the
second one is a client to use this control. When both sub-projects are
built using WXUSINGDLL, and linked to wx*.dll (dynamic build of
wxWidget), there's no problem.
Now I want to the first sub-project can be used for some client which is
not based on wxWidget, such as glut application. So I re-build the first
sub-project without WXUSINGDLL, and linked to wx*.lib (static build of
wxWidget). Unfortunately, the output .dll file is not good for use. The
details is following:
If I do not add the following code to the first project (very similar to
the wiki page "Creating A DLL Of An Application"):
class wxDLLApp : public wxApp
{
bool OnInit();
};
...
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
wxApp::SetInstance(new wxDLLApp());
wxEntry(GetModuleHandle(NULL),NULL,NULL,SW_SHOW);
return true;
}
BOOL APIENTRY DllMain(HINSTANCE hModule,
DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateThread(NULL,0,ThreadProc,NULL,0,NULL);
break;
case DLL_THREAD_ATTACH: break;
case DLL_THREAD_DETACH: break;
case DLL_PROCESS_DETACH:
wxEntryCleanup();
break;
}
return TRUE;
}
The application crashed at "wxTopLevelWindowMSW::CreateFrame" because
wxTheApp is NULL.
But if I follow the wiki page "Creating A DLL Of An Application", and
add above code to my program, I cannot close the control
(derived from wxFrame) by click the "X" at the title bar.
My question is what is the standard (or correct) way to create a dll
which supply a customized wxWidget control, and can be used outside a
wxWidget application?
Thank you very much!
More information about the wx-users
mailing list