Kbase 17281: How to Call WIN32 API Function: ShowWindow
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to Call WIN32 API Function: ShowWindow
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 ShowWindow. This function sets a window's show state. The
show state determines how a window is displayed on the screen.
This code has been tested on Windows NT 4.0 Workstation only.
&SCOPED-DEFINE SW_HIDE 0
&SCOPED-DEFINE SW_SHOWNORMAL 1
&SCOPED-DEFINE SW_SHOWMINIMIZED 2
&SCOPED-DEFINE SW_SHOWMAXIMIZED 3
&SCOPED-DEFINE SW_SHOWNOACTIVATE 4
&SCOPED-DEFINE SW_SHOW 5
&SCOPED-DEFINE SW_MINIMIZE 6
&SCOPED-DEFINE SW_SHOWMINNOACTIVE 7
&SCOPED-DEFINE SW_SHOWNA 8
&SCOPED-DEFINE SW_RESTORE 9
&SCOPED-DEFINE SW_SHOWDEFAULT 10
DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
DEFINE VARIABLE intHwnd AS INTEGER NO-UNDO.
PROCEDURE ShowWindow EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER intHwnd AS LONG.
DEFINE INPUT PARAMETER intCmdShow 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", OUTPUT intHwnd).
IF intHwnd <> 0 THEN
DO:
RUN ShowWindow(intHwnd, {&SW_RESTORE}, OUTPUT intResult).
IF intResult = 1 THEN
MESSAGE "Window Already Visible" VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Call Worked" VIEW-AS ALERT-BOX.
END.
ELSE
MESSAGE "Could Not Find Window" VIEW-AS ALERT-BOX.
Progress Software Technical Support Note # 17281