February 22, 2019
Hot Topics:

Owner-Draw Menus with .NET and Managed C++

  • April 29, 2005
  • By Tom Archer
  • Send Email »
  • More Articles »

Putting Everything into a Class

Now, condense everything into a more usable C++ class called ACG::MenuItem. Instead of redisplaying the same code already presented in the previous section, this section shows you only how to use the example class:
  1. Copy the ACG::MenuItem class from the demo project into your project.
  2. Insert the following code into your application's form-load method:
    // Instantiate the top level menu
    MenuItem* menuFile = new MenuItem(S"&File");
    // Instantiate the owner-draw menu, specifying the 
    // "click" event handler, font, and font's point size
    ACG::MenuItem* menuExit = 
      new ACG::MenuItem(S"E&xit", 
                        new EventHandler(this, ExitClick),
                        S"Comic Sans MS",
  3. Implement the "click" event handler:
    private: void ExitClick(Object* sender, EventArgs* e) 

Download the Code

To download the code for the demo application, click here.

About the Author

Tom Archer owns his own training company, Archer Consulting Group, which specializes in educating and mentoring .NET programmers and providing project management consulting. If you would like to find out how the Archer Consulting Group can help you reduce development costs, get your software to market faster, and increase product revenue, contact Tom through his Web site.

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date