Posts: 863
Threads: 197
Joined: Apr 2005
Is possible to use something like this?
Toolbar
Toolbar2
red :mac "red" * $qm$\il_icons.bmp * 6
Posts: 12,141
Threads: 143
Joined: Dec 2002
Posts: 863
Threads: 197
Joined: Apr 2005
Is there any way to do it?
Posts: 12,141
Threads: 143
Joined: Dec 2002
example toolbar
Toolbar
tb imagelist
;/hook tb_imagelist_hook
;/imagelist "$qm$\il_qm.bmp"
three :out 3 *:4
four :out 4
five :out 5 * mouse.ico
Computer :run "$17$"
Computer :run "$17$" *:15
its hook function
Function
tb_imagelist_hook
;/tb imagelist
function% hWnd message wParam lParam
TB_Imagelist hWnd message wParam lParam
and function that does all it
Function
TB_Imagelist
;/
function% hWnd message wParam lParam
;Adds toolbar icons from an imagelist file created with QM imagelist editor.
;Call this function from toolbar hook function (before sel message).
;Toolbar syntax:
;;/hook hook_function
;;/imagelist "file.bmp"
;Label1 :command *:imageindex
;Label2 :command *:imageindex
;...
;Also can contain buttons with icons not from the imagelist.
if(message!=WM_NOTIFY) ret
NMHDR* nh=+lParam
if(nh.code=TBN_GETDISPINFOW and nh.idFrom=9999); else ret
NMTBDISPINFOW* d=+nh
str s1 s2 s3
s1.getwintext(hWnd)
s2.getmacro(s1); err ret
s1.getl(s2 d.idCommand)
if(findrx(s1 "\*:(\d+)$" 0 0 s3 1)<0) ret
;out d.idCommand
;The above code takes ~20 mcs. It runs for some normal buttons too.
;The below code runs only at startup and after text or style changes.
int htb=id(9999 hWnd)
int il=SendMessage(htb TB_GETIMAGELIST 0 0)
__ImageList il2
int i(-1) j
foreach s1 s2
,i+1
,sel i
,,case 0 continue
,,case 1
,,if(findrx(s1 "/imagelist +''(.+?)''" 0 0 s3 1)>0) il2.Load(s3)
,,continue
,,
,if(findrx(s1 "\*:(\d+)$" 0 0 s3 1)<0) continue
,int hi=ImageList_GetIcon(il2 val(s3) 0)
,if hi
,,j=ImageList_ReplaceIcon(il -1 hi); if(j<0) j=I_IMAGENONE
,,DestroyIcon hi
,else
,,j=I_IMAGENONE
,
,SendMessage(htb TB_CHANGEBITMAP i j) ;;no more TBN_GETDISPINFOW
,if(i=d.idCommand) d.iImage=j
;Easier would be to add or replace icons in imagelist on WM_INITDIALOG.
;But then we cannot restore icons when toolbar changed (text or some properties).
;For some buttons, QM extracts icons when creating toolbar.
;For others extracts on demand (sets image index = I_IMAGECALLBACK and processes TBN_GETDISPINFOW).
;If explicitly specified icon begins with :, also uses I_IMAGECALLBACK.
;
Posts: 863
Threads: 197
Joined: Apr 2005
Perfect, like always.
Thanks.
Posts: 863
Threads: 197
Joined: Apr 2005
If possible, could you add it to a new version of QM?
Posts: 12,141
Threads: 143
Joined: Dec 2002
Can you provide one or several examples where and why it could be used?
Posts: 863
Threads: 197
Joined: Apr 2005
When open QM icon dialog to assign icon to toolbar item appear
Icon files (ico, exe, dll, ocx, icl)
You can include bmp (imagelist)...