ds34 Posted March 24, 2010 Share Posted March 24, 2010 I have a RichTextEdit and use it as a log application. I would like to add a "find/ find next" function for this log. Anyone of you who has an idea of how-to or even sample implementation? Cheers! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 24, 2010 Moderators Share Posted March 24, 2010 ds34,Here is a example using _GUICtrlRichEdit_FindText - which is designed to do just what you want: expandcollapse popup#include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $lblMsg, $hRichEdit Main() Func Main() Local $sSearchTerm = "another" Local $iSearchStart = 0 Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a line." & @CRLF & "And this is another line." & _ @CRLF & "And yet another line.", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Local $hFind_Button = GUICtrlCreateButton("Find", 230, 310, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit Case $hFind_Button If GUICtrlRead($hFind_Button) = "Find" Then GUICtrlSetData($hFind_Button, "Again") _GUICtrlRichEdit_SetSel($hRichEdit, $iSearchStart, $iSearchStart) $iIndex = _GUICtrlRichEdit_FindText($hRichEdit, $sSearchTerm) _GUICtrlRichEdit_SetSel($hRichEdit, $iIndex, $iIndex + StringLen($sSearchTerm)) $iSearchStart = $iIndex + StringLen($sSearchTerm) Else GUICtrlSetState($hFind_Button, $GUI_DISABLE) _GUICtrlRichEdit_SetSel($hRichEdit, $iSearchStart, $iSearchStart) $iIndex = _GUICtrlRichEdit_FindText($hRichEdit, $sSearchTerm) _GUICtrlRichEdit_SetSel($hRichEdit, $iIndex, $iIndex + StringLen($sSearchTerm)) EndIf EndSwitch WEnd EndFunc ;==>MainI hope that helps. 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...
ds34 Posted March 24, 2010 Author Share Posted March 24, 2010 Thanks, seems I should have made a move to the "new" GUIRichEdit. However, this is not feasible, since the old GUIRichEdit I am using is way faster and this performance is critical in my case (lots of small, differently formatted text pieces to be appended to the RichTextEdit every second). I will check the _GUICtrlRichEdit_FindText() if I can find a way to reuse/adapt this to the my version of "a" UDF (I do not even know the real version of this, since its an unversioned file from Gary Frost/Yoan Roblet I took from the forum ages ago). I know it misses lots of finetuning/features (i.e. resizing support) compared to the new UDF, but again, the performance counts here. Thanks again! Daniel Link to comment Share on other sites More sharing options...
DickG Posted December 23, 2010 Share Posted December 23, 2010 I tried to run this code directly, but get "ERROR: _GUICtrlRichEdit_FindText(): undefined function." I also get the "undefined function" error when trying to use _GUICtrlRichEdit_FindTextEx and _GUICtrlRichEdit_GetTextRange in my own code. The functions are recognized by AutoIt's CallTips, leading me to think they are found. Yet other RichEdit functions work fine. I can't figure out what the problem is. Any idea? ds34, Here is a example using _GUICtrlRichEdit_FindText - which is designed to do just what you want: <snip> Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 24, 2010 Moderators Share Posted December 24, 2010 DickG ,Any idea?Which AutoIt version are you using? The 2 additional commands you mention (_GUICtrlRichEdit_FindTextEx and _GUICtrlRichEdit_GetTextRange) are not in the current release - add the fact that you cannot use _GUICtrlRichEdit_FindText (which is) and it looks very much as though you are a little behind on the update front. 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...
DickG Posted December 24, 2010 Share Posted December 24, 2010 I'm using 3.3.0.0. So you're probably right about that being the reason. I've been putting off updating because I might have to spend time debugging those that break due to the changes. So I'll just have to bite the bullet and update.DickG ,Which AutoIt version are you using? The 2 additional commands you mention (_GUICtrlRichEdit_FindTextEx and _GUICtrlRichEdit_GetTextRange) are not in the current release - add the fact that you cannot use _GUICtrlRichEdit_FindText (which is) and it looks very much as though you are a little behind on the update front. M23 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 24, 2010 Moderators Share Posted December 24, 2010 DickG, Good luck to you with the updating - it will be worth it. I would wait until after Xmas though, or your dinner is likely to be overcooked and you might miss Santa! 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...
DickG Posted December 24, 2010 Share Posted December 24, 2010 I bit the bullet and updated all my scripts. Luckily, not that much needed changing. All went well.But now AutoIt can't find these commands: o _GUICtrlRichEdit_GetBold o _GUICtrlRichEdit_SetBold o _GUICtrlRichEdit_SetOLECallback o $ES_SUNKEN as parameter to _GUICtrlRichEdit_CreateI searched the forum and the Help file, but can't find anything about them. Were they deleted? Is there a replacement or workaround?DickG,Good luck to you with the updating - it will be worth it. I would wait until after Xmas though, or your dinner is likely to be overcooked and you might miss Santa! M23 Link to comment Share on other sites More sharing options...
DickG Posted December 24, 2010 Share Posted December 24, 2010 OK, I did more digging and discovered how to handle the bold (_GetCharAttributes and _SetCharAttributes). No problem on $ES_SUNKEN: I just deleted that.The only problem I have is not being able to unbold text after bolding it.I'm using _GUICtrlRichEdit_SetCharAttributes($hwnd, "+bo", True) to make it bold and _GUICtrlRichEdit_SetCharAttributes($hwnd, "-bo", True) to try to unbold it, but "-bo" doesn't do it. Well, anyway, hope you have a great Christmas and New Year, Melba. And thanks for your help.DickI bit the bullet and updated all my scripts. Luckily, not that much needed changing. All went well.But now AutoIt can't find these commands: o _GUICtrlRichEdit_GetBold o _GUICtrlRichEdit_SetBold o _GUICtrlRichEdit_SetOLECallback o $ES_SUNKEN as parameter to _GUICtrlRichEdit_CreateI searched the forum and the Help file, but can't find anything about them. Were they deleted? Is there a replacement or workaround? 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