Author Topic: Colored menu/status bar  (Read 585 times)

clamicun

  • Member
  • ***
  • Posts: 347
Colored menu/status bar
« 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.

clamicun

  • Member
  • ***
  • Posts: 347
Re: Colored menu/status bar
« Reply #1 on: May 16, 2019, 07:48:49 PM »

this one does it directly.
Don't know why.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6754
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Colored menu/status bar
« Reply #2 on: May 17, 2019, 12:46:38 PM »
Runs OK here on Win10 64 Pro.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

clamicun

  • Member
  • ***
  • Posts: 347
Re: Colored menu/status bar
« Reply #3 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.

jj2007

  • Member
  • *****
  • Posts: 9792
  • Assembler is fun ;-)
    • MasmBasic
Re: Colored menu/status bar
« Reply #4 on: May 17, 2019, 08:36:05 PM »
Congrats, the last version works fine :t

clamicun

  • Member
  • ***
  • Posts: 347
Re: Colored menu/status bar
« Reply #5 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

TimoVJL

  • Member
  • ***
  • Posts: 476
Re: Colored menu/status bar
« Reply #6 on: May 19, 2019, 09:47:24 PM »
A good trick :t

Code: [Select]
...
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);
May the source be with you

clamicun

  • Member
  • ***
  • Posts: 347
Re: Colored menu/status bar
« Reply #7 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