Author Topic: Popup Menu  (Read 3260 times)

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: Popup Menu
« Reply #30 on: April 21, 2019, 01:08:45 AM »
No chance to colorize the menubar
??
No problem I think, but you have to subclass menubar.

clamicun

  • Member
  • ***
  • Posts: 347
Re: Popup Menu
« Reply #31 on: April 21, 2019, 02:13:41 AM »
Funny thing is that everything seems to be ok.
invoke  SetMenuInfo returns 1.
Is it the SolidBrush ?

TimoVJL

  • Member
  • ***
  • Posts: 476
Re: Popup Menu
« Reply #32 on: April 21, 2019, 02:26:21 AM »
background color is a menu feature.
Code: [Select]
HMENU hMenu = GetSystemMenu(hWnd, 0);
MENUINFO mi;
mi.cbSize = sizeof(MENUINFO);
mi.fMask = MIM_BACKGROUND | MIM_APPLYTOSUBMENUS;
mi.hbrBack = GetStockObject(GRAY_BRUSH);
SetMenuInfo(hMenu, &mi);
toolbar / rebar can act as menubar, An old internet explorer is a good example.
Also TLPEView use normal toolbar for menu, and at least jj knows how it works.
May the source be with you

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: Popup Menu
« Reply #33 on: April 21, 2019, 02:48:32 AM »
That is "C" not assembly!

clamicun

  • Member
  • ***
  • Posts: 347
Re: Popup Menu
« Reply #34 on: April 21, 2019, 03:51:00 AM »
TimoVJL,

mov mi.fMask,MIM_BACKGROUND or MIM_APPLYTOSUBMENUS   
invoke GetStockObject,GRAY_BRUSH
mov mi.hbrBack,eax

paints the submenu gray but the menubar is still white.

clamicun

  • Member
  • ***
  • Posts: 347
Re: Popup Menu
« Reply #35 on: April 21, 2019, 04:01:40 AM »

No problem I think, but you have to subclass menubar.

? What does that mean ?

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: Popup Menu
« Reply #36 on: April 21, 2019, 05:39:38 AM »
? What does that mean ?

Not worry, apparently doesn't work.

clamicun

  • Member
  • ***
  • Posts: 347
Re: Popup Menu
« Reply #37 on: April 21, 2019, 09:49:01 PM »
Nobody has an idea ?. It must be possible to colorize a menubar

 :(

jj2007

  • Member
  • *****
  • Posts: 9792
  • Assembler is fun ;-)
    • MasmBasic
Re: Popup Menu
« Reply #38 on: April 21, 2019, 11:05:21 PM »
Search for "TBSTYLE_CUSTOMERASE", or go straight to SOF.

clamicun

  • Member
  • ***
  • Posts: 347
Re: Popup Menu
« Reply #39 on: April 22, 2019, 01:01:53 AM »
jj, thank you and happy easter !

Use the TBSTYLE_CUSTOMERASE style on the control:
Generates NM_CUSTOMDRAW notification codes when the toolbar processes WM_ERASEBKGND messages.
Then you handle the NM_CUSTOMDRAW notification and when you get the CDDS_PREERASE event, draw your own background and return CDRF_SKIPDEFAULT.

That definitely makes lots of sense to me. Starting with what control.
The menu is created with CreateMenu and CreatePopupMenu.

TimoVJL

  • Member
  • ***
  • Posts: 476
Re: Popup Menu
« Reply #40 on: April 22, 2019, 01:47:59 AM »
Toolbar have options TBSTYLE_FLAT and TBSTYLE_TRANSPARENT, for no background erasing.
« Last Edit: April 22, 2019, 03:28:25 AM by TimoVJL »
May the source be with you

clamicun

  • Member
  • ***
  • Posts: 347
Re: Popup Menu
« Reply #41 on: April 22, 2019, 02:20:50 AM »
TimoVJL,

This produces a perfekt dropdownmenu.

      mov ebx, rv(CreateMenu)                     ; create the main menu
             
      mov esi, rv(CreatePopupMenu)            ; create the first sub-menu
      invoke AppendMenu, esi, MF_STRING, 101, chr$("&Open")   ; fill it
      invoke AppendMenu,esi,MF_SEPARATOR,0,0
      invoke AppendMenu, esi, MF_STRING, 102, chr$("&Save")    ; with various
      invoke AppendMenu,esi,MF_SEPARATOR,0,0
      invoke AppendMenu, esi, MF_STRING, 103, chr$("Save&As")   ; options
      invoke AppendMenu,esi,MF_SEPARATOR,0,0
      invoke AppendMenu, esi, MF_STRING, 105, chr$("&Exit")   

      invoke AppendMenu, ebx,MF_POPUP,esi,chr$("&File")       ; add sub-menu to the main menu
      invoke SetMenu, hWnd, ebx                                               ; attach menu to main window

All I want is colorizing the menubar.

Where to insert "Toolbar Control and Button Styles" ?


jj2007

  • Member
  • *****
  • Posts: 9792
  • Assembler is fun ;-)
    • MasmBasic
Re: Popup Menu
« Reply #42 on: April 22, 2019, 02:49:06 AM »
Where to insert "Toolbar Control and Button Styles" ?

Menus and toolbars are very different animals...

  invoke CreateWindowEx, 0, Chr$("ToolbarWindow32"), 0,
   WS_CHILD or WS_VISIBLE or CCS_ADJUSTABLE or TBSTYLE_FLAT or TBSTYLE_AUTOSIZE or TBSTYLE_CUSTOMERASE,
   0, 0, 99, 99, hWin, eax, esi, NULL   ; TbStartID-1, allows to get handle
...
  mov imgList, rv(ImageList_Create, eax, eax, ILC_MASK or ILC_COLOR24, maxfiles, 0)     ; inspired by deutsche Site

TB_ADDBUTTONS ... TB_SETIMAGELIST ... etc, the whole module is over 500 lines and somewhat complicated, can't post it here. Check if it should look like the attached exe.

« Last Edit: April 22, 2019, 04:25:07 AM by jj2007 »

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: Popup Menu
« Reply #43 on: April 22, 2019, 04:03:38 AM »
All I want is colorizing the menubar.

I found that menubar is drawing calling apfnSimpleCall. Then is a 1985 Windows function. For sure, at that time, developers think that modifications in SystemColors were enough.

Like JJ and Timo pointed, toolbar control provide all needed to replace menubar.

clamicun

  • Member
  • ***
  • Posts: 347
Re: Popup Menu
« Reply #44 on: April 22, 2019, 04:49:47 AM »
Menus and toolbars are very different animals...

Ja, Jochen,
In Deinem SimpleEditor "File Language" ist die Menubar (menubar ?), die Bitmaps sind in der Toolbar (toolbar ?).

Irgendwie rede ich permanent an jedem vorbei oder jeder redet an mir vorbei.
In meinem Beispiel - Post vor Deinem - rede ich von Dropdownmenu.
Das Beispiel ist Dein MiniWin Beispiel.
Alles, was ich möchte, ist die Menubar in einer anderen Farbe als weiss.
Wenn es nicht geht, geht es nicht (kann ich mir nicht vorstellen).
Viel Möglichkeiten gibt es in SetMenuInfo ja nicht, bis auf:

mov mi.fMask,                                                             
mov mi.dwStyle,

Nochmals fröhliche Ostereier.
Ich lass Dich jetzt auch ganz bestimmt in Ruhe