roboz Posted July 13, 2005 Share Posted July 13, 2005 (edited) Hi, I've got a problem with displaying the "&" sign properly. Here's a short example: $album = "Lock, Stock & Two Smoking Barrels" GuiCreate("test", 600, 210) $abc = GUICtrlCreateLabel ($album, 20, 80, 400, 80) GUISetState() MsgBox(4096,'debug:' , '$album:' & $album) While 1 Sleep (100) WEnd The label created with GUICtrlCreateLabel shows: Lock, Stock_Two Smoking Barrels The message window shows the correct: Lock, Stock & Two Smoking Barrels When I replace "&" with "&&" in the string it shows one "&" in the label. Can aynone please explain why this happens? Using v3.1.1 by the way Thanks Edited July 13, 2005 by roboz Link to comment Share on other sites More sharing options...
GaryFrost Posted July 13, 2005 Share Posted July 13, 2005 for GUI it would be to identify a shortcut key for example an OK button Select Alt+o and see what happens #include <GuiConstants.au3> $album = "Lock, Stock && Two Smoking Barrels" GuiCreate("test", 600, 210) $abc = GUICtrlCreateLabel ($album, 20, 80, 400, 80) $Button = GUICtrlCreateButton ("&OK", 10, 30, 50) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button MsgBox(4096,'debug:' , '$album:' & $album) EndSelect WEnd SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
sandyd Posted July 13, 2005 Share Posted July 13, 2005 Windows standard for controls is to use the & to indicate an accelerator key.e.g. If you give a button the text of Can&cel the button will show Canc el.This means that if you press ALT+c the button is clicked.Labels can be attached to Edits to allow the same thing to happen. If you press the ALT key and the accelerator key, the focus is moved to the Edit relating to the Label.The message box is just showing the string literaly.Hope that helps. ----[ SandyD ]--- Link to comment Share on other sites More sharing options...
roboz Posted July 13, 2005 Author Share Posted July 13, 2005 Thanks for the quick replies. So is there an easy way to show the string in the label literally? Link to comment Share on other sites More sharing options...
LxP Posted July 13, 2005 Share Posted July 13, 2005 (edited) The best way would be to StringReplace() any '&' occurences in your data with '&&' while displaying on the GUI:$album = "Lock, Stock & Two Smoking Barrels" guiCreate("test", 600, 210) $abc = guiCtrlCreateLabel(stringReplace($album, "&", "&&"), 20, 80, 400, 80) guiSetState() Edited July 13, 2005 by LxP Link to comment Share on other sites More sharing options...
roboz Posted July 13, 2005 Author Share Posted July 13, 2005 I'll do that. Thanks Link to comment Share on other sites More sharing options...
LxP Posted July 13, 2005 Share Posted July 13, 2005 Probably an even better solution would be to create your label with the $SS_NOPREFIX style included:$abc = guiCtrlCreateLabel($album, 20, 80, 400, 80, $SS_NOPREFIX) Link to comment Share on other sites More sharing options...
seandisanti Posted July 14, 2005 Share Posted July 14, 2005 Probably an even better solution would be to create your label with the $SS_NOPREFIX style included:$abc = guiCtrlCreateLabel($album, 20, 80, 400, 80, $SS_NOPREFIX)<{POST_SNAPBACK}>another alternative would be to use chr(38) inplace of your &...ex: "Lock, Stock, " & chr(38) & " 2 smoking barrels"... in notepad you could just press control h, and replace '&' with '" & chr(38) & "' without the surrounding single quotes... that way you can have a hotkey AND and a '&' in your string... Link to comment Share on other sites More sharing options...
roboz Posted July 16, 2005 Author Share Posted July 16, 2005 Thanks for all the help. I think I'll go with the $SS_NOPREFIX because I'm reading the information directly from iTunes through the COM interface, so that's probably the easiest way. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now