The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on July 13, 2007, 06:40:43 PM

Title: insert drives on toolbar problem
Post by: ragdog on July 13, 2007, 06:40:43 PM
hi guys

i have a problem to draw drives in my toolbar my algo draw only one icon in the toolbar

can your help me

dotoolbar proc drive:dword,id:dword
LOCAL  tbb      :TBBUTTON
LOCAL  sfi:SHFILEINFO
LOCAL  hImageList :DWORD

      invoke SHGetFileInfo,drive, 0, addr sfi, sizeof SHFILEINFO,\
                       SHGFI_SYSICONINDEX or SHGFI_ICON or SHGFI_SMALLICON

      invoke ImageList_Create, 32, 32, ILC_COLOR32 or ILC_MASK, 24, 48
         mov hImageList, eax
      invoke ImageList_AddIcon, hImageList,  sfi.hIcon
      invoke SendMessage,hToolbar,TB_BUTTONSTRUCTSIZE,sizeof TBBUTTON,0
      invoke SendMessage, hToolbar, TB_SETIMAGELIST, 0, hImageList
   
         mov edi,id
      TBButt hToolbar, 0, edi, offset AppName

      invoke RtlZeroMemory,addr hImageList,sizeof hImageList
      invoke RtlZeroMemory,addr sfi,sizeof SHFILEINFO
         mov eax,hToolbar
          ret
dotoolbar endp


example as jpg is attached in the zip file


greets in forward
ragdog

[attachment deleted by admin]
Title: Re: insert drives on toolbar problem
Post by: u on July 13, 2007, 06:57:47 PM
ImageList_Create and TB_SETIMAGELIST ... you should call them only once, not every time you add a drive.
Title: Re: insert drives on toolbar problem
Post by: ragdog on July 13, 2007, 07:12:00 PM
thx for the info

i have change to:

.if uMsg==WM_INITDIALOG

            invoke GetDlgItem,hWnd,1001
               mov hToolbar,eax
            invoke ImageList_Create, 32, 32, ILC_COLOR32 or ILC_MASK, 24, 48
               mov hImageList, eax
            invoke SendMessage,hToolbar,TB_BUTTONSTRUCTSIZE,sizeof TBBUTTON,0

            invoke SendMessage, hToolbar, TB_SETIMAGELIST, 0, hImageList
         
            invoke dotoolbar,driveicon1,1
            invoke dotoolbar,driveicon2,2

....
......

dotoolbar proc drive:dword,id:dword
LOCAL  tbb      :TBBUTTON
LOCAL  sfi:SHFILEINFO
LOCAL  hImageList :DWORD

      invoke SHGetFileInfo,drive, 0, addr sfi, sizeof SHFILEINFO,\
                       SHGFI_SYSICONINDEX or SHGFI_ICON or SHGFI_SMALLICON

   
         mov edi,id
      TBButt hToolbar, 0, edi, offset AppName

      invoke RtlZeroMemory,addr hImageList,sizeof hImageList
      invoke RtlZeroMemory,addr sfi,sizeof SHFILEINFO
         mov eax,hToolbar
          ret
dotoolbar endp



this display  2* the first icon driveicon1 not driveicon2   :'(

greets
ragdog
Title: Re: insert drives on toolbar problem
Post by: ragdog on July 13, 2007, 08:36:45 PM
the problem solved

thanks