home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol12n03.zip / SYSICONS.C < prev    next >
Text File  |  1993-01-14  |  2KB  |  84 lines

  1. #include <windows.h>
  2.  
  3. long FAR PASCAL WndProc (HWND, WORD, WORD, LONG);
  4.  
  5. /**********************************************************
  6.   WinMain starts the program.
  7.  **********************************************************/
  8.  
  9. int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
  10.                     LPSTR lpszCmdLine, int nCmdShow)
  11. {
  12.     static char szClassName[] = "SysIcons";
  13.     WNDCLASS wndclass;
  14.     HWND hwnd;
  15.     MSG msg;
  16.  
  17.     if (!hPrevInstance) {
  18.         wndclass.style = 0;
  19.         wndclass.lpfnWndProc = (WNDPROC) WndProc;
  20.         wndclass.cbClsExtra = 0;
  21.         wndclass.cbWndExtra = 0;
  22.         wndclass.hInstance = hInstance;
  23.         wndclass.hIcon = LoadIcon (NULL, IDI_ASTERISK);
  24.         wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
  25.         wndclass.hbrBackground = (HBRUSH) COLOR_APPWORKSPACE + 1;
  26.         wndclass.lpszMenuName = (LPCSTR) NULL;
  27.         wndclass.lpszClassName = szClassName;
  28.  
  29.         RegisterClass (&wndclass);
  30.     }
  31.  
  32.     hwnd = CreateWindow (szClassName,
  33.             "System Icons", WS_OVERLAPPEDWINDOW,
  34.             CW_USEDEFAULT, CW_USEDEFAULT,
  35.             CW_USEDEFAULT, CW_USEDEFAULT,
  36.             NULL, NULL, hInstance, NULL);
  37.  
  38.     ShowWindow (hwnd, nCmdShow);
  39.     UpdateWindow (hwnd);
  40.  
  41.     while (GetMessage (&msg, NULL, 0, 0))
  42.             DispatchMessage (&msg);
  43.  
  44.     return msg.wParam;
  45. }
  46.  
  47. /**********************************************************
  48.   WndProc processes messages to the main window.
  49.  **********************************************************/
  50.  
  51. long FAR PASCAL WndProc (HWND hwnd, WORD message,
  52.                          WORD wParam, LONG lParam)
  53. {
  54.     static HICON hIcon[5];
  55.     PAINTSTRUCT ps;
  56.     HDC hdc;
  57.     int i;
  58.  
  59.     switch (message) {
  60.  
  61.     case WM_CREATE:
  62.         // Obtain handles to the five system icons
  63.         hIcon[0] = LoadIcon (NULL, IDI_APPLICATION);
  64.         hIcon[1] = LoadIcon (NULL, IDI_EXCLAMATION);
  65.         hIcon[2] = LoadIcon (NULL, IDI_ASTERISK);
  66.         hIcon[3] = LoadIcon (NULL, IDI_HAND);
  67.         hIcon[4] = LoadIcon (NULL, IDI_QUESTION);
  68.         return 0;
  69.  
  70.     case WM_PAINT:
  71.         // Draw the icons
  72.         hdc = BeginPaint (hwnd, &ps);
  73.         for (i=0; i<5; i++)
  74.             DrawIcon (hdc, (i*72)+32, 32, hIcon[i]);
  75.         EndPaint (hwnd, &ps);
  76.         return 0;
  77.  
  78.     case WM_DESTROY:
  79.         PostQuitMessage (0);
  80.         return 0;
  81.     }
  82.     return DefWindowProc (hwnd, message, wParam, lParam);
  83. }
  84.