Posts: 45
Threads: 13
Joined: Jul 2009
Hi everyone
I have come across another problem
When my dialog starts, it has a simple icon in it
How can i make it where you can change the icon at will by pressing a button
Or maybe even having it shuffle through a certain few icons in a folder in "My QM"
Sorry if im unclear but this is the best i can describe it
Change static icon after dialog has already been open, like from a #1 icon, press button, says #2 now
Thanks you very much
Posts: 12,072
Threads: 140
Joined: Dec 2002
Function SetStaticIcon
;/
function hwndControl [$iconFile] [flags] ;;flags: 1 large
;Sets/changes/deletes icon of a static icon control.
;hwndControl - control handle.
;iconFile - icon file. If "" or not used, removes icon.
;;;;To avoid memory leak, always call this function on WM_DESTROY with empty iconFile.
;Initially the control must not have icon.
int hi
if(!empty(iconFile)) hi=GetFileIcon(iconFile 0 flags)
hi=SendMessage(hwndControl STM_SETICON hi 0)
if(hi) DestroyIcon hi
Function Dialog91
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str si3
if(!ShowDialog("Dialog91" &Dialog91 &controls)) ret
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54000003 0x0 6 8 16 16 ""
;4 Button 0x54032000 0x0 2 42 48 14 "Button"
;5 Button 0x54032000 0x0 54 42 48 14 "Button"
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "*" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,SetStaticIcon id(3 hDlg) "$qm$\copy.ico"
,
,case WM_DESTROY
,SetStaticIcon id(3 hDlg)
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4
,SetStaticIcon id(3 hDlg) "$qm$\paste.ico"
,
,case 5
,SetStaticIcon id(3 hDlg) "shell32.dll,3" 1
,
,case IDOK
,case IDCANCEL
ret 1
Posts: 12,072
Threads: 140
Joined: Dec 2002
another example
Function Dialog63
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str si3
if(!ShowDialog("Dialog63" &Dialog63 &controls)) ret
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54000103 0x0 0 0 16 16 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030100 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,;when dialog starts, load 2 icons
,ARRAY(__Hicon)-- t_ai; int-- t_aii ;;array of icons and current icon index
,t_ai.create(2)
,t_ai[0]=GetFileIcon("shell32.dll" 8 1)
,t_ai[1]=GetFileIcon("shell32.dll" 9 1)
,SendMessage id(3 hDlg) STM_SETICON t_ai[0] 0
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_SETCURSOR
,;detect mouse over the static icon control (it must have SS_NOTIFY style)
,if(GetDlgCtrlID(wParam)=3)
,,if(t_aii=0)
,,,t_aii=1
,,,SendMessage id(3 hDlg) STM_SETICON t_ai[1] 0
,,,SetTimer hDlg 100 50 0
,case WM_TIMER
,;detect when mouse leaves the control
,sel wParam
,,case 100
,,if(child(mouse)!=id(3 hDlg))
,,,KillTimer hDlg wParam
,,,t_aii=0
,,,SendMessage id(3 hDlg) STM_SETICON t_ai[0] 0
,,,
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Posts: 45
Threads: 13
Joined: Jul 2009
Thank you very much
The first example was exactly what i was looking for
|