The MASM Forum

General => The Workshop => Topic started by: clamicun on April 09, 2019, 12:16:59 AM

Title: Popup Menu
Post by: clamicun on April 09, 2019, 12:16:59 AM
This is an old example from jj - Oct. 2013 - simplewin
Create a menu and submenu without a resource file

mov esi, rv(CreateMenu)      ; create the main menu
mov edi, rv(CreateMenu)      ; create a sub-menu

invoke AppendMenu, esi, MF_POPUP, edi, chr$("&File")   ; add it to the main menu

invoke AppendMenu, edi, MF_STRING, 101, chr$("&New")   ; and add submenu
invoke AppendMenu, edi, MF_STRING, 102, chr$("&Save")   
invoke AppendMenu, edi, MF_STRING, 103, chr$("&Save as")
invoke AppendMenu, edi, MF_STRING, 104, chr$("&Exit")   

invoke SetMenu, hWnd, esi      ; attach menu to main window

I can write:
invoke AppendMenu, esi, MF_POPUP, edi, chr$("&File")       ; add it to the main menu
invoke AppendMenu, esi, MF_POPUP, edi, chr$("&Extras")  ; add it to the main menu
and have File and Extras in the menubar.

Both show the same dropdownmenu
New
Save
Save as
Exit

How to get different Strings in Extras ?
Title: Re: Popup Menu
Post by: jj2007 on April 09, 2019, 01:04:44 AM
Just repeat the steps:
Code: [Select]
mov ebx, rv(CreateMenu) ; create the main menu

mov esi, rv(CreatePopupMenu) ; create a sub-menu
invoke AppendMenu, esi, MF_STRING, 121, chr$("&Open") ; fill it
invoke AppendMenu, esi, MF_STRING, 122, chr$("&Save") ; with various
invoke AppendMenu, esi, MF_STRING, 123, chr$("Save&As") ; options
invoke AppendMenu, ebx, MF_POPUP, esi, chr$("&File") ; add it to the main menu

mov esi, rv(CreatePopupMenu) ; create a sub-menu
invoke AppendMenu, esi, MF_STRING, 121, chr$("&Copy") ; fill it
invoke AppendMenu, esi, MF_STRING, 122, chr$("&Paste") ; with various
invoke AppendMenu, esi, MF_STRING, 123, chr$("&Cut") ; options
invoke AppendMenu, ebx, MF_POPUP, esi, chr$("E&xtras") ; add it to the main menu
invoke SetMenu, hWnd, ebx ; attach menu to main window
Title: Re: Popup Menu
Post by: clamicun on April 09, 2019, 06:22:37 AM
jj,
thank a lot.
I got it.
There is no difference between CreateMenu and CreatePopupMenu ?
Title: Re: Popup Menu
Post by: clamicun on April 09, 2019, 06:37:03 AM
One last question.
In most popupmenu/dropdownmenus - resourcemenus as well  I see  &Open &Save ...
It functions without as well.
What is & good for ?
Title: Re: Popup Menu
Post by: jj2007 on April 09, 2019, 12:32:51 PM
The ampersand in e.g. "Save &as" says "user can use the A key to choose that menu item".
Title: Re: Popup Menu
Post by: TimoVJL on April 09, 2019, 03:40:33 PM
Menu Access Keys (https://docs.microsoft.com/fi-fi/windows/desktop/menurc/about-menus#menu-access-keys)
Title: Re: Popup Menu
Post by: Vortex on April 10, 2019, 03:15:35 AM
There is no difference between CreateMenu and CreatePopupMenu ?

Article : What's the difference between CreateMenu and CreatePopupMenu?

Quote
CreateMenu creates a horizontal menu bar, suitable for attaching to a top-level window. This is the sort of menu that says “File, Edit”, and so on.
CreatePopupMenu creates a vertical popup menu, suitable for use as a submenu of another menu (either a horizontal menu bar or another popup menu) or as the root of a context menu.
If you get the two confused, you can get strange menu behavior. Windows on rare occasions detects that you confused the two and converts as appropriate, but I wouldn’t count on Windows successfully reading your mind.

https://devblogs.microsoft.com/oldnewthing/20031230-00/?p=41273
Title: Re: Popup Menu
Post by: clamicun on April 10, 2019, 10:19:41 PM
Article : What's the difference between CreateMenu and CreatePopupMenu?

Yes, good explanation by Raymond
Title: Re: Popup Menu
Post by: clamicun on April 11, 2019, 11:37:29 PM
Hallelujah,
finally I have the bitmaps in the menubar.
Only thing I am still trying to change is the color of the menubar ? 
Title: Re: Popup Menu
Post by: jj2007 on April 11, 2019, 11:40:33 PM
Congrats :t

So you basically wanted a toolbar that opens popups. That was not so clear from the beginning ;-)
Title: Re: Popup Menu
Post by: clamicun on April 12, 2019, 02:33:02 AM
jj,
yes, but with bitmaps in the menubar because it looks "better" in my project.
Any idea how to change the color of the menubar ?
Seems to be white by default.

