News:

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

Main Menu

Replace menu item to sub item

Started by ragdog, January 15, 2019, 10:01:44 PM

Previous topic - Next topic

ragdog

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?



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

here is my code:


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,

fearless


HSE

Last one, it's not?:mov mii.fMask,MIIM_SUBMENU
Equations in Assembly: SmplMath

ragdog

Hello all
I have test your solution  MFT_OWNERDRAW without good result .


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


.if  (uMsg==AIM_MENUUPDATE)
invoke UpdateMenu,hWnd
                mov eax,TRUE
                ret


Is this a problem with mii.dwTypeData?

ragdog

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.


.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