Menu background color is Blue and text color is White
(Colors depends on your Theme)
This is how I add the menu...
HMENU hSystemMenu = GetSystemMenu (hWnd, FALSE);
AppendMenu (hSystemMenu,MF_STRING, IDM_PMACTION_K, L"ABC");
AppendMenu (hSystemMenu,MF_POPUP, (UINT)hMenuPopup, L"XYZ");
I know that I can change the property of menu using MENUINFO
structure and SetMenuInfo ....something like this.....
MENUINFO mInfo;
mInfo.cbSize = sizeof(MENUINFO);
mInfo.fMask = MIM_BACKGROUND ;
mInfo.hbrBack = CreateSolidBrush(RGB(128,128,128));
SetMenuInfo((HMENU) hSystemMenu , &mInfo);
But the my problem is ...
1) It will apply this setting to entire System Menu...and not only to
'the two items added by me'
2) I can only change the background color ...using MENUINFO and
SetMenuInfo
a) but I can not change the text color
b) I can not change the Hilight color ( the selection color)
only for my two menu items...
> I can only change the background color ...using MENUINFO and
> SetMenuInfo
>
> a) but I can not change the text color
> b) I can not change the Hilight color ( the selection color)
> only for my two menu items...
Make them OD (WM_DRAWITEM, ...)
Do you mean Owner Draw ? How do i do that ?
Yes, with MF_OWNERDRAW or MFT_OWNERDRAW
Like described in MSDN
http://msdn.microsoft.com/en-us/library/ms647558.aspx
http://msdn.microsoft.com/en-us/library/bb756947.aspx
...
Hi There,
Thanks for the pointer..
I did read about Owner Draw menus and other control...
most of the place i find the example of MFC... Did not find any WIN32
api examples
there still few thing I am not getting any hold of ...
1) Do i really need to trap WM_MEASUREITEM message ...
What i have learnt for far is ppl trap this message ...iterate
through all the menus ...
Modify those menu to owner draw .....and supply the information
needed for owner draw using DRAWITEMSTRUCT
But in my case i belive ... i know in adnvace which menu i have to
owner draw...
so i can add that information right at the time of Append
menu .. .can't I ?
Note : I append these menu in WM_INITMENUPOPUP message handler
like this
HMENU hSystemMenu = GetSystemMenu (hWnd, FALSE);
AppendMenu (hSystemMenu,MF_STRING, IDM_PMACTION_K, L"ABC");
AppendMenu (hSystemMenu,MF_POPUP, (UINT)hMenuPopup, L"XYZ");
2) in WM_DRAWITEM handler ...
Can't I just check the
if (lpDrawItemStruct->itemID == IDM_PMACTION_K)
{
//Change the selection color or rollover color of this menu item
// change the font color
}
3) in WM_DRAWITEM handler ...
I get te Device context handle
HDC DC = lpDrawItemStruct->hDC;
Now I could not find any API to change the Brush
color ...rectangle order, text color ....
I see its quite easy using MFC , in MFC CDC provides API for doing
all these ., but could not find
WIN32 API for doing this
> Hi There,
> Thanks for the pointer..
> I did read about Owner Draw menus and other control...
> most of the place i find the example of MFC... Did not find any WIN32
> api examples
???
But there is absolutely no MFC in this MSDN documentation !
Set MF_OWNERDRAW and handle WM_DRAWITEM like OnMeasureItem sample.
There is nothing special to do
Hey there,
Thanks for giving me the pointer to learn more about Owner
Draw controls,
After reading couple of Articles and MSDN i have learnt that ...
generally most developer trap WM_MEASUREITEM and WM_DRAWITEM.
in WM_MEASUREITEM hnadler , They retrive they iterate through al the
menu ,
identify the menu they want to owner draw ....and then they modify
the
menu using ModifyMenu and make the menu item MF_OWNERDRAW and then
they also set MENUINFO ....
in WM_DRAWITEM handler , they retrive the information they had set
in WM_MEASUREITEM handler
using the DRAWITEMSTRUCT, which is passed in LPARAM lp.
Now My queries are
1) Is it really necessoy for me to handle WM_MEASUREITEM , and mark a
particular menu
as MF_OWNERDRAW ... and fill the DRAWITEMSTRUCT struct....
Can;t I do the same job done while, I am adding these menus..sing
Append Menu...
FYI: I add these menu lie this ...
if(wps->message == WM_INITMENUPOPUP)
{
HMENU hMenu = (HMENU)wps->wParam;
if ((IsMenu (hMenu) & (HIWORD(wps->lParam) == TRUE)))
{
HMENU hSystemMenu = GetSystemMenu (hWnd, FALSE);
AppendMenu (hSystemMenu, MF_SEPARATOR, 0, NULL);
AppendMenu (hSystemMenu,MF_OWNERDRAW, IDM_PMACTION_K, L"&Kill");
AppendMenu (hSystemMenu,MF_POPUP, (UINT)hMenuPopup, L"&Priority");
}
}
Also I remove them back on WM_MENUSELECT msg ...
2) Do i really need to fill struct DRAWITEMSTRUCT during
AppendMenu ???
can't i use the 3rd paramter of AppendMenu in WM_DRAWITEM item
handler ?
something like this ...
if (lparam->itemID == IDM_PMACTION_K)
{
change the Text color and text background color ( only if mouse
is rolled over)
}
I tried this but it did not work for me.
3) How to use HDC ??
have come across lots of MFC apps , which use
CDC and quite easily handle their functions like
Fill rectangle, DrawRectangle, settext color, text bck color
But could not find many examples on WIN32 API for doing the same
using HDC
4) I guess the answer of Query 1 is yes, but i am kinda lost on how
to fill the
DRAWITEMSTRUCT ....
All i want is I wanna Draw My menu items with custom selected
color and custom font color , when mouse is rolled over them
Is there any WIN32 example of filling DRAWITEMSTRUCT and then
retreiving it in WM_DRAWITEM handler..
Looks like we can pass anyting as the last parameter of AppendMenu
and ModifyMenu.... it need not be
DRAWITEMSTRUCT
Now My queries are
HMENU hSystemMenu = GetSystemMenu (hWnd, FALSE);
Not really sure why msg are not going ???
Hey there,
Thanks for giving me the pointer to learn more about Owner
Draw controls,
After reading couple of Articles and MSDN i have learnt that ...
generally most developer trap WM_MEASUREITEM and WM_DRAWITEM.
in WM_MEASUREITEM hnadler , They retrive they iterate through al the
menu ,
identify the menu they want to owner draw ....and then they modify
the
menu using ModifyMenu and make the menu item MF_OWNERDRAW and then
they also set MENUINFO ....
in WM_DRAWITEM handler , they retrive the information they had set
in WM_MEASUREITEM handler
using the DRAWITEMSTRUCT, which is passed in LPARAM lp.
Now My queries are
1) Is it really necessoy for me to handle WM_MEASUREITEM , and mark a
particular menu
as MF_OWNERDRAW ... and fill the DRAWITEMSTRUCT struct....
Can;t I do the same job done while, I am adding these menus..sing
Append Menu...
FYI: I add these menu lie this ...
if(wps->message == WM_INITMENUPOPUP)
{
HMENU hMenu = (HMENU)wps->wParam;
if ((IsMenu (hMenu) & (HIWORD(wps->lParam) == TRUE)))
{
HMENU hSystemMenu = GetSystemMenu (hWnd, FALSE);
> Now My queries are
>
> 1) Is it really necessoy for me to handle WM_MEASUREITEM , and mark a
> particular menu
> as MF_OWNERDRAW ... and fill the DRAWITEMSTRUCT struct....
>
> Can;t I do the same job done while, I am adding these menus..sing
> Append Menu...
>
> FYI: I add these menu lie this ...
>
>
> if(wps->message == WM_INITMENUPOPUP)
> {
> HMENU hMenu = (HMENU)wps->wParam;
> if ((IsMenu (hMenu) & (HIWORD(wps->lParam) == TRUE)))
> {
> HMENU hSystemMenu = GetSystemMenu (hWnd, FALSE);
> AppendMenu (hSystemMenu, MF_SEPARATOR, 0, NULL);
> AppendMenu (hSystemMenu,MF_OWNERDRAW, IDM_PMACTION_K, L"&Kill");
> AppendMenu (hSystemMenu,MF_POPUP, (UINT)hMenuPopup, L"&Priority");
> }
> }
>
> Also I remove them back on WM_MENUSELECT msg ...
Why don't you add them only once, on WM_CREATE for example ?
All others answers are on MSDN links : you just have to copy and paste
First of all apologize for multiple post .... it seem there is some
problem with Google Groups and there was few hours delay in displaying
the message in group ...
that;s why I posted multiple times