hallaplay835 0 Posted April 22, 2011 Hey there, probably the answer is simple but I cannot find a way to do this. Suppose you had this string and you wanted to display a message box with its contents: $string = "Unable to complete operation" & @CR & "Error code: AS532" MsgBox(0, "Error", $string) Is there some way to display the second part of the string ("Error code: AS532") in some other colour e.g red? I've had a read through the documentation but cannot find a way to accomplish this. Any ideas? Thanks in advance. _____________________________________________________[size="2"][font="Arial"]"Pain is temporary, glory is forever."[/font][/size] Share this post Link to post Share on other sites
Melba23 3,456 Posted April 22, 2011 hallaplay835,Is there some way to display the second part of the string ("Error code: AS532") in some other colour e.g red?Not that I know of. My ExtMsgBox UDF (look in my sig) will let you colour all the text in the ExtMsgBox whatever colour you wish, but if you want different colours for separate parts of the text I think you will have to write your own UDF with a GUI and separate labels. 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 Share this post Link to post Share on other sites
nitekram 68 Posted April 22, 2011 Not sure you can do it with just a string. But you could do it with creating your own message box - then use lables to create the text, using two lables. One for the regular text and one with the colored text. #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $string = "Unable to complete operation" & @CR Global $string2 = "Error code: AS532" Example() Func Example() Local $msg GUICreate("My GUI color text") ; will create a dialog box that when displayed is centered GUICtrlCreateLabel($string, 10, 20) GUICtrlCreateLabel($string2, 10, 35) GUICtrlSetColor(-1, 0xff0000) ; Red GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example 2¢All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDFLearning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming TipsExcel ChangesControlHover.UDFGDI_PlusDraw_On_ScreenGDI BasicsGDI_More_BasicsGDI RotateGDI GraphGDI CheckExistingItemsGDI TrajectoryReplace $ghGDIPDll with $__g_hGDIPDllDLL 101?Array via ObjectGDI SwimlaneGDI Plus French 101 SiteGDI Examples UEZGDI Basic ClockGDI DetectionTernary operator Share this post Link to post Share on other sites