Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Imagelist.bmp and exe file
#1
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.
#2
Macro Macro2765
Code:
Copy      Help
;/exe
__ImageList k.Load(":10 $qm$\il_qm.bmp")
out k

;BEGIN PROJECT
;flags  22
;END PROJECT
#3
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.
#4
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.
#5
Thank you once more! I have one more question. Is it possible to use Tray.AddIcon in relation to an ImageList ?
#6
Member function Tray.UseImagelist
Code:
Copy      Help
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)
#7
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.
#8
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
Code:
Copy      Help
__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
#9
Thank you !
#10
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...
#11
Try function ExeExtractFile.
#12
TY, will have a look


Forum Jump:


Users browsing this thread: 1 Guest(s)