Solved

Dialog-based application

Posted on 1998-08-14
10
237 Views
Last Modified: 2013-11-20
Which base class can I use after creating a menu resource  in a dialog-based appplication?

When I create a dialog based application and add a menu resource to it, I get the "add class" dialog.  But I don't
see CMenu as a choice.  Which class can I use for this menu resource?  I am using VC++ 5.0.  (I'm just a rookie...but
I must learn MFC!!)

Any good books you can recommend??
Let me know...

Please help....
Thanks, Joe

PS --  Please send to this address also:

Joseph Pagliarulo/Mount Pleasant/Contr/IBM@IBMUS
0
Comment
Question by:pagz
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 2

Expert Comment

by:kinkajou
ID: 1320828
Inside Visual C++ is a great book for learning MSVC++ 5.0 and MFC.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1320829
From my experience not all versions of VC++ come with that book, mine didn't, but I have the "Enterprise Edition" so I don't know if they just think I know everything ;-)
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1320830
That would be MS Press and Kruglinski...
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1320831
Also, for the problem, you do derive the menu from CMenu even though that's not an option.  Seems to me that Class wizard has a few problems.  If you just want to make the menu show up in your dialog box, select "Select an existing class" and choose your dialog box class.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 50 total points
ID: 1320832
Uh, no.  The reason that CMenu doesn't show up in the list of classes offered by ClassWizard is that you almost never need to derive your own class from CMenu--you'd only want to derive your own class if you were doing owner-draw menus. (If you look at the CMenu declaration or the documentation, you'll notice it only has two virtual functions, and both of them have to do with owner-draw.)

If you want to use a menu, just instantiate a CMenu.  Then, use the LoadMenu() member to load the resource.  Then, call SetMenu() on the dialog object to set the CMenu.

It's really easy. It's not even five lines of code, so why bother with a Wizard?

B ekiM

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:thresher_shark
ID: 1320833
I meant that he could derive a class from CMenu, but ClassWizard would not allow it.

If you don't want to write any code, simply select "Select an existing class" then select the name of your dialog box class.  Then, when you start the program, the menu will show up in the dialog box just like any other menu you've seen.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1320834
Uh, look: you're still all wet, Thresher_Shark. You don't need to derive from CMenu unless you're doing owner-draw. This question has nothing to do with owner-draw menus, so deriving from CMenu is trivial.

If you don't want to write any code, simply use the "Menu" setting in the properties of the dialog itself to get the menu resource directly associated with the dialog resource. Your "don't want to write any code" advice is the long way around.

B ekiM


0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1320835
>> If you just want to make the menu show up in your dialog box,
>> select "Select an existing class" and choose your dialog box
>> class.

Even if it is the long way around, what's wrong with it?  I know that when you derive from CMenu, you are most likely creating a new kind of menu, unless you just want to derive from it so you can use your own class name but that would be stupid and pointless.

There are simply several solutions to this problem, I suggested one, and you suggested one.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1320836
What's wrong with it is that it's the long way around: it's inefficeint and overly tedious.

Associating a menu with a class just tells ClassWizard that the menu choices in the menu should be available as commands in the class you choose, or in the class you newly create. It won't cause the menu to be displayed when an instance of that class creates a window.

If you want to instantiate and manipulate the menu, you'll want a CMenu, as I suggest.  If you don't need manipulation, you'll want to set the resource as I suggest.

B ekiM
0
 

Author Comment

by:pagz
ID: 1320837
I think Mike's a pro. Very brief and to the point with the problem.  I'm really fascinated with VC++ but I still find myself at a standstill most of the time.  I really want to learn it.

Thanks Mike
Joe
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 62
Best tools for Backup and restore of Wordpress site 6 55
sumNumber challenge 16 110
java ^ examples 8 62
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now