Owner Drawn Menu With Free Color '& Font

defaul1.gif.gif (4096 bytes)

Download Source Code and Example 35K

CFreeMenu:This class is a owner drawn menu, You will be able to:
1. Set the menu position
2. Set the menu background color
3. Set the menu bar's edge color
4. Set the menu text color
5. Set the menu text font
6. Set the first level menu as horizontal or vertical
7.Develop the class to implement menuitem with icon,and cool background menubar (as wood, metal ,or other picture etc.)

In order to use it,you need add the file freemenu.cpp ,freemenu.h,menuitemwnd.cpp and menuitemwnd.h to your project.If you don't change any of the code,you can get the 1-6 function.To redraw the CFreeMenu's method DrawMenu you can develop it.

In the beginning of  .H file add those code:

            #include "freemenu.h"

In the containing class add those code:

             CFreeMenu *m_Menu;

In the .CPP file of the class where you want use the menu add those code:

1. In initialization part(as CDialog class' OnInitDialog method,the CFreeMenu need a parent window) add those code:

    m_menu = new CFreeMenu(IDR_MENU1,     //The menu ID

                        CPoint(10,10),this,         //The Menu position and it's parent window
                        RGB(192,192,192),        //The Color of the menu bar's background
                        RGB(255,225,255),        //The Color of the menu bar's left and up edge
                        RGB(128,128,128),        //The Color of the menu bar's right and down edge
                        RGB(0,0,0),&font,0);     //The Color and font of the menu text, when the

                                                            // last parameter is 0 the first level of the menu if

                                                            // horizontal,1 meant vertical

2.Where you need the menu you add those code:

3.In your class derive the WindowProc method to call the function:

void CTestdiDlg::OnMenuitem32782()
    AfxMessageBox("Test menu");   

LRESULT CTestdiDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    return CDialog::WindowProc(message, wParam, lParam);

Download demo project 35K

Last updated: 26 June 1998