Hi guys, I am just wondering how to implement a dialog I have made in Microsoft C++ 6.0

So I created a C++ project, then added a .rc script file. Then I added a new item to it (dialog control, called IDD_MENU) Now, I am wondering how would I use this menu inside my code? I have worked with WINAPI and spent hours coding GUIS. Just yesterday I downloaded C++ 6.0 (my new compiler, instead of Code::Blocks. Could save me hours of time!) and I am wondering how would I use the GUI I created? I have tried implementing it the same way I usually do for WINAPI, but this did not work. How do I do this? I have searched google for 1 day now, and I have not found anything. Hopefully somebody could help me out on this.

Thanks,
Chris

In version 8, you can just do it from the dialog interface, scroll down to the 'Menu' option, and select the name of the menu you created (view screenshot)

If you can't do that, you could edit the resource file directly, for example:

IDD_MAIN DIALOGEX 0, 0, 186, 94
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
[B]MENU IDR_MENUNAME[/B]
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,129,7,50,14
    PUSHBUTTON      "Cancel",IDCANCEL,129,24,50,14
END

And, if all else fails, you can do it programically:

int CALLBACK WndProc(
      HWND hwnd,
      UINT msg,
      WPARAM wParam,
      LPARAM lParam)
{
  switch ( msg ) {
    case WM_INITDIALOG:
      {
        [B]HINSTANCE hInstance = GetModuleHandle( NULL );
        SetMenu( hwnd, LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)) );[/B]
      }
      break;
    case WM_CLOSE:
      {
        EndDialog( hwnd, 0 );
      }
      break;
  }
  return 0;
}

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.