Function Reference


_WinAPI_HideCaret

Removes the caret from the screen

#include <WinAPIRes.au3>
_WinAPI_HideCaret ( $hWnd )

Parameters

$hWnd Handle to the window that owns the caret. If this parameter is 0, _WinAPI_HideCaret() searches the
current task for the window that owns the caret.

Return Value

Success: True.
Failure: False, call _WinAPI_GetLastError() to get extended error information.

Remarks

_WinAPI_HideCaret() hides the caret only if the specified window owns the caret. If the specified window does
not own the caret, _WinAPI_HideCaret() does nothing and returns 0.

Hiding is cumulative. If your application calls _WinAPI_HideCaret() five times in a row, it must also call
_WinAPI_ShowCaret() five times before the caret is displayed.

Related

_WinAPI_ShowCaret

See Also

Search HideCaret in MSDN Library.

Example

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIConv.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPIRes.au3>
#include <WindowsConstants.au3>

Global $g_vDuration = Default, $g_hBitmap = _WinAPI_CreateSolidBitmap(0, 0x00AEFF, 10, 14)

OnAutoItExitRegister('OnAutoItExit')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Exit', 165, 59, 70, 23)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)

While 1
        Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE, $idButton
                        ExitLoop
        EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
        #forceref $iMsg

        Switch $hWnd
                Case $hForm
                        Switch _WinAPI_LoWord($wParam)
                                Case $idInput
                                        Switch _WinAPI_HiWord($wParam)
                                                Case $EN_KILLFOCUS
                                                        _WinAPI_HideCaret($lParam)
                                                        _WinAPI_DestroyCaret()
                                                        _WinAPI_SetCaretBlinkTime($g_vDuration)
                                                        $g_vDuration = Default
                                                Case $EN_SETFOCUS
                                                        $g_vDuration = _WinAPI_SetCaretBlinkTime(-1)
                                                        _WinAPI_CreateCaret($lParam, $g_hBitmap)
                                                        _WinAPI_ShowCaret($lParam)
                                        EndSwitch
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func OnAutoItExit()
        _WinAPI_DeleteObject($g_hBitmap)
        If Not IsKeyword($g_vDuration) Then
                _WinAPI_SetCaretBlinkTime($g_vDuration)
        EndIf
EndFunc   ;==>OnAutoItExit