Posts: 1,058
Threads: 367
Joined: Oct 2007
I am referring to
Floating toolbar difficulties (toolbars in exe)
I understand that a linked exe file does not contain the information included in an imagelist (.bmp) file. In other words the imagelist file should be independently supplied to the non-QM end user together with the .exe file. If this is the case, I wonder whether there exist a way to link the imagelist together with exe. Is it likely that the "resources" option could help to this end? If this is the case could you please give an example?
Many thanks in advance.
Posts: 12,097
Threads: 142
Joined: Dec 2002
Macro
Macro2765
;/exe
__ImageList k.Load(":10 $qm$\il_qm.bmp")
out k
;BEGIN PROJECT
;flags 22
;END PROJECT
Posts: 1,058
Threads: 367
Joined: Oct 2007
Thank you, excellent advice. However, excuse me if I would extend a bit my question : I understand that once an imagelist is loaded, for example at the beginning of an exe function, the imagelist handle should be used later in the function. In such cases, for example as the imagelist - string argument, as that in function InitToolbar in dlg_attached (topic 4679), how one can manage? Furthermore, I would appreciate it if you could advice on the way one could handle an individual icon in the imagelist, for example in a statement of the type GetFileIcon.
Posts: 12,097
Threads: 142
Joined: Dec 2002
Pass the string to InitToolbar. It uses __Imagelist.Load, as you can see.
Icon handles can be created from imagelist images with Windows API function ImageList_GetIcon, look in MSDN library.
Posts: 1,058
Threads: 367
Joined: Oct 2007
Thank you once more! I have one more question. Is it possible to use Tray.AddIcon in relation to an ImageList ?
Posts: 12,097
Threads: 142
Joined: Dec 2002
Member function
Tray.UseImagelist
function hImagelist firstImage lastImage
;Allows to use imagelist images for tray icons.
;hImagelist - imagelist handle. For example an __ImageList variable (you can call its function Load to load a bitmap file created with the QM imagelist editor).
;firstImage - 0-based index of the first image to get from the imagelist.
;lastImage - 0-based index of the last image to get from the imagelist.
;REMARKS
;Adds one or more icons from an imagelist to an internal array.
;Then you can show that icons with Modify.
;At first need to call AddIcon, even if the icon will not be used. Its index with Modify is 1, therefore imagelist icons are 2, 3 and so on.
;This function copies the images, therefore the imagelist can be destroyed immediately after calling it.
;EXAMPLE
;Tray t.AddIcon
;__ImageList k.Load(":10 $qm$\il_qm.bmp")
;t.UseImagelist(k 0 3)
;int i
;for i 0 4
,;t.Modify(2+i)
,;1
int i
for i firstImage lastImage+1
,__TRAYIC& r=m_a[]
,r.hicon=ImageList_GetIcon(hImagelist i 0)
Posts: 1,058
Threads: 367
Joined: Oct 2007
I am sorry, I have one - most probably - final question on this issue. In a ShowDialog call, $icon is the title bar icon. Is it possible - and if yes how - to use as title bar icon one of the icons in an imagelist? Best regards.
Posts: 12,097
Threads: 142
Joined: Dec 2002
Not recommended, because a window should have 2 icons - 16x16 and 32x32. Ico files usually contain icons of these two sizes. But the bigger icon is not necessary if it is never displayed (eg in Alt+Tab window) or you don't care that it then looks not good because is auto-stretched.
Cannot set dialog icon through the icon parameter. Do it in dialog procedure.
Function
Dialog197
__ImageList k16.Load(":10 $qm$\il_qm.bmp")
__Hicon hi16=ImageList_GetIcon(k16 4 0)
;__ImageList k32.Load(":10 $qm$\il_qm_32x32.bmp")
;__Hicon hi32=ImageList_GetIcon(k32 4 0)
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040304 "*" "" "" ""
if(!ShowDialog(dd &sub.DlgProc 0)) ret
#sub DlgProc v
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,SendMessage hDlg WM_SETICON 0 hi16
,;SendMessage hDlg WM_SETICON 1 hi32
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Posts: 1,058
Threads: 367
Joined: Oct 2007
Posts: 795
Threads: 136
Joined: Feb 2009
Reviving the thread, is it possible to extend this behavior for an stand alone exe file, and use it by code in the QM exe?
Would be great to have 7zip command line exe version in a QM exe without the need to carry the 7zip.exe on the USB key...
Posts: 12,097
Threads: 142
Joined: Dec 2002
Try function ExeExtractFile.
Posts: 795
Threads: 136
Joined: Feb 2009