WS_EX_CONTROLPARENT & WS_TABSTOP
Hello!
I have created a simple app - one parent window, a couple of edits and buttons in it, as its children. I want to be able to switch between edits with the TAB key. I thought these two will do... guess I was wrong. Can anybody explain how to make it work?
Even the simplest app with a window and two edits - when I press TAB w want to switch edits. And in my app nothing happens (not even a warning soud).
wndHandle = CreateWindowEx(
WS_EX_CONTROLPARENT,
"MainWindow",
"My application",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
NULL,
NULL,
hInstance,
NULL);
edit1Handle = CreateWindowEx(
WS_EX_CLIENTEDGE,
"Edit",
NULL,
WS_CHILD | WS_VISIBLE | ES_NUMBER | WS_TABSTOP,
20, 25, 30, 20,
wndHandle,
NULL,
hInstance,
NULL);
edit2Handle = CreateWindowEx(
WS_EX_CLIENTEDGE,
"Edit",
NULL,
WS_CHILD | WS_VISIBLE | ES_NUMBER | WS_TABSTOP,
20, 75, 30, 20,
wndHandle,
NULL,
hInstance,
NULL);
Just a fragment... Why doesn't the TAB key work???
You'll need to use IsDialogMessage(). Change your message pump to this
if (!IsDialogMessage(hwnd, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg);}
Did what you proposed... but now when I execute my program, the window is shown but the cursor is still a sand-glass, and the application doesn't respond. My WinMain looks like this:
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)
{
if (!initWindow(hInstance))
return false;
MSG msg;
ZeroMemory(&msg,sizeof(msg));
while(msg.message!=WM_QUIT)
{
while (GetMessage(&msg,wndHandle,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int)msg.wParam;
}
Any idea, please?
PS. I'm sorry for not answering for a long time. I was away.
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)
{
if (!initWindow(hInstance))
return false;
MSG msg;
ZeroMemory(&msg,sizeof(msg));
while(msg.message!=WM_QUIT)
{
while (GetMessage(&msg,wndHandle,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int)msg.wParam;
}
Any idea, please?
PS. I'm sorry for not answering for a long time. I was away.
Remove the Window handle from the GetMessage call and insert the IsDialogMessage:
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow){ if ( !initWindow( hInstance ) ) { return false; } MSG msg; ZeroMemory( &msg, sizeof( msg ) ); while ( msg.message != WM_QUIT ) { while ( GetMessage( &msg, NULL, 0, 0 ) ) { if ( !IsDialogMessage( wndHandle, &msg ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } } return (int)msg.wParam;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement