Edit as Input Re: Input vs Edit control

"valery_vi" <[email protected]>
Newsgroups gmane.comp.windows.autoit.user
Message-ID <[email protected]>
This script uses WM_COMMAND notification instead of Edit control 
polling. It shows real replacement Input control by Edit one.

#include <GUIConstants.au3>
Global Const $WM_COMMAND = 0x0111
Global Const $EN_UPDATE = 0x400
Global Const $EN_SETFOCUS = 0x0100

Global $Edit

; Set up a basic test GUI
$hWnd = GUICreate("Input vs Edit", 400, 150)
$LabelOfEdit = GUICtrlCreateLabel("Edit control is fired by 
{Enter},only", 10, 10, 380, 21)
$Edit = GUICtrlCreateEdit("", 10, 30, 380, 21, BitOR
($ES_WANTRETURN,$ES_AUTOVSCROLL))
$LabelOfInput = GUICtrlCreateLabel("Input control is fired by any 
focus changes incl. {Tab}", 10, 50, 380, 21)
$Input = GUICtrlCreateInput("", 10, 70, 380, 21)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

; Start the main loop
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Input
WinSetTitle($hWnd, "", GUICtrlRead($Input))
EndSwitch
WEnd

;==================================
Func WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $EditContent
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0x0000FFFF)

    If $nID = $Edit Then
        Select
        Case $nNotifyCode = $EN_UPDATE
            $EditContent = GUICtrlRead($Edit)
            If StringRight($EditContent,2) = @CRLF Then
                $EditContent = StringTrimRight($EditContent,2)
                GUICtrlSetData($Edit,$EditContent)
                WinSetTitle($hWnd, "", $EditContent)
                Send("{TAB}")
            EndIf
        Case  $nNotifyCode = $EN_SETFOCUS
		;Clear content selection
        	Send("{RIGHT}")
        EndSelect
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND 

See also here
http://www.autoitscript.com/forum/index.php?showtopic=39786

Valery

--- In [email protected], "valery_vi" <shehrer1@...> wrote:
>
> Hi,
> 
> Remembering old discussion topic about input control events I've 
> written new script which shows difference between Input and Edit 
> events:
> 
> ; Both includes are required
> #include <GUIConstants.au3>
> 
> ; Set up a basic test GUI
> $hWnd = GUICreate("Input vs Edit", 400, 150)
> $LabelOfEdit = GUICtrlCreateLabel("Edit control is fired by 
{Enter}, 
> only", 10, 10, 380, 21)
> $Edit = GUICtrlCreateEdit("", 10, 30, 380, 21, BitOR
> ($ES_WANTRETURN,$ES_AUTOVSCROLL))
> $LabelOfInput = GUICtrlCreateLabel("Input control is fired by any 
> focus changes incl. {Tab}", 10, 50, 380, 21)
> $Input = GUICtrlCreateInput("", 10, 70, 380, 21)
> 
> GUISetState()
> 
> ; Start the main loop
> While 1
>    $EditContent = GUICtrlRead($Edit)
>    If StringRight($EditContent,2) = @CRLF Then
>      $EditContent = StringTrimRight($EditContent,2)
>      WinSetTitle($hWnd, "", $EditContent)
>      GUICtrlSetData($Edit,$EditContent)
>    endif        
>    $iMsg = GUIGetMsg()
>    Switch $iMsg
>         Case $GUI_EVENT_CLOSE
>             Exit
>         Case $Input
>             WinSetTitle($hWnd, "", GUICtrlRead($Input))
>     EndSwitch
> WEnd
> 
> You can see that Edit control is refreshing window title by {Enter} 
> key but Input does the same action by any {Enter}, {Tab}, or after 
> focus loss.
> The cost of Edit control advance is polling of it's content.
> 
> Valery
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.