// wxDll.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
// wxDLL is a simple DLL which demonstrates how to use
// wxWindows in a DLL which is called from another
// application (not using wxWindows)
// Edited by upCASE
#include "wx/wx.h"
#include "wxDLL.h"
#include "wx/wxhtml.h"
// We use IMPLEMENT_APP_NO_MAIN so we can start the app from DllMain
// as we don't have a WinMain or main entry point
//
BEGIN_EVENT_TABLE(wxDLLApp, wxApp)
EVT_BUTTON(123,wxDLLApp::OnButton)
END_EVENT_TABLE()
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{ //use wxInitialize() if you don't want GUI instead of the following 12 lines
wxSetInstance((HINSTANCE)hModule);
int argc = 0;
char **argv = NULL;
wxEntryStart(argc, argv);
if ( !wxTheApp || !wxTheApp->CallOnInit() )
return FALSE;
}
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
wxEntryCleanup(); //use wxUninitialize() if you don't want GUI
break;
}
return TRUE;
}
// extern "C" so we don't need a DEF file
// This is the function to be called from the host app
extern "C" DLLFUNCTIONS_API void DLLFunction(HWND handle)
{
// Create a dummy wxWindow so we can use the HWND passed from the
// host application
wxWindow win;
win.SetHWND((WXHWND)handle);
win.Enable(false);
wxDialog dlg(&win, -1, "wxDialog in DLL", wxDefaultPosition, wxSize(150,150));
wxButton b(&dlg, 123,"Press me please");
dlg.ShowModal();
// Clean up else the caller can't use its window
win.Enable(true);
win.SetHWND(0);
}
extern "C" DLLFUNCTIONS_API void TestReport(HWND handle, char * msg)
{
wxWindow win;
win.SetHWND((WXHWND)handle);
win.Enable(false);
wxDialog dlg(&win, wxID_ANY, wxString(msg), wxDefaultPosition, wxSize(400,180));
wxHtmlWindow html1(&dlg,wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
html1.SetPage("<html><body>"
"<h1>" "About" "</h1>"
"Some error occurred Smile :-)"
"</body></hmtl>");
dlg.ShowModal();
// Clean up else the caller can't use its window
win.Enable(true);
win.SetHWND(0);
}
bool wxDLLApp::OnInit()
{
return true;
}
void wxDLLApp::OnButton(wxCommandEvent& evt)
{
wxMessageBox("You really did it.... I don't believe it!");
}
Partager