Author Topic: Replace menu item to sub item  (Read 448 times)

ragdog

  • Member
  • ****
  • Posts: 610
Replace menu item to sub item
« 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?



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,
« Last Edit: January 16, 2019, 05:03:43 AM by ragdog »

fearless

  • Member
  • ***
  • Posts: 435
    • LetTheLightIn
Re: Replace menu item to sub item
« Reply #1 on: January 16, 2019, 12:08:18 AM »
Maybe the mask needs MFT_OWNERDRAW

fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

HSE

  • Member
  • *****
  • Posts: 1030
  • <AMD>< 7-32>
Re: Replace menu item to sub item
« Reply #2 on: January 16, 2019, 12:23:43 AM »
Last one, it's not?:
Code: [Select]
mov mii.fMask,MIIM_SUBMENU

ragdog

  • Member
  • ****
  • Posts: 610
Re: Replace menu item to sub item
« Reply #3 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?

ragdog

  • Member
  • ****
  • Posts: 610
Re: Replace menu item to sub item
« Reply #4 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