Create a brush and
INVOKE FillRect,handle of the  menu ... ?

There is an example in goasm.
Title: Re: Popup Menu
Post by: clamicun on April 14, 2019, 12:40:26 AM
Can someone show an example for:

invoke GetMenuBarInfo,handle_win, OBJID_MENU,0,addr mbi

Whatever I try, the return is error 87 - wrong parameter
Title: Re: Popup Menu
Post by: TimoVJL on April 14, 2019, 12:58:58 AM
Is mbi.cbSize set to sizeof(mbi) ?

EDIT: http://masm32.com/board/index.php?topic=3176.0

EDIT: sizeof = 32
Code: [Select]
MENUBARINFO STRUCT
 cbSize DWORD ?
 rcBar RECT <>
 hMenu PTR ?
 hwndMenu PTR ?
 fBarFocused DWORD ?
; fFocused DWORD ?
MENUBARINFO ENDS
Title: Re: Popup Menu
Post by: clamicun on April 14, 2019, 02:01:48 AM
sure it is.

I see "the structure" in windows.inc might be wrong.
I sure dont't know how to fix that
Title: Re: Popup Menu
Post by: AW on April 14, 2019, 04:41:24 AM
The structure is wrong in Windows.inc

Try:

(untested)

BFIELD RECORD fBarFocused:1,fFocused:1, Other:30

_MENUBARINFO struct
  cbSize DWORD sizeof _MENUBARINFO
  rcBar RECT <0>
  hMenu HMENU 0
  hwndMenu HWND 0
  bitf BFIELD <0>
_MENUBARINFO ends


.data
mbar _MENUBARINFO <>

There is a macro somewhere to retrieve bit fields, if needed. But it can be done without macro.
Title: Re: Popup Menu
Post by: clamicun on April 14, 2019, 06:28:52 AM
AW,
thanks. Had the same (similar) ideia.

_MENUBARINFO STRUCT
   cbSize                 DWORD ?
   rcBar                  RECT <>
   hMenu                DWORD ?
   hwndMenu           DWORD ?
   fBarFocused         WORD ?
   fFocused              WORD ?
_MENUBARINFO ENDS

At least GetMenuBarInfo returns 1
Title: Re: Popup Menu
Post by: clamicun on April 15, 2019, 11:45:39 PM
AW,
yes, your structure seems to work.
But I do not understand the values returned by rcBar

mbar.rcBar.left"
mbar.rcBar.right
...
...
They definitely dont correspond to my menu, created with CreateMenu

invoke GetMenuBarInfo.hwnd
MS says: "A handle to the window (menu bar) whose information is to be retrieved."

That is the handle of the mainwindow which contains the menu or to the menubar ?
Title: Re: Popup Menu
Post by: AW on April 16, 2019, 02:05:14 AM
I understand your code is secret and you can't publish it but I have no idea what you are doing.
Title: Re: Popup Menu
Post by: clamicun on April 16, 2019, 03:51:01 AM
AW,
???
Why my code is secret ?

I wrote this a couple of times by now:

invoke GetMenuBarInfo,handle_win, OBJID_MENU,0,addr -mbi
(Last time I asked this: handle_win is the handle of the mainwindow of the application or ?)

I check the values
_mbi.rcBar.right
_mbi.rcBar.bottom

Weird values.

