Consultor Eletrônico



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

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 code sample shows how to call the Win32 API function
called BringWindowToTop. This function brings a window to the top and
superimposes it over other overlapping windows on the screen. The
window is activated if it is a pop-up or top-level window. You will
most commonly use BringWindowToTop() to bring pop-up windows in front
of other windows and activate them for user input.

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


DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
DEFINE VARIABLE intHwnd AS INTEGER NO-UNDO.

PROCEDURE BringWindowToTop EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER intHwnd AS LONG.
DEFINE RETURN PARAMETER intResult AS LONG.
END PROCEDURE.

PROCEDURE FindWindowA EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER intClassName AS LONG.
DEFINE INPUT PARAMETER intCaption AS CHARACTER.
DEFINE RETURN PARAMETER intHandle AS LONG.
END PROCEDURE.

RUN FindWindowA(0, "Some Window Title", OUTPUT intHwnd).

IF intHwnd <> 0 THEN
DO:
RUN BringWindowToTop(intHwnd, OUTPUT intResult).
IF intResult = 1 THEN
MESSAGE "Window Brought To Top" VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Window Not Brought To Top" VIEW-AS ALERT-BOX.
END.
ELSE
MESSAGE "Could Not Find Window" VIEW-AS ALERT-BOX.

Progress Software Technical Support Note # 17258