sentry07 Posted March 22, 2013 Share Posted March 22, 2013 (edited) Back again with hopefully another quickie: I'm using a RichEdit box in my app as a communications log and a ComboBox as a command string input box. I'm using the CBS_DROPDOWN flag and storing a recent history of strings in it for recalling. The problem I'm having is when logging communication from the remote device, _GUIRichEdit_AppendText calls _WinAPI_SetFocus on the richedit which takes focus away from my combobox, so then I have to call _WinAPI_SetFocus on the combobox again. This causes the combobox to highlight everything in itself. If I'm typing when something happens in the log, I lose what I'm typing because it basically did a "Select All" and my typing overwrote the selected text. My try at two solutions: 1) I edited GuiRichEdit.au3 and removed the _WinAPI_SetFocus call in the _AppendText function. When you do this, the richedit doesn't scroll vertically automatically anymore. So I added _GUIRichEdit_ScrollLines calls and tried counting how many lines and blah blah blah and it always screws up the scroll and never works right. 2) After putting the SetFocus back in the AU3 so that scrolling works correctly, I thought to myself "I'll just get the current selection in the combobox (which should be nothing most of the time) before appending text, then set the selection again after appending and everything should be great." So I added the functions and after much debugging and cursing found the note that says you can't use GetCurEditSel/SetCurEditSel if you use the $CBS_DROPDOWN flag or it will return an error. So I'm stuck again looking for ideas. I wish I could just say "Scroll 100%" but it doesn't seem to work like that. Edited March 22, 2013 by sentry07 Link to comment Share on other sites More sharing options...
PhoenixXL Posted March 22, 2013 Share Posted March 22, 2013 (edited) Don't change the UDF's default, try using ControlSetText Does this help in some way#include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Main() Func Main() Local $hGui, $hRichEdit, $iMsg $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_AppendTextEx($hRichEdit, @CR & "This is more text") GUISetState() While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes ;~ GUIDelete() ; is OK too Exit EndSelect WEnd EndFunc ;==>Main Func _GUICtrlRichEdit_AppendTextEx( $hWnd, $sText ) Local $hParent = _WinAPI_GetParent( $hWnd ) ControlSetText($hParent, '', $hWnd, $sText ) EndFunc Edited March 22, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. 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