ibigpapa Posted January 2, 2012 Share Posted January 2, 2012 (edited) I've got an issue and I'm not sure if it's a bug or if I'm doing something incorrectly. I'm making a richedit tool for my script. When I choose to change the font and I have text selected it'll change the selected text but then the selected text highlight is gone and cannot be seen until changing something like the font size. It's weird, it is still selecting the text but you cannot see what you have selected. To recreate follow these steps: 1. Run the code 2. Type some text 3. Highlight the text 4. Change the font. 5. click back on the edit to see the highlighted text 6. Attempt to highlight anything in the edit field (should see the issue now) 7. Change the font size 8. Now you'll see your selection again and what was selected will have changed. expandcollapse popup#include <Color.au3> #include <GuiRichEdit.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <RichEditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("GUIOnEventMode",1) #region Main Global $iLeft = 5 Global $iTop = 20 Global $iWidth = 780 Global $iHeight = 575 Global $iFieldWidthLong = 100 Global $iFieldWidthMid = 50 Global $iFieldWidthShort = 25 Global $iDefaultHeight = 25 Global $iDefaultGap = 5 Global $guiTest = GUICreate("Test",800,600) Global $cboFont = GUICtrlCreateCombo("", $iLeft, $iTop, $iFieldWidthLong, $iDefaultHeight,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData($cboFont,"Arial|Arial Black|Comic Sans MS|Courier|Courier New|Estrangelo Edessa|Franklin Gothic Medium|Gautami|Impact|Latha|Lucida Console|Lucida Sans Console|Lucida Sans Unicode|Marlett|Modern|MS Sans Serif|MS Serif|MV Boli|Palatino Linotype|Roman|Script|Small Fonts|Symbol|Tahoma|Times New Roman|Trebuchet|Tunga|Verdana|Wingdings","Times New Roman") GUICtrlSetOnEvent($cboFont,"_fontChange") Global $cboFontSize = GUICtrlCreateCombo("", _getPositionLeftOfCtrl($guiTest, $cboFont, $iDefaultGap), $iTop, $iFieldWidthMid, $iDefaultHeight,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData($cboFontSize,"8|9|10|11|12|14|16|20|24|32|48|64|72","12") GUICtrlSetOnEvent($cboFontSize,"_fontSizeChange") Global $rhcBody = _GUICtrlRichEdit_Create($guiTest, "", $iLeft, $iTop + $iDefaultHeight + $iDefaultGap, $iWidth, $iHeight - $iDefaultHeight - $iDefaultGap, BitOR($WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE, $ES_WANTRETURN)) Global $bUndo = _GUICtrlRichEdit_SetUndoLimit($rhcBody, 1000) _GUICtrlRichEdit_SetFont($rhcBody,_getcboFontSize(),_getcboFont()) GUISetOnEvent($GUI_EVENT_CLOSE, "guiClose",$guiTest) GUISetState(@SW_SHOW,$guiTest) While 1 WEnd #endregion Main Func _fontChange() Local $avFontInfo = _GUICtrlRichEdit_GetFont($rhcBody) _GUICtrlRichEdit_SetFont($rhcBody,$avFontInfo[0],_getcboFont()) EndFunc Func _fontSizeChange() _GUICtrlRichEdit_SetFont($rhcBody,_getcboFontSize()) EndFunc Func guiClose() _GUICtrlRichEdit_Destroy($rhcBody) Exit EndFunc Func _getPositionLeftOfCtrl($hWin,$hCtrl,$iGap) Local $aiCoord = ControlGetPos($hWin,"",$hCtrl) Return $aiCoord[0] + $aiCoord[2] + $iGap EndFunc Func _getcboFont() Return GUICtrlRead($cboFont) EndFunc Func _getcboFontSize() Return GUICtrlRead($cboFontSize) EndFunc Edited January 2, 2012 by ibigpapa Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 2, 2012 Share Posted January 2, 2012 Try this to unhide the selection: _SendMessage($hWnd, $EM_HIDESELECTION, False) ibigpapa 1 Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ibigpapa Posted January 2, 2012 Author Share Posted January 2, 2012 Woot, that did it. Good call. Should this be a bug report? Try this to unhide the selection: _SendMessage($hWnd, $EM_HIDESELECTION, False) Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 2, 2012 Share Posted January 2, 2012 A few points: 1) As I should have expected and failed to look for, there is already a _GuiCtrlRichEdit_HideSelection() function in the UDF.2) According to this guy: "As with edit controls, you can specify the ES_NOHIDESEL window style to prevent a rich edit control from hiding the selection highlight when it loses the focus." Setting that style when creating the control does maintain the selection highlight when the control loses focus, but didn't help when setting the font.3) Before reporting this as an AutoIt bug, you will have to see if this is expected Microsoft behavior. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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