In order to make my app more attractive,i wanna draw the menu bar myself,but i can not get the DC of it by useing API GetDC & GetWindowDC.It seems that the handle of a menu is not a window handle.So GetDC return NULL instead of returning the DC of the menu bar.I totally have no ideal about it.Could you gave me some help about it ! Thank you in advance!
Posted on 2004-08-10 06:55:43 by Rey
GetMenu?

The GetMenu function retrieves the handle of the menu assigned to the given window.

HMENU GetMenu(

HWND hWnd // handle of window
);

or maybe if its a on a dialog window i guess you could try

The GetDlgItem function retrieves the handle of a control in the specified dialog box.

HWND GetDlgItem(

HWND hDlg, // handle of dialog box
int nIDDlgItem // identifier of control
);
Posted on 2004-08-10 08:07:58 by HeXeN
Rey,

In order the change the appearance of the main menu of a window or any sub-menus, you will need to process two different window messages and also do some pre-processing of the menu items before/during the window creation method.

Here are the window messages to catch and process: (To make sure you are touching the menu and not some control), the structures used (MEASUREITEMSTRUCT and DRAWITEMSTRUCT), check the CtrlType == ODT_MENU.

WM_MEASUREITEM
WM_DRAWITEM

You will also need to go through each of the menu items in your WM_CREATE handler and modify the menu style to be owner-drawn. One you have the styles set, you will start getting WM_MEASUREITEM calls. This is where you do any additonal calculations you like to acheive before the drawing occurs.

Relvinian
Posted on 2004-08-10 12:01:35 by Relvinian
Thanks,i have done what i wanna do.Thank you for you great help.
I have implement XP-style menu under win98?
Posted on 2004-08-30 00:05:10 by Rey
Thanks,i have done what i wanna do.Thank you for you great help.
I have implement XP-style menu under win98?
Posted on 2004-08-30 00:05:48 by Rey