The MASM Forum

General => The Workshop => Topic started by: clamicun on May 16, 2019, 09:06:09 AM

Title: Colored menu/status bar
Post by: clamicun on May 16, 2019, 09:06:09 AM
Finally,
the experts said there is no way to change the color of a a menubar.
There is. And it is quite easy.
Runs on windows 10 Home 64b.
Title: Re: Colored menu/status bar
Post by: clamicun on May 16, 2019, 07:48:49 PM

this one does it directly.
Don't know why.
Title: Re: Colored menu/status bar
Post by: hutch-- on May 17, 2019, 12:46:38 PM
Runs OK here on Win10 64 Pro.
Title: Re: Colored menu/status bar
Post by: clamicun on May 17, 2019, 08:21:04 PM
hutch,
good to know.

The  thing is to set the first popupmenu  (only the first !) as MF_POPUP or MF_BITMAP or MF_OWNERDRAW.
The bmp is not important. In my case it only sets the menubar to 25 pixels.
Not even an expert like jj  ("Colouring the menu bar is not foreseen in Windows afaik)
knew of this easy possibility.
Title: Re: Colored menu/status bar
Post by: jj2007 on May 17, 2019, 08:36:05 PM
Congrats, the last version works fine :t
Title: Re: Colored menu/status bar
Post by: clamicun on May 17, 2019, 09:31:20 PM
jj,
it is almost too easy.
The first and only MF_OWNERDRAW causes the SetMenuInfo function to set the background color of the menubar

mov mi.fMask,MIM_BACKGROUND
mov eax,hBrush
mov mi.hbrBack,eax     

Now, in my project I would like to replace all
invoke AppendMenu, ebx,MF_POPUP,esi,chr$("&First popup") .....
with
invoke AppendMenu, ebx,MF_POPUP or MF_BITMAP,esi,bitmaphandle

And to  provide the bmps with tooltips
Working on that
Title: Re: Colored menu/status bar
Post by: TimoVJL on May 19, 2019, 09:47:24 PM
A good trick :t

...
hBM1x16 = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(8001));
...
hMenu = CreateMenu();
AppendMenu(hMenu, MF_ENABLED | MF_POPUP | MF_OWNERDRAW | MF_BITMAP, (UINT)0, (LPCTSTR)hBM1x16);
hMenuF = CreatePopupMenu();
AppendMenu(hMenuF, MF_ENABLED | MF_STRING, IDM_EXIT, TEXT("&Exit"));
AppendMenu(hMenu, MF_ENABLED | MF_POPUP | MF_OWNERDRAW, (UINT)hMenuF, TEXT("&File"));
SetMenu(hWnd, hMenu);
Title: Re: Colored menu/status bar
Post by: clamicun on May 19, 2019, 10:43:11 PM
Last version.
Found out. If you provide the submenus with a bitmap instead of text, the bitmap gets real strange on click , but works fine