Use API Functions That Require Pointers to Arrays Sample
File: ...\Samples\Solution\Winapi\Syscolor.scx
This example uses two Windows API functions to first get the system color settings (GetSysColor) and then to reset the system colors to new values (SetSysColors). Two of the three arguments required by SetSysColors are pointers to native C arrays.
GetSysColor
The GetSysColor function accepts an integer parameter, a number between 0 and 18, and returns a DWORD (32-bit unsigned integer) indicating the current color setting.
DWORD GetSysColor(
int nIndex // display element
);
nIndex is a value representing an area of the interface, as defined in the following list:
#define COLOR_SCROLLBAR 0
#define COLOR_BACKGROUND 1
#define COLOR_ACTIVECAPTION 2
#define COLOR_INACTIVECAPTION 3
#define COLOR_MENU 4
#define COLOR_WINDOW 5
#define COLOR_WINDOWFRAME 6
#define COLOR_MENUTEXT 7
#define COLOR_WINDOWTEXT 8
#define COLOR_CAPTIONTEXT 9
#define COLOR_ACTIVEBORDER 10
#define COLOR_INACTIVEBORDER 11
#define COLOR_APPWORKSPACE 12
#define COLOR_HIGHLIGHT 13
#define COLOR_HIGHLIGHTTEXT 14
#define COLOR_BTNFACE 15
#define COLOR_BTNSHADOW 16
#define COLOR_GRAYTEXT 17
#define COLOR_BTNTEXT 18
#define COLOR_INACTIVECAPTIONTEXT 19
#define COLOR_BTNHIGHLIGHT 20
#if(WINVER >= 0x0400)
#define COLOR_3DDKSHADOW 21
#define COLOR_3DLIGHT 22
#define COLOR_INFOTEXT 23
#define COLOR_INFOBK 24
#define COLOR_DESKTOP COLOR_BACKGROUND
#define COLOR_3DFACE COLOR_BTNFACE
#define COLOR_3DSHADOW COLOR_BTNSHADOW
#define COLOR_3DHIGHLIGHT COLOR_BTNHIGHLIGHT
#define COLOR_3DHILIGHT COLOR_BTNHIGHLIGHT
#define COLOR_BTNHILIGHT COLOR_BTNHIGHLIGHT
#endif /* WINVER >= 0x0400 */
SetSysColors
The SetSysColors function requires three arguments: the number of elements in two arrays and the addresses of the two arrays.
BOOL WINAPI SetSysColors(
int cElements, // number of elements to change
CONST INT *lpaElements, // address of array of elements
CONST COLORREF *lpaRgbValues // address of array of RGB values
);
Calling SetSysColors in Visual FoxPro
The following code is extracted from cmdSetSysColors.Click:
DECLARE INTEGER SetSysColors IN win32api INTEGER, STRING, STRING
Construct the elements of the first array in a character variable.
cElements = ""
FOR i = 0 TO 18
cElements = cElements + THISFORM.DecToHex(i)
ENDFOR
Construct the elements of the second array in a character variable. The cursor that is scanned was filled with GetSysColor values in the Init of the form.
cColors = ""
SCAN
cColors = cColors + THISFORM.DecToHex(INT(color))
ENDSCAN
=SetSysColors(18,cElements,cColors)
See Also
Tasks
Use API Functions that Require a STRUCT Sample
Reference
Visual FoxPro Foundation Classes A-Z