Jump to content

Richedit Delete Question


Go to solution Solved by MattyD,

Recommended Posts

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

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

  • Solution

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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...