home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / graphics / stsyscol.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  1.6 KB  |  49 lines

  1. /*
  2.  * This program demonstrates the use of SetSysColor(). In this example,
  3.  * the background desktop color of the current windows session is changed
  4.  * to black. This change is not permanent. If the background is already
  5.  * set to black, no change will be visible.
  6.  */
  7.  
  8. #include <windows.h>
  9.  
  10. #define MAXCOLORS         13
  11.  
  12. DWORD lpColorValues[MAXCOLORS];
  13. int lpSysColor[MAXCOLORS] = { COLOR_SCROLLBAR,
  14.                               COLOR_BACKGROUND,
  15.                               COLOR_ACTIVECAPTION,
  16.                               COLOR_INACTIVECAPTION,
  17.                               COLOR_MENU,
  18.                               COLOR_WINDOW,
  19.                               COLOR_WINDOWFRAME,
  20.                               COLOR_MENUTEXT,
  21.                               COLOR_WINDOWTEXT,
  22.                               COLOR_CAPTIONTEXT,
  23.                               COLOR_ACTIVEBORDER,
  24.                               COLOR_INACTIVEBORDER,
  25.                               COLOR_APPWORKSPACE };
  26.  
  27. int PASCAL WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
  28. HANDLE hInstance, hPrevInstance;
  29. LPSTR  lpszCmdLine;
  30. int    nCmdShow;
  31. {
  32.    int         i;
  33.  
  34.    MessageBox(GetFocus(), (LPSTR)"Setting Background Color to Black.",
  35.               (LPSTR)"SetSysColors()", MB_OK);
  36.    
  37.    for (i = 0; i < MAXCOLORS; i++)
  38.       lpColorValues[i] = GetSysColor(lpSysColor[i]);
  39.    
  40.    lpColorValues[COLOR_BACKGROUND] = RGB(0, 0, 0);
  41.    SetSysColors(MAXCOLORS, (int far *)lpSysColor, (long far *)lpColorValues);
  42.  
  43.    MessageBox(GetFocus(), (LPSTR)"Background Set For Current Session Only.",
  44.               (LPSTR)"SetSysColors()", MB_OK);
  45.  
  46.    return(0);
  47.  
  48. }
  49.