News:

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

Main Menu

Bitmap in popup menu

Started by clamicun, April 03, 2019, 04:41:51 AM

Previous topic - Next topic

clamicun

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

aw27


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.

fearless

Something like this dropdown perhaps?

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.

LiaoMi


clamicun

AW
??
But the syntax in the ressourcemenu is

POPUP "......."  ;   
   BEGIN
      MENUITEM "xxxxxxxxxxxxxxxx",IDM_13
      "
If you use a different expression, it doesn't work

clamicun

fearless ,

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

screenshot.zip

fearless

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.


jj2007

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

aw27

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);

.....


jj2007

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.

aw27

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.

clamicun

fearless,
thanks a lot !
Who knows.
1439 lines of code will take some time to digest.

clamicun

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

jj2007

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