Trouble with Ampersand Character

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

wxdude
Posts: 102
Joined: Fri Mar 12, 2010 4:02 pm
Location: Canada

Trouble with Ampersand Character

Post by wxdude »

Does any one know if the Ampersand character (&) needs to be escaped when used in some circumstances?

For example with the code below, the form caption displays the & character correctly, yet the button caption does not. Seems that the & and a space is replaced with an underscore.

Image

The answer is probably simple but I cannot for the life of me figure out how to get the ampersand to display properly on the button...can anyone provide some guidance?

Thanks.

Code: Select all

Option Explicit

Dim Form, Btn
Sub OnStartup
	Script.RegisterEvent SDB, "OnPlay", "OnPlaybackStart"
End Sub

Sub OnPlaybackStart

	Set Form = SDB.UI.NewForm
	Form.Common.SetRect 100, 100, 500, 400
	Form.Caption = "Title with an & ampersand"
	 
	Set Btn = SDB.UI.NewButton(Form)
	Btn.Caption = "Close & exit"
	Btn.Common.SetRect 10, 10, 100, 20
	 
	Form.ShowModal

End Sub
Lowlander
Posts: 56607
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: Trouble with Ampersand Character

Post by Lowlander »

wxdude
Posts: 102
Joined: Fri Mar 12, 2010 4:02 pm
Location: Canada

Re: Trouble with Ampersand Character

Post by wxdude »

Thanks for that Lowlander.

I knew it had to be easy and I tried every other escape sequence I knew of....guess I'm just unsure why it has to be escaped in button text, but not the form text.
Lowlander
Posts: 56607
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: Trouble with Ampersand Character

Post by Lowlander »

In the button a single & is used to indicate the shortcut key to access the button. ie. If you have a button text like Click H&ere the e is used as shortcut key (Alt+E or if that's wrong Ctrl+E).
wxdude
Posts: 102
Joined: Fri Mar 12, 2010 4:02 pm
Location: Canada

Re: Trouble with Ampersand Character

Post by wxdude »

Now it's starting to make sense to me.....thanks again Lowlander.
Post Reply