Sign in to follow this  
Followers 0
qwert

Need smooth update of a derived field

5 posts in this topic

I am desperately trying to get a handle on this -- and find a solution -- after two days of work. I hope someone can help me past this. I've tried two dozen combinations and nothing has worked.

All I need is a data entry field that updates smoothly (i.e., without any flicker effect) and that will accept input interchangeably from the keyboard and an on-screen button. That sounded simple enough when I started -- but an acceptable solution has stayed just out of reach.

Earlier, I posted an example attempting to accomplish it with a single input field -- but update flickering made me abandon that approach. (I must say, I never understood what was causing the entered characters to become highlighted, which resulted in the momentary flash.) Here's a link to the previous example, if anyone is interested: previous

In the following example, I'm trying a display-only field that is derived from the real input field. The problem now is that nothing triggers a refresh when a keyboard entry is made -- although the keys are accepted (they display where the next button entry is clicked. The field works fine when only button clicks are made or when only keyboard entry is made. Intermixing is the problem I'm trying to solve.

;   Entry from keyboard input doesn't update related field
;   after any input from graphic button is received
#include <GUIConstants.au3>

GUICreate("Example", 300, 277, -1, 240, $WS_SIZEBOX + $WS_SYSMENU)

GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg", -1, -1, 200, 50)
GUICtrlSetState(-1, $GUI_DISABLE)

$ctrlInput = GUICtrlCreateInput("", 20, 60, 260, 30, $ES_RIGHT)
GUICtrlSetFont($ctrlInput, 16, 600)

$ctrlDisplay = GUICtrlCreateLabel("", 20, 120, 260, 30, $ES_RIGHT)
GUICtrlSetFont($ctrlDisplay, 16, 600)
GUICtrlSetBkColor($ctrlDisplay, 0xFFFFFF)

$Graphic1 = GUICtrlCreateGraphic(33, 14, 100, 30, $SS_NOTIFY + $SS_WHITEFRAME)
GUICtrlSetTip(-1, "Grahic Button")

$clear = GUICtrlCreateButton("Clear", 50, 160, 40, 20)

GUIRegisterMsg($WM_COMMAND, "On_WM_COMMAND")
GUISetState()

While 1
    $msg = GUIGetMsg()
        Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $clear
            GUICtrlSetData( $ctrlInput, "" )
            GUICtrlSetData( $ctrlDisplay, "" )
            ControlFocus("", "", $ctrlInput ); <<<<< this works to enable keyboard entry
        EndSwitch
WEnd

Func On_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iNotifyCode = BitShift($wParam, 16), $iID = BitAnd($wParam, 0x0000FFFF)
    If $iID = $Graphic1 Then
        Switch $iNotifyCode
            Case 0, 1; STN_CLICKED, STN_DBLCLK
                GUICtrlSetData( $ctrlInput, GUICtrlRead( $ctrlInput )  & "X" )
                GUICtrlSetData( $ctrlDisplay, GUICtrlRead( $ctrlInput ))
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

I will greatly appreciate help on this -- or a recommendation of an entirely different approach.

Thanks in advance.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi again ;)

(but in this code cliking X will lose the first edit focus! but from the other side the second edit works perfectly now :) )

--EDITED--

foget about the code up, if you will change Inputs to edit controls you may use code like this:

(it will give focus to first edit when clicked X, without any flickering )

$len=stringlen(GUICtrlRead( $ctrlInput ))
               GUICtrlSetState($ctrlInput,$GUI_FOCUS)
        GUICtrlSendMsg($ctrlInput, $EM_SETSEL,$len,$len)

:(

EDIT:

Check out this code and loke like its work :D

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
GUICtrlCreateButton ("Ok", 20,200,50)

GUISetState ()

For $n=1 To 5
GUICtrlSetData ($nEdit, @CRLF & "edit control line "& $n)
Next


; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    If $msg >0 Then
        GUICtrlSetState($nEdit,$GUI_FOCUS)
        for $i=2 to 21
        GUICtrlSendMsg($nEdit, $EM_SETSEL,$i,$i)
        sleep(50)
        next
    EndIf
Until $msg = $GUI_EVENT_CLOSE
Edited by Uriziel01

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes, I think I tried that same thing earlier. But I can't have it lose edit focus. Sorry. Thanks for trying.

Anyone else willing to give this a try? -- or tell me why it's not possible!

Edit: Oops, I posted too soon ... didn't see your update. Let me try it.

Edited by qwert

Share this post


Link to post
Share on other sites

... if you will change Inputs to edit controls ...

I don't think I can do that -- but I think I see what you're suggesting. I just don't think edit controls are appropriate for my application. The displayed field is actually "calculated" in real time, according to the combination of key entries and button clicks. Updates must be immediate -- and without flicker. I'll look at this more tomorrow. I'm just a little beat down at the moment from trying so much today. Thanks for your help.

Share this post


Link to post
Share on other sites

No problem ;)

1)I dont see problem witch changing input to edit, it will no cause any flickering or any other problems

2)I think the goal that you want to achieve isnt real when using input insteed of edit (or meaby im wrong?I dunno for sure :D )

Ok then see you tommorow :(

p.s-meaby in free time ill rewrite your code to show you input version :)


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