News   Articles   Sources   Code libraries    RSS

Language:

English   Russia  

Current filter:

All   C#   C++   C  



Log in:

Name
Pass

Register

XP Style Menu with CMenuXP 1.1

XP Style Menu with CMenuXP

Language:C++
Category:Desktop
Subcategory: Decoration
Date: 2008-07-09
Downloads:0
Size:115 kb
Author:Jean-Michel LE FOL`
Requirements:
Limitations:

This source code presents an implementation of an owner drawn menu with the Office XP and Visual Studio .NET visual style. To use the CMenuXP class in your projects, you have to add 3 macros in your code only.

To use the CMenuXP class in your projects, you have to add 3 macros in your code.

1. In the header file of the class that handles the menu (probably the MainFrame):

#include "Tools/MenuXP.h"  // Before the declaration of the class
// ...
DECLARE_MENUXP()           // Into the definition of the class

2. In the source file of the same class:

IMPLEMENT_MENUXP(className, baseClass);

3. In the message map of the class:

BEGIN_MESSAGE_MAP(className, baseClass)
// ...

  ON_MENUXP_MESSAGES()   // <-- Added line

END_MESSAGE_MAP()

To make borders flat, I subclass the popup menu window managed by the system. To make it possible, you have to add those 2 calls in your code:

1. In the InitInstance method of your CWinApp derived class:

CMenuXP::InitializeHook();

2. In the ExitInstance method of your CWinApp derived class:

CMenuXP::UninitializeHook();

To make the menubar flat, you must do this call:

CMenuXP::UpdateMenuBar (pFrameWnd); // pFrameWnd refers to the frame 
                // that contains the MenuBar

The best place for this call depends of the frame type:

  • For MDI application, into the OnUpdateFrameMenu method of the child windows.
  • For SDI application, into the LoadFrame method of the main frame.

Finally, don't forget the last call:

CMenuXP::SetXPLookNFeel (pFrameWnd); // refers to the frame that contains the MenuBar

Without this call, menus will appear in a standard mode.

Download XP Style Menu with CMenuXP 1.1


Send your comment

Your name:
Vote:
Title:
Comment:
Protection code:





Submit an article   Submit a file

Copyright © HackishCode.com 2008. All rights reserved
WEB Design and WEB Development by WEB consulting company ProfWebDev.com
www.hackishcode.com