Posts: 1,006
Threads: 330
Joined: Mar 2007
Hi All,
I hope I am not missing the answer to this already somewhere in the forum. Anyway, I use a lot of Toolbars and sometimes they change a status - e.g. de-activating a set of triggers (i.e. on/off toggle).
The functionality is easy
;;;toggles on/off folders with keyboard triggers
dis "Sample Macros Folder 1" 1
dis "Sample Macros Folder 2" 1
But I would like some way to have a visual indication of the state - i.e. a different icon or a button that looks "depressed" or to change the text and color of the Toolbar Item.
I geuss I may have to master dialogs to do this - - my major QM weakness!
Perhaps there is a sample floating around that I can reverse engineer!
Thanks,
Stuart
Posts: 576
Threads: 97
Joined: Aug 2007
Not sure if i know exactly what you want but ill give it a try, button on a dialog tht sticks down and changes text once its down?
try this
Function: Dialog2
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 135 66 "Test"
;1 Button 0x54030001 0x4 18 44 48 14 "OK"
;2 Button 0x54030000 0x4 76 44 48 14 "Cancel"
;3 Button 0x54013003 0x0 46 14 48 14 "START"
;END DIALOG
;DIALOG EDITOR: "" 0x202000B "" ""
str controls = "3"
str c3STA
if(!ShowDialog("Dialog2" &Dialog2 &controls)) ret
ret
;messages
if(message=WM_INITDIALOG) DT_Init(hDlg lParam)
;int param=DT_GetParam(hDlg)
sel message
,case WM_INITDIALOG
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,,if(but(lParam))
,,,_s="STOP"
,,else
,,,_s="START"
,,_s.setwintext(lParam)
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
Give it a trigger i already have the code pasted in there to show the dialog hope this works
Posts: 12,074
Threads: 141
Joined: Dec 2002
See also:
change macro? (toolbar check button that controls a macro)
It shows how to check a toolbar button.
----
Also found this:
Function Toolbar8Proc
;/Toolbar8
function# hWnd message wParam lParam
def TB_GETIMAGELIST (WM_USER + 49)
def TB_CHANGEBITMAP (WM_USER + 43)
dll user32 #UpdateWindow hWnd
type TBBLINK htb iic is
int i hil hic button icon
TBBLINK* p
button=2 ;;toolbar button index. This is line index, including comments.
icon=0 ;;real button index (not including comments)
sel message
,case WM_CREATE
,;PostMessage hWnd WM_APP 1 0
,SetProp hWnd "p" p._new
,case WM_DESTROY
,p=+GetProp(hWnd "p"); p._delete
,
,case WM_APP
,p=+GetProp(hWnd "p")
,if(!p.htb)
,,p.htb=id(9999 hWnd)
,,hil=SendMessage(p.htb TB_GETIMAGELIST 0 0)
,,hic=GetIcon("$qm$\mouse.ico")
,,p.iic=ImageList_ReplaceIcon(hil -1 hic)
,,DestroyIcon hic
,if(wParam) SetTimer hWnd 0 300 0; p.is=0; goto g1
,else KillTimer hWnd 0; p.is=1; goto g1
,
,case WM_TIMER
,;g1
,p=+GetProp(hWnd "p")
,p.is^1
,SendMessage p.htb TB_CHANGEBITMAP button iif(p.is p.iic icon)
,UpdateWindow p.htb
,
,
Toolbar Toolbar8
;/hook Toolbar8Proc
-
Macro15 :mac "Macro15"
Macro Macro15
int h=win("TOOLBAR8" "QM_Toolbar")
PostMessage h WM_APP 1 0
5
PostMessage h WM_APP 0 0
It shows how to change toolbar button icon at run time. Create function, toolbar and macro. Run toolbar. Click the button or run the macro to see how it works.
----
And this:
Can a menu/toolbar item's text-title be a string variable?
Function that changes button text.
|