Jump to content

Recommended Posts

Posted (edited)

I believe this is a windows bug. I don't know if it is specific to XP. Please try the following test. Do you get the same results as I do?

1. Run the reproducer

2. Wait one second and then type some text,

3. Press Ctrl+Z

#include <GuiEdit.au3>
#include <GuiConstantsEx.au3>

_Reproducer()

Func _Reproducer()
    Local $hGUI, $hEdit

    $hGUI = GUICreate("Edit Create", 400, 300)
    $hEdit = _GUICtrlEdit_Create($hGUI, "0x0045", 2, 2, 394, 268)
    ;$hEdit = GUICtrlCreateEdit("0x8345", 2, 2, 394, 268) ; Native function
    GUISetState()

    Sleep(1000) ; Please wait
    _GUICtrlEdit_ReplaceSel($hEdit,ChrW(0x0045))
    _GUICtrlEdit_SetSel($hEdit, 0, 0) ; Position to start typing

    Do
        ; Type something
        ; Press Ctrl+Z
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Reproducer

My Results:

At first you see 0x0045. This is replaced with the letter E ==> ChrW(0x0045)

If you now type the letter A, the result should be AE

Pressing Ctrl+Z does not revert to an earlier rendering.

Instead the result will be 0x0045E. This is not a successful undo operation.

Edited by czardas
Posted

Thanks for testing JohnOne and kylomas. It doesn't occur if you type letters after the replaced hex. It also does not occur if you paste the hex into the control. It only seems to occur when you use _GUICtrlEdit_ReplaceSel to replace the hex, and then type something before the replaced characters. At first I thought it might be an AutoIt bug, but I'm not convinced this is the case. Perhaps some more advanced members can shed some light on this.

Posted

Hm... interesting, this does not happend if you use a raw string but the _GUICtrlEdit_SetSel function is needed to create the bug.

On the contrary there is no problem on Win8 64bits. (Windows issue I guess)

Br, FireFox.

Posted

  On 4/1/2013 at 12:15 AM, 'FireFox said:

On the contrary there is no problem on Win8 64bits. (Windows issue I guess)

Hmm right. If it's a windows issue, I wonder why it took so long to fix. Perhaps the undo operation is the culprit, rather than the method used to add the text.

Posted

czardas,

I tried this

#include <GuiEdit.au3>
#include <GuiConstantsEx.au3>
hotkeyset('^z',"undo")
local $hedit
_Reproducer()
Func _Reproducer()
    Local $hGUI, $hEdit
    $hGUI = GUICreate("Edit Create", 400, 300)
    $hEdit = _GUICtrlEdit_Create($hGUI, "0x0045", 2, 2, 394, 268)
    ;$hEdit = GUICtrlCreateEdit("0x8345", 2, 2, 394, 268) ; Native function
    GUISetState()
    Sleep(1000) ; Please wait
    _GUICtrlEdit_ReplaceSel($hEdit,ChrW(0x0045))
    _GUICtrlEdit_SetSel($hEdit, 0, 0) ; Position to start typing
 sleep(3000)
 _guictrledit_undo($hedit)
    Do
        ; Type something
        ; Press Ctrl+Z
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Reproducer
func undo()
 ConsoleWrite('Undo actioned' & @LF)
 consolewrite(_guictrledit_undo($hedit) & @lf)
endfunc

but I don't think I'm using the functions or hotkey correctly (never used a hotkey before).

The undo from the function always returns "false" (failure).

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted (edited)

kylomas

The biggest problem with your script is that you are trying to reset a windows default hotkey for the edit control. You can't override Ctrtl+Z with a user defined hotkey (or accelerator) when working with an edit control.

Edited by czardas

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...