Visual C++ Message Loops

Yes, another question :]

I have a dialog resource, IDD_MYDIALOG

I also have my WinMain setup so that when my app is run, a window shows up with a menu FILE -> EXIT and HELP -> ABOUT

The file-exit closes the window.

What I want now, is to show my dialog resource when the help-about is clicked. How do I display my dialog MAKEINTRESOURCE(IDD_MYDIALOG)?

Thanks.
Menu options send a WM_COMMAND message to the window with the ID of the command in the low word of the wParam.

For example, if your About menu option has the ID 'IDD_HELP_ABOUT' you'd do this in your message handler:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
switch(msg)
{
 // .. WM_INITDIALOG and other messages you're processing here

case WM_COMMAND:
  // WM_COMMAND is sent for button clicks, list changes, menu options
  //   ie:  nearly everything widget related
  switch( LOWORD(wParam) )
  {
  case IDD_HELP_ABOUT:
    // About selected from the menu -- open your about dialog here
    break;
  }
}


note: this is from memory and it's been a while -- I might have LOWORD and HIWORD mixed up. I don't think so though. If you want, you can look up WM_COMMAND on msdn and see if I got it right.

EDIT: nah I checked -- I got it right. HIWORD is the subcommand, LOWORD is the control ID. So yeah, above works.
Last edited on
Thanks!
Topic archived. No new replies allowed.