Sign in to follow this  
Followers 0
Kademlia

[Solved] GUICtrlSetData abnormal behaviour

4 posts in this topic

#1 ·  Posted (edited)

Hey,

I got some problems with GUICtrlSetData,GUICtrlCreateInput and GUICtrlCreateEdit I wans´t able to work around.

Every time I insert text with GuiCtrlSetData into the EditField the text inside the InputText will be copied too (if changed).

Example Code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>

Global $ConsoleGui = GUICreate("Console",500,300,50,50,-1,$WS_EX_ACCEPTFILES)
Global $ConsoleList = GUICtrlCreateEdit("",5,5,490,270, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY) )
Global $ConsoleInput = GUICtrlCreateInput("",5,275,490,20)
Global $SecondsTimer = TimerInit()
GUISetState(@SW_SHOW)
Opt("GUIOnEventMode", 0)

while True
    Local $msg = GUIGetMsg()
    Switch $msg
        Case $ConsoleInput
            GUICtrlSetData($ConsoleList,GUICtrlRead($ConsoleInput),1)
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    CheckTimer()
WEnd

Func CheckTimer()
    If TimerDiff($SecondsTimer) > 500 Then
        GUICtrlSetData($ConsoleList,"..." & @CRLF,1)
        $SecondsTimer = TimerInit()
    EndIf
EndFunc

Second thing:

GUICtrlCreateEdit("",5,5,490,270, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY) )

Should create a READONLY EditField. But i´m still able to change the text by highlighting (hold mouse down and move cursor) parts of the text with my mouse cursor.

This works in the example above.

If someone has a fix for this or just a hint i´d be happy to hear about it. Thanks.

Edited by Kademlia

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$ES_READONLY: Prevents the user from typing or editing text in the edit control.

Thats what it does, i also would have expected it to prevent cutting, but that's not what's documented :D. Add GUICtrlSetState(-1,$GUI_DISABLE) directly after creating the edit control. Otherwise the GUI behaves as I would expect... you call GUICtrlSetData() twice in the loop, once on input and once via a timed function. Maybe you should clarify a little more what you want it to do :huggles:. Also check out the documentation of the third parameter you use with GUICtrlSetData().

Edited by KaFu

Share this post


Link to post
Share on other sites

Every time the input looses focus and has changed text, the changed-event occurs. You should use an Accelerator-key to send the input to the console instead of using the input-Changed event:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>

Global $ConsoleGui = GUICreate("Console",500,300,50,50,-1,$WS_EX_ACCEPTFILES)
Global $ConsoleList = GUICtrlCreateEdit("",5,5,490,270, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY) )
Global $ConsoleInput = GUICtrlCreateInput("",5,275,490,20)
Global $SecondsTimer = TimerInit()
$ENTER_DUMMY= GUICtrlCreateDummy()
Dim $accel[1][2] = [["{ENTER}", $ENTER_DUMMY]]
GUISetAccelerators($accel)
GUISetState(@SW_SHOW)
Opt("GUIOnEventMode", 0)

while True
    Local $msg = GUIGetMsg()
    Switch $msg
        Case $ENTER_DUMMY
            GUICtrlSetData($ConsoleList,GUICtrlRead($ConsoleInput),1)
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    CheckTimer()
WEnd

Func CheckTimer()
    If TimerDiff($SecondsTimer) > 500 Then
        GUICtrlSetData($ConsoleList,"..." & @CRLF,1)
        $SecondsTimer = TimerInit()
    EndIf
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hey, thanks for answering.

I´d like to use $GUI_DISABLE [ Control will be greyed out. :idiot: ]

But gray on gray is not that readable... and GUICtrlSetColor($-1, 0x000000) won´t change it back

About the GUICtrlSetData()

I tried to make some kind of Logging/ConsoleInput window.

Text can be inserted by the User using GUICtrlCreateInput.

The program itself will add Logging information to the window all the time depending on the DebugLevel [Date/Time information and some Statistic values]

A User should be able to write inside the InputBox and publish the text into EditField by pressing enter.

But everytime the Timer Based function inserts a text into the EditField the current text of that InputBox will be added too.

Edit: Thanks GUISetAccelerators works fine. I think i will have a closer look on that one.

Edited by Kademlia

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  
Followers 0