How do you handle Accelerators in modeless dialog boxes using SDK?

How do you handle Accelerators in modeless dialog boxes using SDK?

Post by simon clar » Fri, 16 Sep 1994 22:56:11



Does anyone know  the correct way to handle Accelerators in modeless
dialog boxes using the Windows 3.1 SDK?

One of the examples which comes with  Visual C++ does it the following
way

if (hwndDialog &&
    (TranslateAccelerator(hwndDialog, hAccTable, &msg) ||
    IsDialogMessage(hwndDialog, &msg)))
    continue;
TranslateMessage(&msg);
DispatchMessage(&msg);

However the SDK programmers guide mentions that IsDialog should comes
before any TranslateAccelerator.

So this leaves me a bit confused as to the correct way of handling the
accelerators.

-------------------------

Simon Clarke.

Telecom Research Laboratories

 
 
 

1. Using accelerators when a modeless dialog box is the main window

I'm writing a control panel that uses a modeless dialog box as its main
window.  Somehow I can't seem to trap the accelerator keys.  Here's the
beginning part:

case CPL_DBLCLK:
        CreateDialog(hinst, MAKEINTRESOURCE(IDD_MAIN), hwndCPl,
(DLGPROC)DialogProc);
        hAccelTable = LoadAccelerators(hinst, MAKEINTRESOURCE(IDR_ACCELERATOR));
        while (GetMessage(&msg, NULL, 0, 0))
        {
                if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
                {
                        TranslateMessage(&msg);
                        DispatchMessage(&msg);
                }
        }
        break;

Then in the DialogProc, I try to get the message:

switch(uMsg)
{
        .
        .
        case WM_COMMAND:
                switch(LOWORD(wParam))
                {
                        .
                        .
                        case IDM_MYMENUITEM:
                                MessageBox(GetFocus(), "Hello", "Test", MB_OK);
                                break;
                }
                break;

It doesn't work, though.  What am I missing?

Thanks,
Dave Herman

http://www.microcosm.com/~dave

To e-mail me, delete the underscore
at the end of my e-mail address.

2. WinCE Outlook Service

3. Accelerators + Modeless Dialog Boxes == 0????

4. Type 1 font for Win & Mac ?

5. Processing keyboard accelerators with modeless dialog boxes

6. Eudora 5.1.1 pd mode OSX crashing

7. Accelerators in modeless dialog boxes

8. Calling a modeless dialog box from a modal dialog box

9. how do I disable my app when running % done modeless dialog box?

10. How to make a modeless dialog box using MFC?

11. Trapping Messages or Exanging Data on a Modeless Dialog Box using C++.

12. Modeless dialog out of a Modal dialog box: possible?