The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on June 17, 2008, 09:11:48 PM

Title: icon menu
Post by: ragdog on June 17, 2008, 09:11:48 PM
hi

i have a another probelm with add a program icon to a  menu
have your a idea why this not work?

source is added

thanks in forward
ragdog



[attachment deleted by admin]
Title: Re: icon menu
Post by: jj2007 on June 17, 2008, 09:38:21 PM
Twice the same identifier?

            invoke     AppendMenu,hSMenu3,MF_BITMAP + MF_STRING,1000,offset szItem
            invoke     AppendMenu,hSMenu3,MF_BITMAP + MF_STRING,1000,offset szItem1

Note it would be easier if you were more specific, i.e. does it assemble, if not: error messages, if yes: what's the problem then, and especially: where in your dozen files do you believe should we find the problem.
Title: Re: icon menu
Post by: ragdog on June 17, 2008, 10:02:26 PM
the problem is this draw not the icon in menu

thanks for your reply
Title: Re: icon menu
Post by: ragdog on June 18, 2008, 11:04:54 AM
hi

i have add xxcontrols lib
this draw not my text and not the correct icon
have your a idea?


invoke     GetMenu,hWnd
              mov     hMenu,eax
             
          invoke      ImageList_Create, 16, 16, ILC_COLOR or ILC_MASK, 18,0
              mov     hImageList, eax

              mov     mii.cbSize, sizeof mii
              mov     mii.fMask, MIIM_DATA or MIIM_ID or MIIM_STATE or MIIM_SUBMENU or MIIM_TYPE or MIIM_CHECKMARKS
           INVOKE     CreatePopupMenu
              mov     hSMenu3, eax
              mov     mii.fType, MFT_STRING
             push     hSMenu3
              pop     mii.hSubMenu
              mov     eax, offset szNewMenu1
              mov     mii.dwTypeData, eax
           INVOKE     InsertMenuItem, hMenu, 8, TRUE, addr mii  ; Adds new menu
           INVOKE     DrawMenuBar, hWnd

           invoke     AppendMenu,hSMenu3,MF_STRING,1000,offset szItem
         
       ;get the icon of the item
           invoke     SHGetFileInfo, offset szProg, NULL, addr sfi, sizeof sfi,\
                  SHGFI_ICON or SHGFI_ICON+SHGFI_ICONLOCATION +SHGFI_USEFILEATTRIBUTES

    ;insert the icon into the image list
        invoke     ImageList_AddIcon, hImageList, sfi.hIcon

        invoke     ImageList_GetIcon, hImageList, 0, ILD_NORMAL

           invoke     SetMenuItemIcon, hSMenu3,1000,eax
           INVOKE     DrawMenuBar, hWnd


greets
ragdog

[attachment deleted by admin]
Title: Re: icon menu
Post by: jj2007 on June 18, 2008, 12:14:57 PM
invoke AppendMenu, hmenu, MF_STRING, id, addr MyString
invoke SetMenuItemBitmaps, hmenu, ... MF_BYCOMMAND or MF_BITMAP, Bitmaphandle, 0

