Using accelerators when a modeless dialog box is the main window

Using accelerators when a modeless dialog box is the main window

Post by David Herma » Mon, 30 Jun 1997 04:00:00



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;

Quote:}

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.

 
 
 

Using accelerators when a modeless dialog box is the main window

Post by Stephen W. Hiemstr » Sun, 13 Jul 1997 04:00:00


David,

If you figure out the problem, I would be interested in the solution.

Stephen

 
 
 

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

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

2. Apple fast Scsi Card wanted

3. Accelerators for Dialog box (as main Window)

4. C/Net: "Win 98 not subject to injunction"

5. Modeless dialog as main program window & Combo Boxes

6. Using POSIX Threads on OSS

7. Help with modeless dialog box as the main window

8. Laser Pointer

9. using ctl3d with modeless dialog as main window?

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

11. Processing keyboard accelerators with modeless dialog boxes

12. Accelerators in modeless dialog boxes

13. Using Dialog Box as Main Window - How?