Jump to content

WinSetPresParam

From EDM2
Revision as of 03:03, 9 April 2025 by Martini (talk | contribs) (Created page with "This function ''sets a presentation parameter for a window''. ==Syntax== WinSetPresParam(hwnd, idAttrType, cbAttrValueLen, pAttrValue) ==Parameters== ;hwnd (HWND) - Input : Window handle. : This is the window to which changes of the presentation parameters are to be applied. ;idAttrType (ULONG) - Input : Type of presentation parameter attribute to be set. : This parameter can be set to one of the following system-defined presentation parameter attribute types...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function sets a presentation parameter for a window.

Syntax

WinSetPresParam(hwnd, idAttrType, cbAttrValueLen, pAttrValue)

Parameters

hwnd (HWND) - Input
Window handle.
This is the window to which changes of the presentation parameters are to be applied.
idAttrType (ULONG) - Input
Type of presentation parameter attribute to be set.
This parameter can be set to one of the following system-defined presentation parameter attribute types or an application-defined type:
PP_FOREGROUNDCOLOR
Foreground color (in RGB) attribute.
PP_BACKGROUNDCOLOR
Background color (in RGB) attribute.
PP_FOREGROUNDCOLORINDEX
Foreground color index attribute.
PP_BACKGROUNDCOLORINDEX
Background color index attribute.
PP_HILITEFOREGROUNDCOLOR
Highlighted foreground color (in RGB) attribute, for example for selected menu items.
PP_HILITEBACKGROUNDCOLOR
Highlighted background color (in RGB) attribute.
PP_HILITEFOREGROUNDCOLORINDEX
Highlighted foreground color index attribute.
PP_HILITEBACKGROUNDCOLORINDEX
Highlighted background color index attribute.
PP_DISABLEDFOREGROUNDCOLOR
Disabled foreground color (in RGB) attribute.
PP_DISABLEDBACKGROUNDCOLOR
Disabled background color (in RGB) attribute.
PP_DISABLEDFOREGROUNDCOLORINDEX
Disabled foreground color index attribute.
PP_DISABLEDBACKGROUNDCOLORINDEX
Disabled background color index attribute.
PP_BORDERCOLOR
Border color (in RGB) attribute.
PP_BORDERCOLORINDEX
Border color index attribute.
PP_FONTNAMESIZE
Font name and size attribute.
PP_ACTIVECOLOR
Active color value of data type RGB.
PP_ACTIVECOLORINDEX
Active color index value of data type LONG.
PP_INACTIVECOLOR
Inactive color value of data type RGB.
PP_INACTIVECOLORINDEX
Inactive color index value of data type LONG.
PP_ACTIVETEXTFGNDCOLOR
Active text foreground color value of data type RGB.
PP_ACTIVETEXTFGNDCOLORINDEX
Active text foreground color index value of data type LONG.
PP_ACTIVETEXTBGNDCOLOR
Active text background color value of data type RGB.
PP_ACTIVETEXTBGNDCOLORINDEX
Active text background color index value of data type LONG.
PP_INACTIVETEXTFGNDCOLOR
Inactive text foreground color value of data type RGB.
PP_INACTIVETEXTFGNDCOLORINDEX
Inactive text foreground color index value of data type LONG.
PP_INACTIVETEXTBGNDCOLOR
Inactive text background color value of data type RGB.
PP_INACTIVETEXTBGNDCOLORINDEX
Inactive text background color index value of data type LONG.
PP_SHADOW
Changes the color used for drop shadows on certain controls.
PP_USER
This is a user-defined presentation parameter.
cbAttrValueLen (ULONG) - Input
Size of the buffer pointed to by the pAttrValue parameter.
pAttrValue (PVOID) - Input
Pointer to the presentation parameter's data.

Returns

rc (BOOL) - returns
Success indicator.
TRUE
Successful completion
FALSE
Error occurred.

Remarks

This function associates the presentation parameter attribute identified by idAttrType with the window hwnd. If the attribute already exists for the window, its value is changed to the new value specified by pAttrValue. If the attribute does not exist, it is added to the window's presentation parameters, with the specified value. (See also WinQueryPresParam and WinRemovePresParam.) When a presentation parameter is set, a WM_PRESPARAMCHANGED message is sent to all windows owned by the window calling the WinSetPresParam function. When switching from using color indexes to using RGB color values, you must call GpiCreateLogColorTable with the LCOLF_RGB parameter. Otherwise, this function will treat the RGB color passed as an index into a color table, rather than as an absolute color value.

Errors

Possible returns from WinGetLastError:

PMERR_INVALID_HWND (0x1001)
An invalid window handle was specified.

Example Code

#define INCL_WINSYS /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HWND     hwnd;            /*  Window handle. */
ULONG    idAttrType;      /*  Type of presentation parameter attribute to be set. */
ULONG    cbAttrValueLen;  /*  Size of the buffer pointed to by the pAttrValue parameter. */
PVOID    pAttrValue;      /*  Pointer to the presentation parameter's data. */
BOOL     rc;              /*  Success indicator. */

rc = WinSetPresParam(hwnd, idAttrType, cbAttrValueLen, pAttrValue);

This example changes the border color to blue.

#define INCL_WINSYS
#define INCL_GPIBITMAPS  /* for RGB2 structure definition */
#include <OS2.H>

HWND hwnd;
RGB2 rgb2;   /* Red, green, and blue color index */
rgb2.bBlue = 200;
rgb2.bGreen = 10;
rgb2.bRed = 5;
rgb2.fcOptions = 0;

WinSetPresParam(hwnd,
                PP_BORDERCOLOR,
                (ULONG)sizeof(RGB2),
                (PVOID)&rgb2);

This example changes the font to 18-point Courier. Note that the length parameter includes 10 characters for the font name and 1 for a null terminator.

#define INCL_WINSYS
#define INCL_GPIBITMAPS /* for RGB structure definition */
#include <OS2.H>

HWND hwnd;

WinSetPresParam(hwnd,
                PP_FONTNAMESIZE,
                11,
                (PVOID)"18.Courier");

Related Functions