Archived

This topic is now archived and is closed to further replies.

Dialog box and WM_KEYDOWN

This topic is 5502 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

my dialogbox won''t recive any WM_KEYDOWN messages. I''ve tried to SetFocus() but it doesn''t recive them anyways. For now, I use WM_HELP messages to check for a keypress but it as you know, that limits the keys of chose to the F1 key = :-/ Does anyone know how I can let the DialogBox recive keystroke msgs. If it does matter, the mouse has to be outside the client area (while the window is still "chosed"). Thanks!

Share this post


Link to post
Share on other sites
There''s not much to post...

this is a part of the msghandler proc for a dialogbox (started by:

DialogBox( g_hInst, (LPCTSTR)IDD_ULTRACLICKER, hWnd, (DLGPROC)UltraClickerMH );

)


  
LRESULT CALLBACK UltraClickerMH( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_KEYDOWN:
// won''t reach here

break;

case WM_HELP:
// but comes here when I press F1

break;
}
}

Share this post


Link to post
Share on other sites
I don´t know but shouldn´t the dialogproc return FALSE and look like this:

BOOL CALLBACK UltraClickerMH( HWND, UINT, WPARAM, LPARAM)?

If that doesn´t work, try using a accelerator (if u are using MSVS).

Add a new accelerator resource file to MSVS, add a new accelerator key, set the ID to a valid controller ID (a button in your dialogbox or what ever) and bind it to a key. Choose VIRTKEY as type.


  

HANDLE hAccel = LoadAccelerators (hInstance, MAKEINTRESOURCE (IDR_ACCELERATOR1)) ;

// In your message pump


MSG msg;
while( WM_QUIT != msg.message )
{
GetMessage( &msg, NULL, 0U, 0U );

if (!TranslateAccelerator (g_kDialogBox, (HACCEL) hAccel, &msg))
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}



Good Luck!

Share this post


Link to post
Share on other sites