Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing toolbar button's label
#1
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?
#2
Function ReplaceToolbarButtonText
Code:
Copy      Help
;/
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
#3
what is this for maybe if you give us a better idea we could help..
#4
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.
#5
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.
#6
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.
#7
I would like a similar function to change button's icon also. How can I do it?
#8
Function ReplaceToolbarButtonIcon
Code:
Copy      Help
;/
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
#9
Wow!


Forum Jump:


Users browsing this thread: 1 Guest(s)