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
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.
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.
:icon14:
AW
??
But the syntax in the ressourcemenu is
POPUP "......." ;
BEGIN
MENUITEM "xxxxxxxxxxxxxxxx",IDM_13
"
If you use a different expression, it doesn't work
fearless ,
something like this from goasm menuTB
Never in my life i compiled anyzhing from goasm
screenshot.zip
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.
Clamicun,
Microsoft has this page talking about resource popup menus. (https://docs.microsoft.com/en-us/windows/desktop/menurc/popup-resource)
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
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)
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)
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.
fearless,
thanks a lot !
Who knows.
1439 lines of code will take some time to digest.
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
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
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:
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);
EDIT: OK.
I was addressing JJ on this one.
ok. excuse me