Posts: 69
Threads: 42
Joined: Jun 2006
I need a toolbar.
The first button's label should be customizable by pressing the following buttons.
So, for example, when I press the second button, the text appearing on the first button should become "1"; when I press the second button, the text appearing on the first button should become "2", and so on. The text changed on the first button should remain permanently, according to the last change, even after restarting Quick Macros.
Is it possibile?
Posts: 12,055
Threads: 140
Joined: Dec 2002
Function ReplaceToolbarButtonText
;/
function# lineindex ~text [$toolbarname]
;Replaces toolbar button text.
;The replacement is permanent, ie it changes toolbar text.
;Can be called while the toolbar is running or not.
;Returns 1 if successful, 0 if not.
;lineindex - 0-based line index in toolbar text.
;text - new text of the button.
;toolbarname - toolbar name. Can be omitted or "" if called from the toolbar itself.
;EXAMPLE toolbar
;0 :out 0
;1 :ReplaceToolbarButtonText 0 "1"
;2 :ReplaceToolbarButtonText 0 "2"
int iid
if(len(toolbarname)) iid=qmitem(toolbarname)
else iid=getopt(itemid 3)
if(!iid) ret
str s.getmacro(iid)
int i=findl(s lineindex); if(i<0) ret
int j=find(s " :" i); if(i<0) ret
s.replace(text i j-i)
s.setmacro(iid); err ret
ret 1
Posts: 331
Threads: 60
Joined: May 2006
what is this for maybe if you give us a better idea we could help..
Posts: 69
Threads: 42
Joined: Jun 2006
John Wrote:what is this for maybe if you give us a better idea we could help..
I need it because some media players do not have the "resume" function, so I need to memorize manually the last point where I was listening an audio CD, in the simplest and fastest way. At this moment, this kind of toolbar seems to me the best way.
Posts: 331
Threads: 60
Joined: May 2006
I guess there are many ways you could do this but first you will need to get the time of the cd from the media player with getwintext or acc and a.Name/// then you could store it in the registry with rget and rset Functions.
If you have a start any code you could post maybe that would be a help, and also the media player you are working with would help also.
Posts: 69
Threads: 42
Joined: Jun 2006
Thanks to Gintaras for the code: it works fine.
For John: the way that you suggest is too complex for me or, anyway, it would take to me too much time. The player I'm trying is CoolCD Studio. Anyway, thanks for the suggestion.
Posts: 69
Threads: 42
Joined: Jun 2006
I would like a similar function to change button's icon also. How can I do it?
Posts: 12,055
Threads: 140
Joined: Dec 2002
Function
ReplaceToolbarButtonIcon
;/
function# lineindex $icon [$toolbarname]
;Replaces toolbar button text.
;The replacement is permanent, ie it changes toolbar text.
;Can be called while the toolbar is running or not.
;Returns 1 if successful, 0 if not.
;lineindex - 0-based line index in toolbar text.
;icon - new icon of the button.
;toolbarname - toolbar name. Can be omitted or "" if called from the toolbar itself.
;REMARKS
;The toolbar line must not have " *" before the " *" that is used for icon.
int iid
if(empty(toolbarname)) iid=getopt(itemid 3)
else iid=qmitem(toolbarname)
if(!iid) ret
str s.getmacro(iid)
int i=findl(s lineindex); if(i<0) ret
REPLACERX r.ifrom=i; r.repl=F"$1{icon}"
if(s.replacerx("(.+? \* *)[^[]]*" r 4)<0)
,r.repl=F" * {icon}[]"
,s.replacerx("([]|\z)" r 4)
s.setmacro(iid); err ret
ret 1
Posts: 69
Threads: 42
Joined: Jun 2006