They very likely should be:
right = mainwindow width
bottom = ca. 25p (menubar with text)
Title: Re: Popup Menu
Post by: AW on April 16, 2019, 04:27:58 AM
If the function returns false then  use GetLastError to know the exact reason for the error.   ;)
Title: Re: Popup Menu
Post by: clamicun on April 16, 2019, 04:41:28 AM
AW,
???
I wrote that already. With your modified structure the function GetMenuBarInfo returns 1.
I am talking about the values of _mbi.rcBar.
Title: Re: Popup Menu
Post by: AW on April 16, 2019, 05:29:01 AM
If you don't show your code, all I can do is wish you a good luck, you may even find the bug by yourself.  :t
Title: Re: Popup Menu
Post by: clamicun on April 16, 2019, 07:41:01 AM
Thank you very much. You're really stubborn ... show code ... it's a normal window ... In WM_CREATE  I create a menu and popupmenu. Everything is business as usual and works fine ... What would you like to see ? ... I am just trying to get all sorts of info about the menubar, cause I would like to change the color of it. Right now it's "GetMenuBarInfo" I am playing with and simply do not understand the values of _mbi.rcBar. right, bottom, left  ... btw. the code is in my  file.zip
Title: Re: Popup Menu
Post by: clamicun on April 17, 2019, 05:23:13 AM
By now I read about 15 articles on GetMenuBarInfo.
I swear noone mentioned that the values returned by mbi.rcBar. ...
correspond to screendimensions.
Title: Re: Popup Menu
Post by: HSE on April 17, 2019, 09:31:19 AM
Clamicum:

You have not posted files using structure.

Sometimes I forgot to make (before to getinfo):
Code: [Select]
mov mbi.cbsize, sizeof _MENUBARINFO
In the 15 articles have to say: A handle to the menu bar whose information is to be retrieved!  (ebx in MinWin)
Title: Re: Popup Menu
Post by: clamicun on April 18, 2019, 12:13:49 AM
HSE,
I was talking on the strange results in mbi.RcBar. xxx
They are not strange at all if you know, that they correspond to Screendimensions
Title: Re: Popup Menu
Post by: HSE on April 18, 2019, 01:00:41 AM
Work perfect but is owner Window handle:
Code: [Select]
   invoke GetMenuBarInfo, hWnd, OBJID_MENU,0, addr mbi

Title: Re: Popup Menu
Post by: clamicun on April 20, 2019, 08:14:14 PM
No chance to colorize the menubar
??
Title: Re: Popup Menu
Post by: jj2007 on April 20, 2019, 09:18:46 PM
No chance to colorize the menubar

Why don't you go for The Real Thing - a toolbar?
Title: Re: Popup Menu
Post by: clamicun on April 20, 2019, 10:42:28 PM
jj,

The Real Thing ... What actually is the differenz between toolbar and menubar ?

