Consultor Eletrônico



Kbase 17595: How to Call WIN32 API Function: GetFocus
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to Call WIN32 API Function: GetFocus

DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.

INTRODUCTION:
=============
The following sample code shows how to call the Win32 API function
called GetFocus. This function retrieves the handle of the window
or control that currently has input focus. This is the window to
which any keyboard input that the user types is sent. If the calling
thread does not contain a window that has input focus, the return
value is null (i.e. zero).

This code has been tested on Windows NT 4.0 Workstation only.


DEFINE VARIABLE intHandle AS INTEGER NO-UNDO.

PROCEDURE GetFocus EXTERNAL "USER32.DLL":
DEFINE RETURN PARAMETER intHandle AS LONG.
END PROCEDURE.

RUN GetFocus(OUTPUT intHandle).

IF intHandle <> 0 THEN
MESSAGE "The Window Focus is " intHandle VIEW-AS ALERT-BOX.
ELSE
MESSAGE "No Window in this Program has Focus" VIEW-AS ALERT-BOX.

Progress Software Technical Support Note # 17595