The MASM Forum

General => The Workshop => Topic started by: clamicun on April 03, 2019, 04:41:51 AM

Title: Bitmap in popup menu
Post by: clamicun on April 03, 2019, 04:41:51 AM
For days I try to get a bitmap in the head of a POPUP menu.

Bitmap button instad of the text "Select ..."
The button (bitmap.bmp) and toolinfo are ready but how to put it in the menu ?

   POPUP "Select..."  ;   !! here the button
   BEGIN
      MENUITEM "Eine Datenbank",IDM_13
      MENUITEM SEPARATOR
      MENUITEM "Datenbank Startseite",IDM_14
      MENUITEM SEPARATOR
      MENUITEM "Info Benutzer",IDM_15
      MENUITEM SEPARATOR
      MENUITEM "Exit",IDM_EXIT

   END

Some info, please
Title: Re: Bitmap in popup menu
Post by: aw27 on April 03, 2019, 11:57:02 PM

POPUP text, [optionlist] {item-definitions ...}

Do you know what text means?

What you want is a button that activates a dropdown like a list box, it is not a pop menu menu.
Title: Re: Bitmap in popup menu
Post by: fearless on April 04, 2019, 01:05:07 AM
Something like this dropdown perhaps?
(https://i.postimg.cc/PJrZjnkT/dropdownbuttonmenu.png)
Uses Rebar control to host toolbars and the dropdown button, which when clicked shows a popup menu. Popup menu is positioned just below the dropdown button to achieve the effect.
Title: Re: Bitmap in popup menu
Post by: LiaoMi on April 04, 2019, 01:37:35 AM
 :icon14:
Title: Re: Bitmap in popup menu
Post by: clamicun on April 04, 2019, 03:19:35 AM
AW
??
But the syntax in the ressourcemenu is

POPUP "......."  ;   
   BEGIN
      MENUITEM "xxxxxxxxxxxxxxxx",IDM_13
      "
If you use a different expression, it doesn't work
Title: Re: Bitmap in popup menu
Post by: clamicun on April 04, 2019, 03:36:48 AM
fearless ,

something like this from goasm menuTB
Never in my life i compiled anyzhing from goasm

screenshot.zip
Title: Re: Bitmap in popup menu
Post by: fearless on April 04, 2019, 04:04:19 AM
Maybe something like the following:
https://github.com/mrfearless/libraries/blob/master/cJSON/libcjson%20x86/cjsontree/menus.asm#L249
Gets the handle for the main menu, then sets a bitmap for a specific menu item using SetMenuItemBitmaps api call.
Title: Re: Bitmap in popup menu
Post by: aw27 on April 04, 2019, 04:12:56 AM
Clamicun,
Microsoft has this page talking about resource popup menus. (https://docs.microsoft.com/en-us/windows/desktop/menurc/popup-resource)
Title: Re: Bitmap in popup menu
Post by: jj2007 on April 04, 2019, 04:16:53 AM
Any idea why this succeeds but there is no bitmap?

invoke LoadBitmap, 0, OBM_CLOSE  ; same for invoke LoadImage, hInstance, Chr$("test.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
push eax
push eax
push MF_BYPOSITION
push 1
push rv(GetMenu, hWnd_)
call SetMenuItemBitmaps ; invoke SetMenuItemBitmaps, hMenu, 1, MF_BYPOSITION, eax, eax
Title: Re: Bitmap in popup menu
Post by: aw27 on April 04, 2019, 05:46:23 AM
RESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
case WM_CREATE:
   {
      HMENU hmenuBar = GetMenu(hWnd);
      
      HBITMAP hBitmap = (HBITMAP)LoadImage((HMODULE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
      SetMenuItemBitmaps(hmenuBar, IDM_EXIT, MF_BYCOMMAND, hBitmap, hBitmap);

.....

(https://www.dropbox.com/s/1zal188wkjfk4a5/setmenubitmap.png?dl=1)
Title: Re: Bitmap in popup menu
Post by: jj2007 on April 04, 2019, 06:07:08 AM
Solved - the popups are sub-menus of GetMenu(hWnd):

push rv(LoadImage, hInstance, "test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
push eax
push MF_BYPOSITION
push 1
push rv(GetSubMenu, rv(GetMenu, hWnd), 0)
call SetMenuItemBitmaps ; invoke SetMenuItemBitmaps, hMenu, 1, MF_BYPOSITION, hBmp, hBmp


The fun part is here - bigger images. (https://docs.microsoft.com/en-us/windows/desktop/menurc/using-menus#creating-owner-drawn-menu-items)
Title: Re: Bitmap in popup menu
Post by: aw27 on April 04, 2019, 06:32:38 AM
It is a bad practice, but is becoming widespread, to ask for help posting incomplete or even misleading information about the issue. Complete information does not forcibly imply total information about the program, but meaningful information.
Title: Re: Bitmap in popup menu
Post by: clamicun on April 04, 2019, 09:03:53 AM
fearless,
thanks a lot !
Who knows.
1439 lines of code will take some time to digest.
Title: Re: Bitmap in popup menu
Post by: clamicun on April 04, 2019, 09:13:55 AM
AW,

It is a bad practice, but is becoming widespread, to ask for help ...

Yes My Lord, I think you are a bit harsh this time.

Bitmap button instad of the text "Select ..."
   POPUP "Select..."  ;   !! here the button
   BEGIN

It is not very misleading
Title: Re: Bitmap in popup menu
Post by: jj2007 on April 04, 2019, 01:15:15 PM
Quote from: LiaoMi on April 04, 2019, 01:37:35 AM
:icon14:

Kool indeed :t
To build it, comment out the wsprintf in lines 36+37 of ODMenus.inc
Title: Re: Bitmap in popup menu
Post by: aw27 on April 04, 2019, 05:55:42 PM
Quote from: clamicun on April 04, 2019, 09:13:55 AM
AW,

It is a bad practice, but is becoming widespread, to ask for help ...

Yes My Lord, I think you are a bit harsh this time.

Bitmap button instead of the text "Select ..."
   POPUP "Select..."  ;   !! here the button
   BEGIN

It is not very misleading

I was addressing JJ on this one.  :biggrin:
Of course, I can understand his difficulties with MASM but he wasted my time without a simple thank you after realizing from my example that GetMenu is indeed for the main menu, when he wanted a popup (something he should have mentioned, of course).  :badgrin:
Title: Re: Bitmap in popup menu
Post by: jj2007 on April 04, 2019, 06:53:14 PM
Quote from: AW on April 04, 2019, 05:55:42 PMhe wasted my time without a simple thank you after realizing from my example that GetMenu is indeed for the main menu, when he wanted a popup

Thank you so much, José :icon14:

Yes, I had a quick look at your example and saw that you used exactly the same code. So I realised that it must be something else. I am so grateful that you are around to give us n00bs a helping hand :t

Quote from: AW on April 04, 2019, 05:46:23 AMHMENU hmenuBar = GetMenu(hWnd);
      
      HBITMAP hBitmap = (HBITMAP)LoadImage((HMODULE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
      SetMenuItemBitmaps(hmenuBar, IDM_EXIT, MF_BYCOMMAND, hBitmap, hBitmap);
Title: Re: Bitmap in popup menu
Post by: TimoVJL on April 04, 2019, 09:17:38 PM
EDIT: OK.
Title: Re: Bitmap in popup menu
Post by: clamicun on April 04, 2019, 10:33:50 PM


I was addressing JJ on this one. 
ok.   excuse me