Win32 API samples

This collection of code snippets used to be hosted on www.global-shared.com.
It is an old collection: it all began in 1996 or 1997, when Progress 8 was new and many of us were still using Windows 3.1 !!
Unlike wine or paintings, program code doesn't get better when it ages. You can find fragments that can be improved because Microsoft continuously expands their API, or are outdated because Progress has added features to the ABL so we don't need to use the WIN32 API anymore.


FlashWindowEx

You can use this function when you want the taskbar button to flash.

run FlashTray.
PROCEDURE FlashTray :
  DEFINE VARIABLE pfwi AS MEMPTR NO-UNDO.
  DEFINE VARIABLE hwndParent AS INTEGER NO-UNDO.
  RUN GetParent (CURRENT-WINDOW:HWND, OUTPUT hwndParent).
  SET-SIZE (pfwi)    = 20.
  PUT-LONG (pfwi, 1) = GET-SIZE(pfwi).
  PUT-LONG (pfwi, 5) = hwndParent.
  PUT-LONG (pfwi, 9) = 2.  /* = FLASW_TRAY */
  PUT-LONG (pfwi,13) = 3.  /* number of times to blink */
  PUT-LONG (pfwi,17) = 0.  /* blink rate in msec, 0=use system default */
  RUN FlashWindowEx ( pfwi ).
  SET-SIZE(pfwi)     = 0.

Center a window to the working area

A window is not automatically centered to the screen, but is cascaded.
This procedure takes the widget-handle of a window as input parameter and centers the window to the 'working area'.
The working area is the portion of the screen not overlapped by the taskbar. So the result will differ when you move the taskbar to either of the 4 edges of the screen.
Windows 98 and Windows 2000 support multiple monitors. The monitors share a virtual desktop but each monitor has its own working area. This procedure is improved to center the window to the monitor where it is positioned at that time. That is, if the window is positioned somewhere on the secondary monitor it will be centered to the secondary monitor too.


Disabling the Close button


Introduction

Author: Todd G. Nist, Protech Systems Inc.

The source code for the window as shown in the picture is attached: w-disablex.w.
When you want to disable the [X]-button in the title bar and also want to remove the 'Close'-option from the system menu, you only have to call this function from within the main block of the window:

{windows.i}
 
FUNCTION DisableWindowClose RETURNS LOGICAL
  ( /* parameter-definitions */ ) :
/*---------------------------------------
  Purpose:  
    Notes:  
-----------------------------------------*/

Appearance

.


#
Syndicate content