Sign in to follow this  
Followers 0
ken82m

Event on Leave Control

5 posts in this topic

#1 ·  Posted (edited)

I'm sure I've seen this done but I can't find any examples.

I'm running a GUI in message loop mode.

How can I create a case for when I leave a control or it loses focus?

Thanks,

Kenny

Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites



ken82m

What the control?

Share this post


Link to post
Share on other sites

an input box


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

an input box

I hope this covers what you need.

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

#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 413, 298, 303, 219)
$Edit1 = GUICtrlCreateEdit("", 112, 40, 185, 89)
GUICtrlSetData(-1, "Edit1")
$Edit2 = GUICtrlCreateEdit("", 112, 168, 185, 89)
GUICtrlSetData(-1, "Edit2")
$Label1 = GUICtrlCreateLabel("Label1", 32, 8, 100, 17)
$Label2 = GUICtrlCreateLabel("Label2", 48, 144, 124, 17)
$dum = GUICtrlCreateDummy()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "ED_WM_COMMAND");to catch focus change for the edit
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $dum
            msgbox(262144,"Event","Edit1 lost focus")

    EndSwitch
WEnd


Func ED_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $iCode = BitShift($wParam, 16)
    Switch $lParam
        Case GUICtrlGetHandle($Edit1)
            Switch $iCode
                Case $EN_KILLFOCUS
                    GUICtrlSetData($Label1, "Edit1 lost focus")
                    GUICtrlSendToDummy($dum);so we can detect it in our message loop
                Case $EN_SETFOCUS
                    GUICtrlSetData($Label1, "Edit1 has focus")
            EndSwitch
        Case GUICtrlGetHandle($Edit2)
            Switch $iCode
                Case $EN_KILLFOCUS
                    GUICtrlSetData($Label2, "Edit2 lost focus")
                Case $EN_SETFOCUS
                    GUICtrlSetData($Label2, "Edit2 has focus")
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc  ;==>ED_WM_COMMAND

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I think I am completely confused as to how it works but yes it does what I need.

I was actually looking at GUIRegisterMsg earlier but I couldn't figure out how to use it.

I'll go your code carefully later and hopefully learn something.

Thanks alot :)

Kenny

Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

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