Solved

Dialog-based application

Posted on 1998-08-14
10
235 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

13 Experts available now in Live!

Get 1:1 Help Now