Menu Bars and Dialog Boxes  
Author Message
SaintAnger





PostPosted: Visual C++ General, Menu Bars and Dialog Boxes Top

Hi,

I am trying to add a menu bar on a dialog box but my attempts seem to fail miserably...

I can't see an option in the toolbox for a menu so i thought that i could create the menu and then add it to the dialog box... Is this plausible If so what's the procedure to do so

Otherwise does anyone know how to go about creating and adding a menu bar to a dialog box

Thanks

--Anger



Visual C++3  
 
 
Mike Danes





PostPosted: Visual C++ General, Menu Bars and Dialog Boxes Top

Since you are speaking about "Dialog Box" I suppose you are using MFC. So here are some steps to do it:

  • Add a menu resource to your resource file
  • Open the dialog box in the resource editor
  • Go to dialog box properties window and select the added menu resource in the Menu field

To add an event handler for a menu item:

  • Right click the menu item in the menu editor and select Add Event Handler
  • Select the class that you want to contain the event handler (the dialog class)
  • Press Add and Edit


 
 
SaintAnger





PostPosted: Visual C++ General, Menu Bars and Dialog Boxes Top

Done!

Thanks


 
 
LessThanThree





PostPosted: Visual C++ General, Menu Bars and Dialog Boxes Top

I was also having issue with trying to get a menu bar displaying in a dialouge box, I came across this post and found it very helpful up until the last step. Visual Studios won't let me hit the Add and Edit button, or enter any Message Types. Is there a solution to this

 
 
Mike Danes





PostPosted: Visual C++ General, Menu Bars and Dialog Boxes Top

Hmm... maybe the file where you want to add the event handler function is readonly


 
 
LessThanThree





PostPosted: Visual C++ General, Menu Bars and Dialog Boxes Top

No, I don't believe so. I've been editing the file both before and after the attempt.

EDIT: I figured out what was wrong, It was something simple that I over looked.