jfcby Posted November 15, 2011 Share Posted November 15, 2011 (edited) I have a edit control that I need to read text from an ini file and display formatted text. The problem is the edit control does not display the text with new lines (n) and tabs (t).How can I get the edit control to display the text from an ini file with new lines and tabs?I've searched through the help file and this forum but I did not find an answer.Ini File: db.ini;Database Test Example [faqq] q0=Select a question q1=Question 1? q2=Question 2? q3=Question 3? [faqa] a0=Select a question above from the drop down.nnEach answer will be displayed here in this area.nnIf there are buttons below this text box then click them because there will be a video or a link for reference with more details.nnIf the answers you are looking for are not found here then go to the Help Tab for more details. a1=Answer 1. a2=Answer 2. a3=Answer 3nnAnswer 3anAnswer 3bt Answer 3ctAnswer 3dnAnswer 3et Answer 3ft Answer 3gnAnswer 3htt Answer 3it Answer 3jScript:#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> $IniLoc = @ScriptDir & "db.ini" GUICreate("Combo Ini Ex FAQ", 230, 200) $cbofaq = GUICtrlCreateCombo("", 10, 10, 200, 25) ; create first item $editfaq = GUICtrlCreateEdit("" & @CRLF, 10, 50, 200, 125, $ES_AUTOVSCROLL + $WS_VSCROLL) _FaqSetupCombo() GuiSetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _FaqSetupCombo() ; $irsfq = IniReadSection($IniLoc, "faqq") $irsfa = IniReadSection($IniLoc, "faqa") For $iirsfq = 1 To $irsfq [0][0] GUICtrlSetData($cbofaq, $irsfq[$iirsfq][1] & "|", IniRead($IniLoc, "faqq", "q0", "NotFound")) ; add other item and set a new default Next GUICtrlSetData($editfaq, StringFormat(IniRead($IniLoc, "faqa", "a0", "NotFound"))) ;Does not display text correct MsgBox(0, "", StringFormat(IniRead($IniLoc, "faqa", "a0", "NotFound"))) ;Displays text correct EndFunc ;==>_FaqSetupComboThank you for your help,jfcby Edited November 15, 2011 by jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** Link to comment Share on other sites More sharing options...
funkey Posted November 15, 2011 Share Posted November 15, 2011 #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> #Include <GuiComboBoxEx.au3> ;~ _GUICtrlComboBoxEx_GetCurSel $IniLoc = @ScriptDir & "db.ini" Global $irsfq = IniReadSection($IniLoc, "faqq") Global $irsfa = IniReadSection($IniLoc, "faqa") Global $hWnd = GUICreate("Combo Ini Ex FAQ", 230, 200) Global $cbofaq = GUICtrlCreateCombo("", 10, 10, 200, 25) ; create first item For $i = 1 To $irsfq[0][0] GUICtrlSetData(-1, $irsfq[$i][1], $irsfq[1][1]) $irsfa[$i][1] = StringReplace($irsfa[$i][1], "n", @CRLF) $irsfa[$i][1] = StringReplace($irsfa[$i][1], "t", @TAB) Next Global $editfaq = GUICtrlCreateEdit("" & @CRLF, 10, 50, 200, 125, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $cbofaq GUICtrlSetData($editfaq, $irsfa[GUICtrlSendMsg($cbofaq, 0x147, 0, 0) + 1][1]) EndSwitch WEnd Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2011 Moderators Share Posted November 15, 2011 jfcby, I think this does what you need: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> ; You create these arrays in a function but we need to use them elsewhere so they must be declared as Global Global $irsfq, $irsfa $IniLoc = @ScriptDir & "db.ini" GUICreate("Combo Ini Ex FAQ", 230, 200) $cbofaq = GUICtrlCreateCombo("", 10, 10, 200, 25) ; create first item $editfaq = GUICtrlCreateEdit("" & @CRLF, 10, 50, 200, 125, BitOr($ES_AUTOVSCROLL, $WS_VSCROLL)) _FaqSetupCombo() GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $cbofaq ; Read the new combo selection $sQuestion = GUICtrlRead($cbofaq) ; Run through the questions For $i = 1 To $irsfq[0][0] If $sQuestion = $irsfq[$i][1] Then ; And when we get a match we write the answer GUICtrlSetData($editfaq, $irsfa[$i][1]) ; No point in looking any more! ExitLoop EndIf Next EndSwitch WEnd Func _FaqSetupCombo() ; Read questions $irsfq = IniReadSection($IniLoc, "faqq") $sCombo_String = "" For $iirsfq = 1 To $irsfq[0][0] $sCombo_String &= "|" & $irsfq[$iirsfq][1] Next GUICtrlSetData($cbofaq, $sCombo_String, $irsfq[1][1]) ; read answers $irsfa = IniReadSection($IniLoc, "faqa") ; Now loop through the answers and convert n and t For $i = 1 To $irsfa[0][0] $irsfa[$i][1] = StringReplace($irsfa[$i][1], "n", @CRLF) $irsfa[$i][1] = StringReplace($irsfa[$i][1], "t", @TAB) Next GUICtrlSetData($editfaq, $irsfa[1][1]) EndFunc ;==>_FaqSetupCombo Please ask if you have any questions. 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...
jfcby Posted November 15, 2011 Author Share Posted November 15, 2011 Thank you funkey and Melba23 for your help. Your replies solved solved my problem. Thank you. Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** 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