944,089 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 753
  • C++ RSS
Nov 5th, 2009
1

(IDE) [VC++ 6.0] Dialog Control [Not MFC]

Expand Post »
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
Last edited by scriptkiddy; Nov 5th, 2009 at 11:21 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scriptkiddy is offline Offline
19 posts
since Nov 2009
Nov 5th, 2009
0
Re: (IDE) [VC++ 6.0] Dialog Control [Not MFC]
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"
MENU IDR_MENUNAME
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:
      {
        HINSTANCE hInstance = GetModuleHandle( NULL );
        SetMenu( hwnd, LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)) );
      }
      break;
    case WM_CLOSE:
      {
        EndDialog( hwnd, 0 );
      }
      break;
  }
  return 0;
}
Hope this helps.
Attached Thumbnails
Click image for larger version

Name:	prev1.jpg
Views:	18
Size:	59.0 KB
ID:	12458  
Last edited by William Hemsworth; Nov 5th, 2009 at 7:40 pm.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: coding help, reverse array, check for palindrome
Next Thread in C++ Forum Timeline: Host intrusion detection system- help required





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC