mike1950r Posted September 19 Share Posted September 19 Hello, if i want to delete something in richedit i use _GUICtrlRichEdit_ReplaceText. This works all fine. But delete in a text editor is also used to draw letters backwards in a line to be deleted, say no selection is marked. (just similar to backspace) My question: how can I do this in richedit? Thanks for a tip. Cheers mike Link to comment Share on other sites More sharing options...
MattyD Posted September 19 Share Posted September 19 Hey Mike - not sure if I understand correctly, but were you trying to do something like this?? #include <GUIConstants.au3> #include <GuiRichEdit.au3> Local $GUI = GUICreate("", 150, 150) Local $hRE = _GUICtrlRichEdit_Create($GUI, "aaaaaaaaaa", 4, 40, 142, 102) _GuiCtrlRichEdit_SetSel($hRE, 2, 6) Local $hBtn = GUICtrlCreateButton("Delete", 4, 4, 80, 24) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit CAse $hBtn $aSel = _GuiCtrlRichEdit_GetSel($hRE) _GUICtrlRichEdit_ReplaceText($hRE, "") _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], $aSel[0]) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Solution MattyD Posted September 19 Solution Share Posted September 19 Or something to mimic BS and Del Keys... #include <GUIConstants.au3> #include <GuiRichEdit.au3> Local $GUI = GUICreate("", 180, 150) Local $hRE = _GUICtrlRichEdit_Create($GUI, "aaaaaaaaaa", 4, 40, 172, 102) _GuiCtrlRichEdit_SetSel($hRE, 2, 6) Local $hBtn = GUICtrlCreateButton("Delete", 4, 4, 80, 24) Local $hBtn2 = GUICtrlCreateButton("BS", 88, 4, 80, 24) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hBtn $aSel = _GuiCtrlRichEdit_GetSel($hRE) If $aSel[0] = $aSel[1] Then _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], $aSel[0] + 1) _GUICtrlRichEdit_ReplaceText($hRE, "") _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], $aSel[0]) Case $hBtn2 $aSel = _GuiCtrlRichEdit_GetSel($hRE) If $aSel[0] = $aSel[1] Then _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], ($aSel[0]) ? $aSel[0] - 1 : 0) $aSel[0] = ($aSel[0]) ? $aSel[0] - 1 : 0 EndIf _GUICtrlRichEdit_ReplaceText($hRE, "") _GuiCtrlRichEdit_SetSel($hRE, $aSel[0], $aSel[0]) EndSwitch WEnd mike1950r 1 Link to comment Share on other sites More sharing options...
mike1950r Posted September 19 Author Share Posted September 19 Many thanks MattyD, this works perfectly. I needed your second example. Cheers mike MattyD 1 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