News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Popup Menu

Started by clamicun, April 09, 2019, 12:16:59 AM

Previous topic - Next topic

HSE

Quote from: clamicun on April 20, 2019, 08:14:14 PM
No chance to colorize the menubar
??
No problem I think, but you have to subclass menubar.
Equations in Assembly: SmplMath

clamicun

Funny thing is that everything seems to be ok.
invoke  SetMenuInfo returns 1.
Is it the SolidBrush ?

TimoVJL

background color is a menu feature. 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

That is "C" not assembly!
Equations in Assembly: SmplMath

clamicun

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


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

? What does that mean ?

HSE

Quote from: clamicun on April 21, 2019, 04:01:40 AM
? What does that mean ?

Not worry, apparently doesn't work.
Equations in Assembly: SmplMath

clamicun

Nobody has an idea ?. It must be possible to colorize a menubar

:(

jj2007

Search for "TBSTYLE_CUSTOMERASE", or go straight to SOF.

clamicun

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

#40
Toolbar have options TBSTYLE_FLAT and TBSTYLE_TRANSPARENT, for no background erasing.
May the source be with you

clamicun

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

#42
Quote from: clamicun on April 22, 2019, 02:20:50 AMWhere 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.


HSE

Quote from: clamicun on April 22, 2019, 02:20:50 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.
Equations in Assembly: SmplMath

clamicun

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