Reputation: 1
This is a small program
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.style = CS_GLOBALCLASS;
wc.lpszClassName = TEXT( "Buttons" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClass(&wc);
wc.style = CS_GLOBALCLASS;
wc.lpszClassName = TEXT( "Frame" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClass(&wc);
HWND hwnd = CreateWindow( wc.lpszClassName, TEXT("Buttons"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
150, 150, 230, 150, 0, 0, hInstance, 0);
while( GetMessage(&msg, NULL, 0, 0)) {
if( !IsDialogMessage(hwnd, &msg) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch(msg)
{
case WM_CREATE:
{
HWND frame = CreateWindowEx(0, TEXT("Frame"), TEXT("&Beep"),
WS_VISIBLE | WS_CHILD,
0, 0, 230, 130,
hwnd, 0, NULL, NULL);
CreateWindow(TEXT("button"), TEXT("&Beep"),
WS_VISIBLE | WS_CHILD | WS_TABSTOP,
20, 50, 80, 25,
frame, (HMENU) 1, NULL, NULL);
CreateWindow(TEXT("button"), TEXT("&Quit"),
WS_VISIBLE | WS_CHILD | WS_TABSTOP ,
120, 50, 80, 25,
frame, (HMENU) 2, NULL, NULL);
break;
}
case WM_COMMAND:
{
if (LOWORD(wParam) == 1) {
Beep(400, 50);
}
if (LOWORD(wParam) == 2) {
PostQuitMessage(0);
}
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
The access keys are not working. That meeans instead of sending the corresponding WM_COMMAND messages a warning bell sounds.
The mcrosoft SDK documentation says that this should work but it doesn't. With or without the call of IsDialogMessage makes no difference. I would expect that hitting Alt+Q on the keyboard would terminate the application.
The problem seems to be the frame window. Without the frame when creating the buttons as a child of the overapped window after setting the focus to one of the buttons everthing works as expected.
Upvotes: -1
Views: 26
Reputation: 101756
if (!IsDialogMessage(...
Upvotes: 0