Jump to content
Sign in to follow this  
czardas

Edit Control Bug

Recommended Posts

czardas

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

Share this post


Link to post
Share on other sites
kylomas

Same Win7 64bit


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

Share this post


Link to post
Share on other sites
czardas

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.

Share this post


Link to post
Share on other sites
FireFox

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.

  • Like 1

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
czardas

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.

Share this post


Link to post
Share on other sites
kylomas

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

Share this post


Link to post
Share on other sites
czardas

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

Share this post


Link to post
Share on other sites
kylomas

Yea, was trying different shit...

Happy Easter!

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

Share this post


Link to post
Share on other sites
czardas

I often try things I'm told to avoid too. ^^

Happy easter to you too, and to everyone else. :)

Edited by czardas

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.