Jump to content

Recommended Posts

Posted

Hi,

i got a strange issue.

If i use _GUICtrlRichEdit_InsertText(  then _GUICtrlRichEdit_CanUndo( is not beeing enabled afterwards.

If i use _GUICtrlRichEdit_ReplaceText( instead, everything is working fine.

Thanks for assistance

Cheers mike

Posted
4 hours ago, mike1950r said:

i got a strange issue ...

In advance : I am not a proven expert on " Rich Edit controls ", so this is just a guess ;).

Unlike _GUICtrlRichEdit_ReplaceText_GUICtrlRichEdit_InsertText" apparently does not add anything to the Undo-Queue by default.

Here is a small demo script (modified from the Help) :

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $idLblMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("NEXT", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "FIRST paragraph")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit)
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($hRichEdit, 0, 5)
                        GUICtrlSetData($idLblMsg, "FIRST selected")
                    Case 2
                        _GUICtrlRichEdit_InsertText($hRichEdit, "****")
                        GUICtrlSetData($idLblMsg, "**** is inserted at active point of selection")
                    Case 3
                        MsgBox(0, "Actions in the UNDO-Queue after 'InsertText'", "UNDO-Queue=" & _GUICtrlRichEdit_CanUndo($hRichEdit))
                    Case 4
                        _GUICtrlRichEdit_SetSel($hRichEdit, 0, 5)
                        _GUICtrlRichEdit_ReplaceText($hRichEdit, "SECOND ")
                        GUICtrlSetData($idLblMsg, "FIRST has been replaced by SECOND")
                        MsgBox(0, "1. Actions in the UNDO-Queue after 'ReplaceText'", _
                                  "'FIRST has been replaced by SECOND'" & @CRLF & _
                                  "UNDO-Queue=" & _GUICtrlRichEdit_CanUndo($hRichEdit) & @CRLF & _
                                  "-> CRTL-Z = 'Undo' possible (will empty UNDO-Queue)" & @CRLF & _
                                  "-> just click NEXT (UNDO-Queue remains)" & @CRLF )
                    Case 5
                        MsgBox(0, "2. Actions in the UNDO-Queue after 'ReplaceText'", "UNDO-Queue=" & _GUICtrlRichEdit_CanUndo($hRichEdit))
                        GUICtrlSetData($idLblMsg, "==> Finished")
                        GUICtrlSetData($idBtnNext, "Exit")
                    Case 6
                        _GUICtrlRichEdit_Destroy($hRichEdit)
                        Exit
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

This probably doesn't help you much, but at least confirms your observation.

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
4 hours ago, Musashi said:

In advance : I am not a proven expert on " Rich Edit controls ", so this is just a guess ;).

Unlike _GUICtrlRichEdit_ReplaceText_GUICtrlRichEdit_InsertText" apparently does not add anything to the Undo-Queue by default.

Here is a small demo script (modified from the Help) :

Hi Musashi,
thanks for your confirmation.
I have used _GUICtrlRichEdit_Paste instead of _GUICtrlRichEdit_InsertText, which works fine with the Undo check.

thanks for your assistance

cheers mike

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
  • Recently Browsing   0 members

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