tags:

views:

39

answers:

2

I'm programming with the Win32 API, not MFC.

A: 

Make sure you have the TranslateMessage(...) function in your message pump. If so, accelerator keys should work. Realize a modal dialog freezes all other windows in your app until it is dismissed.

BOOL bRet;
while( (bRet = GetMessage( &msg, hWnd, 0, 0 )) != 0)
{ 
    if( bRet == -1 )
    {
        // handle the error and possibly exit
    }
    else
    {
        TranslateMessage(&msg); //<< make sure this is present
        DispatchMessage(&msg); 
    }
}

Be sure and put an ampersand in front of your controls caption to "activate" the acceleration. Example: &OK or &Cancel. A small underline should now show up under the first letter indicating it worked. And that letter becomes the acceleration key. It does not have to be the first letter. E&xit. Line shows up under the "x" and that is the acceleration key.

JustBoo
I repeat my question : How to use an accelerator table in a MODAL DIALOG BOX ? You don't have access to the message loop used in a modal dialog box !!!
jaayrosa
A: 

Look at this example http://msdn.microsoft.com/en-us/library/ms646337.aspx#editable_acc. Probably it's what are you looking for.

Oleg
There must be something similar to this article"How to use accelerator keys and a main menu on the dialog box inVisual C++"http://support.microsoft.com/kb/100770/en-gbbut using the Win32 API, instead of MFC.
jaayrosa
The answer is right there in the article you linked to in your comment. I suggest you stand-back a bit and re-think what you're doing. It happens to all of us, because you can't "see" the answer right now.
JustBoo