btw.
7-zip: Die Datei  ToolbarDemoJpg.zip kann nicht geöffnet werden. Ist kein Archiv.
Not important if it is just a picture
Title: Re: Popup Menu
Post by: HSE on April 21, 2019, 01:08:45 AM
No chance to colorize the menubar
??
No problem I think, but you have to subclass menubar.
Title: Re: Popup Menu
Post by: clamicun 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 ?
Title: Re: Popup Menu
Post by: TimoVJL 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 (http://masm32.com/board/index.php?topic=7435.msg81276#msg81276) use normal toolbar for menu, and at least jj knows how it works.
Title: Re: Popup Menu
Post by: HSE on April 21, 2019, 02:48:32 AM
That is "C" not assembly!
Title: Re: Popup Menu
Post by: clamicun 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.
Title: Re: Popup Menu
Post by: clamicun on April 21, 2019, 04:01:40 AM

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

? What does that mean ?
Title: Re: Popup Menu
Post by: HSE on April 21, 2019, 05:39:38 AM
? What does that mean ?

Not worry, apparently doesn't work.
Title: Re: Popup Menu
Post by: clamicun on April 21, 2019, 09:49:01 PM
Nobody has an idea ?. It must be possible to colorize a menubar

 :(
Title: Re: Popup Menu
Post by: jj2007 on April 21, 2019, 11:05:21 PM
Search for "TBSTYLE_CUSTOMERASE", or go straight to SOF (https://stackoverflow.com/questions/26941925/how-to-change-toolbar-control-color).
Title: Re: Popup Menu
Post by: clamicun 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.
Title: Re: Popup Menu
Post by: TimoVJL on April 22, 2019, 01:47:59 AM
Toolbar have options TBSTYLE_FLAT and TBSTYLE_TRANSPARENT, for no background erasing.
Title: Re: Popup Menu
Post by: clamicun 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" ?

Title: Re: Popup Menu
Post by: jj2007 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 (https://www.c-plusplus.net/forum/48288-full)

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.

Title: Re: Popup Menu
Post by: HSE 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.
Title: Re: Popup Menu
Post by: clamicun 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
Title: Re: Popup Menu
Post by: jj2007 on April 22, 2019, 07:09:33 AM
Hallo Mic,

Colouring the menu bar is not foreseen in Windows afaik. I vaguely remember to have read somewhere that "menus are windows", so they might have a WndProc and a WM_ERASEBGND message, but Google is not my friend tonight :(

Good luck and Happy Easter :icon14:
Title: Re: Popup Menu
Post by: Biterider on April 22, 2019, 03:50:41 PM
Hi clamicun
I'm not sure what you want to do. I send you a demo where I used the the "Owner Draw" method to customize the menu drawing.
In this particular example, I painted the "Help" main menu item with the COLOR_GRADIENTACTIVECAPTION system color.

If this is what you want, I can provide you the source to adapt it to your project  :P

Regards, Biterider
Title: Re: Popup Menu
Post by: AW on April 22, 2019, 04:07:10 PM
I vaguely remember to have read somewhere that "menus are windows", so they might have a WndProc and a WM_ERASEBGND message
What you might have read was "Menu of windows" not "Menu are windows".  A little word that changes the whole case.
This does not mean it can't be painted. All you need is a brush.  :t
Title: Re: Popup Menu
Post by: jj2007 on April 22, 2019, 04:42:58 PM
I send you a demo where I used the the "Owner Draw" method to customize the menu drawing.

Impressive :t
Title: Re: Popup Menu
Post by: clamicun on April 22, 2019, 06:51:31 PM
jj,
thanks a lot.
Finally a satisfactory answer. This explains the many unsuccessful attempts in several programming languages.
Have a good one
Mic
Title: Re: Popup Menu
Post by: TimoVJL on April 22, 2019, 08:04:35 PM
mov mi.fMask,MIM_BACKGROUND or MIM_APPLYTOSUBMENUS
and the result was yellow.
But you wanted something else ?
Title: Re: Popup Menu
Post by: clamicun on April 22, 2019, 09:14:38 PM
TimoVJL,
that is exactly what I want. Not necessarily the dropdownmenu (MIM_APPLYTOSUBMENUS)
but the menubar.
How did you do that ?
Whatever I do, only the dropdownmenu gets the color of the brush
Title: Re: Popup Menu
Post by: TimoVJL on April 22, 2019, 09:56:47 PM
I was using a Windows Classic theme, so it's a theme problem with menu.

EDIT: SetWindowTheme(hWnd, L"", L"");
EDIT:
Code: [Select]
sUXT db "UxTheme.dll",0
sFunc db "SetWindowTheme",0
swNull dw 0
Wnd dd ?

.code
start:
INVOKE LoadLibraryA, ADDR sUXT
.if eax
INVOKE GetProcAddress, eax, ADDR sFunc
.if eax
push OFFSET swNull
push OFFSET swNull
push [Wnd]
call eax
.endif
.endif
Title: Re: Popup Menu
Post by: HSE on April 22, 2019, 11:19:15 PM
I was using a Windows Classic theme
I "discover" yesterday that Menu SystemColors don't work with Aero theme I have  :biggrin:
Title: Re: Popup Menu
Post by: Biterider on April 23, 2019, 06:32:48 AM
Hi
Passing a brush to the SetMenuInfo API, it is perfectly possible to draw on the complete MenuBar and there is no need to change the windows theme settings.
Tested on Win 10 & Win7.

Regards, Biterider
Title: Re: Popup Menu
Post by: HSE on April 23, 2019, 09:31:24 AM
Just random luck: the menubar have colors if you disable visual themes in binary compatibility properties  :t
Title: Re: Popup Menu
Post by: clamicun on April 23, 2019, 05:58:55 PM
Hi Biterider,

???  7-Zip
OwnerDraw.zip
Die Datei kann nicht geöffnet werden
Can't open file
Ist kein Archiv
It isn't an arquive
Title: Re: Popup Menu
Post by: Biterider on April 23, 2019, 06:03:26 PM
Hi Clamicun
OwnerDraw.zip is a jpg file renamed to .zip, so that the forum SW can display it.

Regards, Biterider
Title: Re: Popup Menu
Post by: Biterider on April 23, 2019, 06:42:26 PM
Hi
I'm playing with this implementation to let the MenuBar flash asynchroniously to get the users attention.
I modified the code to trigger the flashing when a new MDI client window is created or the help or about dialog are shown.  8)

Regards, Biterider
Title: Re: Popup Menu
Post by: clamicun on April 23, 2019, 07:05:59 PM
jj,
what is this ?

http://vbnet.mvps.org/index.html?code/menu/menucolour.htm
Title: Re: Popup Menu
Post by: clamicun on April 23, 2019, 08:10:35 PM
Biterider,
ok.
Pity, I hoped it would be source
Title: Re: Popup Menu
Post by: jj2007 on April 23, 2019, 08:49:28 PM
what is this ?

Probably what you were looking for :biggrin:

Attention, it might not work with Aero themes on.
Title: Re: Popup Menu
Post by: clamicun on April 23, 2019, 09:18:01 PM
sUXT db "C:\windows\system32\UxTheme.dll",0
sFunc db "SetWindowTheme",0
swNull dw 0

.code
start:
   INVOKE LoadLibrary, ADDR sUXT
   .if eax
      INVOKE GetProcAddress, eax, ADDR sFunc
      .if eax
         push OFFSET swNull
         push OFFSET swNull
         call eax
      .endif
   .endif

TimoVJL,
Unfortunately not.
The dropdownmenu is colored, but not the menubar


Title: Re: Popup Menu
Post by: HSE on April 23, 2019, 09:25:34 PM
Attention, it might not work with Aero themes on.

Disabling "visual themes" in properties of .exe file you obtain a classic window with Aero theme around!

@Clamicum:
   This is exactly your second .exe file:
Title: Re: Popup Menu
Post by: Biterider on April 23, 2019, 10:21:41 PM
Hi clamicun
I send you the most important files with which you can look into the MenuBar functionality.
XMenu is the most important file. In particular, look into FlashMenuBar method.

Regards, Biterider

PS: the source code is 32/64 bit!
Title: Re: Popup Menu
Post by: AW on April 24, 2019, 01:59:29 AM
This is a colored menubar with a hatched background. No need for themes.
It is easy to do, so I believe you are talking about something different.
(https://www.dropbox.com/s/ptn3yunwpxm1khy/ownerdrawn.jpg?dl=1)
Title: Re: Popup Menu
Post by: clamicun on April 24, 2019, 04:10:23 AM
AW,
thats exactly what I am talking about but on my 2 computers (win7 and win 10) it doesn't work with SetMenuInfo.  (MIM_BACKGROUND + MIM_APPLYTOSUBMENUS).
Only the dropdownmenu (in your picture "Exit" gets colored
Title: Re: Popup Menu
Post by: AW on April 24, 2019, 04:54:13 AM
No themes means: it works in Windows 2000 as well.
(https://www.dropbox.com/s/paiirtemcnm4tzq/ownerdrawn2.jpg?dl=1)

In summary:
1) In WM_CREATE you make the background with SetMenuInfo and mask MIM_BACKGROUND (no  MIM_APPLYTOSUBMENUS)
2) In WM_MEASUREITEM you define the itemWidth and itemHeight in the MEASUREITEMSTRUCT passed in the LPARAM
3) In WM_DRAWITEM you have the DRAWITEMSTRUCT passed in the LPARAM. From it you know what is the rectangle to paint.
Title: Re: Popup Menu
Post by: jj2007 on April 24, 2019, 08:26:16 PM
Work in progress ;-)

SetToolbarColour RgbCol(200, 255, 200)
Title: Re: Popup Menu
Post by: clamicun on April 26, 2019, 08:12:45 PM
AW,

In summary:
1) In WM_CREATE you make the background with SetMenuInfo and mask MIM_BACKGROUND (no  MIM_APPLYTOSUBMENUS)
2) In WM_MEASUREITEM you define the itemWidth and itemHeight in the MEASUREITEMSTRUCT passed in the LPARAM
3) In WM_DRAWITEM you have the DRAWITEMSTRUCT passed in the LPARAM. From it you know what is the rectangle to paint.

This refers to userdrawn menus. Works with others too? My example is not userdrawn
Title: Re: Popup Menu
Post by: TimoVJL on April 26, 2019, 09:02:24 PM
You might want to use that techique for menu with bitmaps ;)
A C example using that.
Title: Re: Popup Menu
Post by: AW on April 26, 2019, 09:45:02 PM
With Menubar OwnerDrawn is the way to go.
But best is Toolbar with or without dockbar.

(https://www.dropbox.com/s/dy01kz3axgtlnot/ownerdrawn3.gif?dl=1)
Title: Re: Popup Menu
Post by: felipe on April 26, 2019, 10:58:11 PM
that's nice  :icon14: