The MASM Forum

General => The Campus => Topic started by: ragdog on January 15, 2019, 10:01:44 PM

Title: Replace menu item to sub item
Post by: ragdog on January 15, 2019, 10:01:44 PM
Hello

I know this is a wrong place for writing a Radasm Addin

I try replace a item to a subitem @runtime all works fine but Radasm usw a Ownerdraw menu why draw my new sub menu incorrect?

(https://i.ibb.co/0cWg4DM/Unbenannt.png) (https://imgbb.com/)

left = my addin to replace the item
right=a original radasm menu item

here is my code:

Code: [Select]
UpdateMenu proc hWin:DWORD
LOCAL mii:MENUITEMINFO
LOCAL buffer[256]:BYTE

mov mii.cbSize,sizeof MENUITEMINFO
mov mii.fMask,MIIM_DATA or MIIM_ID or MIIM_SUBMENU or MIIM_TYPE
lea eax,buffer
mov mii.dwTypeData,eax
mov mii.cch,sizeof buffer
mov edx,lpHandles

invoke GetMenuItemInfo,[edx].ADDINHANDLES.hMenu,IDM_PROJECT_OPTION,FALSE,addr mii
;-- Create submenu
invoke CreatePopupMenu
mov ebx,eax
mov mii.hSubMenu,eax
mov edx,lpHandles
invoke SetMenuItemInfo,[edx].ADDINHANDLES.hMenu,IDM_PROJECT_OPTION,FALSE,addr mii
;-- set the Old Item to the submenu

mov mii.fMask,MIIM_DATA or MIIM_ID or MIIM_TYPE
invoke InsertMenuItem,ebx,IDM_PROJECT_OPTION,0,addr mii

Have i forget to get any fMask or what ever?

Greets,
Title: Re: Replace menu item to sub item
Post by: fearless on January 16, 2019, 12:08:18 AM
Maybe the mask needs MFT_OWNERDRAW

Title: Re: Replace menu item to sub item
Post by: HSE on January 16, 2019, 12:23:43 AM
Last one, it's not?:
Code: [Select]
mov mii.fMask,MIIM_SUBMENU
Title: Re: Replace menu item to sub item
Post by: ragdog on January 16, 2019, 05:22:11 AM
Hello all
I have test your solution  MFT_OWNERDRAW without good result .

Code: [Select]
UpdateMenu proc hWin:DWORD
LOCAL mii:MENUITEMINFO
LOCAL buffer[256]:BYTE

mov mii.cbSize,sizeof MENUITEMINFO
mov mii.fMask,MIIM_DATA or MIIM_ID or MIIM_SUBMENU or MIIM_TYPE
lea eax,buffer
mov mii.dwTypeData,eax
mov mii.cch,sizeof buffer

mov edx,lpHandles

invoke GetMenuItemInfo,[edx].ADDINHANDLES.hMenu,IDM_PROJECT_OPTION,FALSE,addr mii
;-- Create submenu
invoke CreatePopupMenu
mov ebx,eax
mov mii.hSubMenu,eax
mov edx,lpHandles
invoke SetMenuItemInfo,[edx].ADDINHANDLES.hMenu,IDM_PROJECT_OPTION,FALSE,addr mii
;-- set the Old Item to the submenu

mov mii.fMask,MIIM_DATA or MIIM_ID  or MIIM_TYPE
mov mii.fType, MFT_OWNERDRAW

invoke InsertMenuItem,ebx,IDM_PROJECT_OPTION,0,addr mii

;Add new entry to the submenu
mov mii.cbSize,sizeof MENUITEMINFO
mov mii.fMask,MIIM_ID or MIIM_TYPE
mov mii.fType,MFT_STRING
mov eax,IDAddIn_NEXTOPTION
mov mii.wID,eax
mov mii.dwTypeData,chr$ ("Next Option")
invoke InsertMenuItem,ebx,IDM_PROJECT_OPTION,FALSE,addr mii
ret
UpdateMenu endp

Code: [Select]
.if  (uMsg==AIM_MENUUPDATE)
invoke UpdateMenu,hWnd
                mov eax,TRUE
                ret

Is this a problem with mii.dwTypeData?
Title: Re: Replace menu item to sub item
Post by: ragdog on January 18, 2019, 12:06:01 AM
Hello Fealess and Hse

I found the problem The Radasm Menu is OwnerDraw and need a flag from RAMNUITEM structur and this is stored in mii.dwTypeData.


Code: [Select]
.if [esi].RAMNUITEM.ntype==1
And is hard work to fill this structur , and other etc ... to use in AIM_MENUPDATE .

a simply solution is to put my code in the InstallAddin procedur.

Thank you