Illuma Posted October 15, 2010 Share Posted October 15, 2010 Hi I am having trouble creating button text using the symbol & I had the same problem using " but I managed to get that working by using the ASCII code Char(34). Please look at the attached code to see what I mean, I have tried numerous methods but all with the same result! So I am hoping some guru on here will tell me I am a fool and show me the simple way of doing it! Thanks in advance! #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 419, 197, 192, 124) GUISetBkColor(0x00FFFF) GUISetFont(12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("A", 80, 64, 65, 57, $WS_GROUP) ;Create button with A as button text $Ditto = Chr(34) ;Create button with " as button text $Button2 = GUICtrlCreateButton($Ditto, 168, 64, 65, 57, $WS_GROUP) $AndSym = Chr(38) ;Create button with & symbol as button text, Can't get this to work? $Button3 = GUICtrlCreateButton($AndSym, 264, 64, 65, 57, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 15, 2010 Moderators Share Posted October 15, 2010 Illuma,Double the &: $Button3 = GUICtrlCreateButton("&&", 264, 64, 65, 57, $WS_GROUP)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Illuma Posted October 15, 2010 Author Share Posted October 15, 2010 Illuma, Double the &: $Button3 = GUICtrlCreateButton("&&", 264, 64, 65, 57, $WS_GROUP) M23 Thanks Melba23, tested && working! Weird though? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 15, 2010 Moderators Share Posted October 15, 2010 Illuma, Weird though?Not really. & is used to set a particular letter to act as the accelerator key for a button (and menu item) when Alt is pressed. So to actually use it as part of the text, you need to escape it in some fashion. Run this script and press "Alt-P": #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hButton = GUICtrlCreateButton("&Press P", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton MsgBox(0, "", "You pressed me!") EndSwitch WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Illuma Posted October 15, 2010 Author Share Posted October 15, 2010 Illuma, Not really. & is used to set a particular letter to act as the accelerator key for a button (and menu item) when Alt is pressed. So to actually use it as part of the text, you need to escape it in some fashion. Run this script and press "Alt-P": #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hButton = GUICtrlCreateButton("&Press P", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton MsgBox(0, "", "You pressed me!") EndSwitch WEnd M23 Ahh, Well now I have learnt two handy things today, Thanks for the lesson! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 15, 2010 Moderators Share Posted October 15, 2010 Illuma,I have learnt two handy things todayWant to try for a third? When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Illuma Posted October 15, 2010 Author Share Posted October 15, 2010 HAHA Thanks, thats three! It takes me longer to work out how to post things than it does to find a solution 90% of the time! Link to comment Share on other sites More sharing options...
ajag Posted October 18, 2010 Share Posted October 18, 2010 And wouldn't this work? ; $Ditto = Chr(34) ; <<<<< not necessary $Button2 = GUICtrlCreateButton('"', 168, 64, 65, 57, $WS_GROUP) ;Create button with " as button text A-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
UEZ Posted October 18, 2010 Share Posted October 18, 2010 It is also working! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hButton = GUICtrlCreateButton('"', 168, 64, 65, 57, $WS_GROUP) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton MsgBox(0, "", "You pressed me!") EndSwitch WEnd Gruß, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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