Jump to content

Alert when Control loses FOCUS


smahdi83
 Share

Recommended Posts

Hi,

How can I check if a certain textbox lost focus? Please this is really important and I have no clue on how to do that?

Thanks,

You could do it like this (assuming a textbox is an edit)-

#INCLUDE <GUICONSTANTS.AU3>
#include <constants.au3>
Global Const $WM_COMMAND = 0x0111
Global Const $EN_KILLFOCUS = 0x0200

$w1 = GUICreate('edit lost focus')

$edit1 = GUICtrlCreateEdit("some text", 20, 20, 120, 80)
$edit2 = GUICtrlCreateEdit("some text", 20, 120, 120, 80)
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState()

While GUIGetMsg() <> -3
WEnd


Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0xFFFF)
    Local $hCtrl = $lParam

    Switch $nID
        Case $edit1
            Switch $nNotifyCode
                Case $EN_KILLFOCUS
                    MsgBox(0, 'EDIT LOST FOCUS', 'from Edit1')
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_COMMAND

It's actually easy to find the notifications and messages for a control.

Have a look here.]

EDIT: Added link to msdn

Edited by martin
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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...