Guy_ Posted October 19, 2020 Share Posted October 19, 2020 (edited) First time I'm diving a little deeper into buttons, and mainly frustrated by the encoding problem. The rabbit hole is deep... đ #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> $text = "[book] EsmĂ©e SĂ»rnomĂ - Cars_ Planes, Boats, & Rockets! (great) Until the line doubles if there are spaces or a .bmp in front." $hGUI = GUICreate("", 600, 300) GUICtrlCreateButton(" " & $text, 10, 10, 580, 40, BitOR($BS_LEFT,$BS_MULTILINE)) GUICtrlSetFont(-1, 11, 600) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd (1) I'm loading filenames with _FileListToArrayRec() and my impression is this gets all or most "special" characters. However, I can't find how to have some correctly go on a button... In the example it's only the '&' that is getting lost, but there may be more... My .au3 file gets saved in UTF-8 with BOM and I'm already pretty dirty from the rabbit hole... đ (2) Is there a more professional way to Left Align besides the $BS_LEFT I'm using? I mean, when a line goes double (like in my example) or you have a bitmap in front, the spaces I'm now using to create some margin lead to big problems. If I don't have the spaces, things stick to the edge...  (3) I've been making some bitmaps to go on the buttons and for a few of them the image colors change. Does this ring a bell about what might be wrong? (tried saving them in different ways, and like the ones that are working). Thanks for any pointers, esp. #1 đ€ Edited October 19, 2020 by Guy_ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 19, 2020 Moderators Share Posted October 19, 2020 Guy_, 1. Buttons always loose a single "&" character as Windows interprets that as setting the next character as the accelerator key for firing the control - you need to double the "&" using StringReplace. 2. You can add the same spacing to the beginning of each line to create a standard margin like this: #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> $sText = "This is line #1" & @CRLF & "This is line #2" _AddMargin($sText) $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton($sText, 10, 10, 580, 40, BitOR($BS_LEFT,$BS_MULTILINE)) GUICtrlSetFont(-1, 11, 600) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _AddMargin(ByRef $sText) $sText = " " & StringReplace($sText, @CRLF, @CRLF & " ") EndFunc 3. Never seen bitmap colours change as you describe. M23 Guy_ 1  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...
Guy_ Posted October 19, 2020 Author Share Posted October 19, 2020 (edited) (1) Phew! Thanks so much! (2) Thanks! I think this can be handy one day but because I have no Returns in the titles, it's really doing the same thing as I did but with four spaces instead of two. The mishaps are still the same... (3) I'll try if I can make a small reproducer somewhere tomorrow. I've had it with at least four .bmp's. They are not changing in front of my eyes but display differently than I designed them. For example ... This is my code minus some lengthy vars: _AddMargin($s_Title) $a_hBtn[$i][0] = GUICtrlCreateButton($s_Title, 10, , , , BitOR($BS_LEFT,$BS_MULTILINE)) GUICtrlSetFont(-1, 11, 600) If StringInStr("pdfx", $_ext) Then GUICtrlSetImage(-1, @ScriptDir & "\label\acro.bmp", "", $BS_BITMAP) ; Adobe Acrobat (pdf) ElseIf StringInStr("djvu", $_ext) Then GUICtrlSetImage(-1, @ScriptDir & "\label\djvu.bmp", "", $BS_BITMAP) ; DjVu ElseIf StringInStr("epub", $_ext) Then GUICtrlSetImage(-1, @ScriptDir & "\label\epub.bmp", "", $BS_BITMAP) ; EPUB ElseIf StringInStr("azw3azw4kdpkpfmobi", $_ext) Then GUICtrlSetImage(-1, @ScriptDir & "\label\kindle.bmp", "", $BS_BITMAP) ; Amazon Kindle (mobi azw azw3 azw4 kdp kpf) ElseIf StringInStr("docx", $_ext) Then GUICtrlSetImage(-1, @ScriptDir & "\label\word.bmp", "", $BS_BITMAP) ; MS WORD (doc docx) ElseIf StringInStr("rtf", $_ext) Then GUICtrlSetImage(-1, @ScriptDir & "\label\wordpad.bmp", "", $BS_BITMAP) ; WordPad (rtf) ElseIf StringInStr("odt", $_ext) Then GUICtrlSetImage(-1, @ScriptDir & "\label\odt.bmp", "", $BS_BITMAP) ; LibreOffice (odt) Else GUICtrlSetImage(-1, @ScriptDir & "\label\generic.bmp", "", $BS_BITMAP) EndIf P.S. Enjoying your great scrollbars for the first time too! đ€© Edited October 19, 2020 by Guy_ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 19, 2020 Moderators Share Posted October 19, 2020 Guy_, Use my StringSize UDF (the link is in my sig) to break up the strings to the width you require - the UDF adds @CRLFs where necessary so solving your problem. M23 Guy_ 1  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...
Guy_ Posted October 23, 2020 Author Share Posted October 23, 2020 The wrongly displaying bitmaps I have solved by saving them out from MS Paint instead. When in several ways saving them out from Photoshop, several displayed differently than designed... 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