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
|
BOOL MainDialog_OnCommand(HWND hWnd, WORD wCommand, WORD wNotify, HWND hControl)
{
switch (wCommand)
{
//...
}
return TRUE;
}
BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
//...
break;
case WM_COMMAND:
return MainDialog_OnCommand(hWnd, LOWORD(wParam),
HIWORD(wParam), (HWND)lParam);
case WM_MOUSEACTIVATE:
if( (HWND)wParam != hWndVP) //hWndVP is hwnd of window I want to get focus
return MA_NOACTIVATE;
else
{
SetFocus(hWndVP);
return MA_ACTIVATE;
}
break;
case WM_PAINT:
return MainDialog_OnCommand(hWnd, LOWORD(wParam),
HIWORD(wParam), (HWND)lParam);
break;
case WM_CLOSE:
EndDialog(hWnd, 0);
return TRUE;
}
return FALSE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
DialogBoxParam(hInstance, MAKEINTRESOURCE(100), //100 - ID of main window
NULL, (DLGPROC)MainDialogProc, 0);
return 0;
}
|