BOOL SetMenuItemBitmaps(

    HMENU  hmenu,   // handle of menu
    UINT  uItem,   // menu item to receive new bitmaps
    UINT  fuFlags,   // menu item flags
    HBITMAP  hbmUnchecked,   // handle of unchecked bitmap
    HBITMAP  hbmChecked   // handle of checked bitmap
Title: Re: icon menu
Post by: ragdog on June 18, 2008, 01:49:58 PM
hmm

i have add this

this does not work       :'(

invoke     ImageList_GetIcon, hImageList,1, ILD_NORMAL
invoke     SetMenuItemBitmaps, hSMenu3,1000,MF_BYCOMMAND or MF_BITMAP,eax,eax
Title: Re: icon menu
Post by: jj2007 on June 18, 2008, 03:06:23 PM
invoke     ImageList_GetIcon, hImageList,1, ILD_NORMAL

What do you get in eax?
Title: Re: icon menu
Post by: ragdog on June 18, 2008, 04:05:55 PM
i get the icon from imagelist


SetMenuItemBitmaps, hSMenu3,1000,MF_BYCOMMAND or MF_BITMAP,hBitmapUnchecked,hBitmapChecked

Title: Re: icon menu
Post by: jj2007 on June 18, 2008, 05:24:49 PM
So it works now?
Title: Re: icon menu
Post by: ragdog on June 18, 2008, 07:17:41 PM
no it works not

I do not know further :'(

Title: Re: icon menu
Post by: jj2007 on June 18, 2008, 07:58:23 PM
Quote from: ragdog on June 18, 2008, 04:05:55 PM
i get the icon from imagelist

I repeat my question: What do you get in eax? A handle, or zero? If "the icon" is zero for some reason, you will hardly succeed. Hint: run your code with Olly.
Title: Re: icon menu
Post by: ragdog on June 18, 2008, 09:20:47 PM
sorry for my understanding

get in eax a handle the stored icon
Title: Re: icon menu
Post by: ragdog on June 21, 2008, 11:56:35 AM
hi @all

I comming not further with my Problem  :'(

With add Icons to menuitem can your Help me please!!

I added xxControls library and convert the Icon to Bmp
This Draw not The icon“s in the menu Why??



invoke     GetMenu,hWnd
  mov     hMenu,eax
             
INVOKE    GetSubMenu,eax,0
    mov    hSMenu3, eax
invoke    ImageList_Create, 16, 16, ILC_COLOR16 or ILC_MASK, 19,0
    mov    hImageList, eax

invoke     SHGetFileInfo, addr szProg, NULL, addr sfi, sizeof sfi,\
SHGFI_ICON or SHGFI_ICON+SHGFI_ICONLOCATION+SHGFI_USEFILEATTRIBUTES

invoke    IconToBmp ,sfi.hIcon,16
invoke    ImageList_AddMasked, hImageList, eax, iBmpMaskColor
invoke    DestroyIcon, sfi.hIcon

         
invoke    ImageList_GetIcon, hImageList,0, ILD_NORMAL
invoke    SetMenuItemIcon, hSMenu3,2005,eax

invoke    RedrawMenu, hWnd, hMenu,0




[attachment deleted by admin]
Title: Re: icon menu
Post by: jj2007 on June 21, 2008, 06:17:20 PM
Quote from: ragdog on June 18, 2008, 09:20:47 PM
get in eax a handle the stored icon

You are supposed to get a handle. However, I don't see any debugging code in your listing. How do you verify that eax is not zero?
Title: Re: icon menu
Post by: ragdog on June 21, 2008, 08:19:10 PM
hi

eax if not zero i use this function for my drive list

i have add a ico button for test this function you can see my screenshot

(http://img357.imageshack.us/img357/3651/unbenanntko3.jpg)


greets
ragdog
Title: Re: icon menu
Post by: jj2007 on June 21, 2008, 11:36:51 PM
I have tried to understand what you are doing, but it seems you are using a fairly exotic library. 38 Google hits for SetMenuItemIcon is not a good start ;-)

There is a working short example in C:\masm32\examples\exampl06\ecmenu\ecmenu.asm
Title: Re: icon menu
Post by: ragdog on June 22, 2008, 12:04:25 AM
thanks

i use the xxcontrols libraray

this example use only bitmaps i will use get the icons von anything app and add to my menu
this SetMenuItemBitmaps works not for me



SetMenuItemIcon proc h_Menu:HMENU, ItemID:DWORD, hIcon:HICON

   LOCAL mii      :MENUITEMINFOM
   
    mov mii.cbSize, sizeof (MENUITEMINFOM)
    mov mii.fMask, MIIM_DATA   
    m2m mii.dwItemData, hIcon
    invoke SetMenuItemInfo, h_Menu, ItemID, FALSE, ADDR mii

    ret
SetMenuItemIcon endp


i upload this xxcontrols libraray source

greets
ragdog

[attachment deleted by admin]
Title: Re: icon menu
Post by: ragdog on June 23, 2008, 07:07:04 PM
hi guys

In my compiled exe works this not in my Plugin (.dll)
This draw not the MenuItem string why??

(http://img75.imageshack.us/img75/8976/unbenanntin0.jpg)

I use a Callback in my Dll for WM_COMMAND and WM_DRAWITEM ...



      push offset CallBackProc
      push GWL_WNDPROC
      push hWnd
        call SetWindowLong
       
      push eax
      push GWL_USERDATA
      push hWnd
        call SetWindowLong

CallBackProc proc hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
LOCAL EditOldProc :DWORD
LOCAL hString [256]:DWORD
  invoke GetWindowLong,hWnd,GWL_USERDATA
  mov EditOldProc,eax
     
.if uMsg==WM_MEASUREITEM
  Invoke MeasureItem,lParam
  MOV EAX,TRUE
  RET
.ElseIf uMsg==WM_DRAWITEM
  Invoke DrawItem,lParam
  MOV EAX,TRUE
  RET
.elseif uMsg==WM_COMMAND
          mov     eax, wParam
     
         .if eax > 9000 && eax < 11000
                mov ebx,eax
             invoke GetMenuString,hMenu,ebx,addr hString,512,MF_BYCOMMAND
             invoke GetItemPath,addr hString
         .endif

     .endif
invoke CallWindowProc,EditOldProc,hWnd,uMsg,wParam,lParam
ret
CallBackProc endp





if I have add this GetMenuString under  MeasureItem Proc and DrawItem Proc then works this

MeasureItem Proc :
original:


MOV EDI, lParam
ASSUME EDI:PTR MEASUREITEMSTRUCT

Invoke lstrlen,[EDI].itemData
MOV ECX,EAX
Invoke GetTextExtentPoint32,hDC,[EDI].itemData,ECX,ADDR TextSize
MOV EAX,TextSize.x
MOV ECX,TextSize.y

modified:

MOV EDI, lParam
ASSUME EDI:PTR MEASUREITEMSTRUCT

    invoke GetMenuString,hMenu,[EDI].itemID,addr hString,512,MF_BYCOMMAND
Invoke lstrlen,addr hString
MOV ECX,EAX
Invoke GetTextExtentPoint32,hDC,addr hString,ECX,ADDR TextSize
MOV EAX,TextSize.x
MOV ECX,TextSize.y

DrawItem Proc:
original:


Invoke DrawText, [EDI].hdc,[EDI].itemData ,-1, ADDR [EDI].rcItem, DT_SINGLELINE or DT_NOCLIP or DT_VCENTER or DT_EXPANDTABS

modified:

invoke GetMenuString,hMenu,[EDI].itemID,addr hString,512,MF_BYCOMMAND
Invoke DrawText, [EDI].hdc,addr hString ,-1, ADDR [EDI].rcItem, DT_SINGLELINE or DT_NOCLIP or DT_VCENTER or DT_EXPANDTABS


Why works not [EDI].itemData for Itemstring?
Have your a anything idea?

Thanks in forward!