1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| typedef wxToolTip * (*DLLFunctionPtr) (HWND);
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow);
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
HMODULE hModule;
DLLFunctionPtr pProc;
wxToolTip* tool;
// Entry point
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX wcx;
wcx.cbSize = sizeof(wcx);
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = MainWndProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 );
wcx.lpszMenuName = "MainMenu";
wcx.lpszClassName = "MainWClass";
wcx.hIconSm = NULL;
ATOM a = RegisterClassEx(&wcx);
assert(a);
HWND hwnd = CreateWindow("MainWClass","Test DLL",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,(HWND) NULL,(HMENU) NULL,hInstance,(LPVOID) NULL);
assert(hwnd);
// Load up the DLL and call DLLFunction
hModule = LoadLibrary("FromDLL.DLL");
assert(hModule);
pProc = (DLLFunctionPtr)GetProcAddress(hModule, "DLLFunction");
assert(pProc);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
wxInitialize();
// Lancement de la DLL
tool = (pProc)(hwnd);
long bRet;
MSG msg;
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0 )
{
if (bRet != -1)
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
return 0;
}
// Windows Callback Procedure
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
switch( msg ) {
case WM_DESTROY:
FreeLibrary(hModule);
PostQuitMessage( 0 );
break;
case WM_MOUSEMOVE:
tool->RelayEvent((WXMSG *)msg); // là, ça plante : il fait un GetToolTipCtrl()
break;
default:
return( DefWindowProc( hWnd, msg, wParam, lParam ));
}
return 0;
} |
Partager