Annotation of pmsdk/samples/petzold/chap12/resource.c, revision 1.1.1.1

1.1       root        1: /*-------------------------------------------------
                      2:    RESOURCE.C -- Uses an Icon and Pointer Resource
                      3:   -------------------------------------------------*/
                      4: 
                      5: #define INCL_WIN
                      6: #define INCL_GPI
                      7: #include <os2.h>
                      8: #include "resource.h"
                      9: 
                     10: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
                     11: 
                     12: int main (void)
                     13:      {
                     14:      static CHAR  szClientClass [] = "Resource" ;
                     15:      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU  |
                     16:                                  FCF_SIZEBORDER    | FCF_MINMAX   |
                     17:                                  FCF_SHELLPOSITION | FCF_TASKLIST |
                     18:                                  FCF_ICON ;
                     19:      HAB          hab ;
                     20:      HMQ          hmq ;
                     21:      HWND         hwndFrame, hwndClient ;
                     22:      QMSG         qmsg ;
                     23: 
                     24:      hab = WinInitialize (0) ;
                     25:      hmq = WinCreateMsgQueue (hab, 0) ;
                     26: 
                     27:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
                     28: 
                     29:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
                     30:                                      &flFrameFlags, szClientClass, NULL,
                     31:                                      0L, NULL, ID_RESOURCE, &hwndClient) ;
                     32: 
                     33:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
                     34:           WinDispatchMsg (hab, &qmsg) ;
                     35: 
                     36:      WinDestroyWindow (hwndFrame) ;
                     37:      WinDestroyMsgQueue (hmq) ;
                     38:      WinTerminate (hab) ;
                     39:      return 0 ;
                     40:      }
                     41: 
                     42: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     43:      {
                     44:      static HPOINTER hIcon, hptr ;
                     45:      static SHORT    cxClient, cyClient, cxIcon, cyIcon ;
                     46:      HPS             hps ;
                     47:      RECTL           rcl ;
                     48: 
                     49:      switch (msg)
                     50:           {
                     51:           case WM_CREATE:
                     52:                hIcon = WinLoadPointer (HWND_DESKTOP, NULL, ID_RESOURCE) ;
                     53:                hptr  = WinLoadPointer (HWND_DESKTOP, NULL, IDP_CIRCLE) ;
                     54: 
                     55:                cxIcon = (SHORT) WinQuerySysValue (HWND_DESKTOP, SV_CXICON) ;
                     56:                cyIcon = (SHORT) WinQuerySysValue (HWND_DESKTOP, SV_CYICON) ;
                     57:                return 0 ;
                     58: 
                     59:           case WM_SIZE:
                     60:                cxClient = SHORT1FROMMP (mp2) ;
                     61:                cyClient = SHORT2FROMMP (mp2) ;
                     62:                return 0 ;
                     63: 
                     64:           case WM_MOUSEMOVE:
                     65:                WinSetPointer (HWND_DESKTOP, hptr) ;
                     66:                return 1 ;
                     67: 
                     68:           case WM_PAINT:
                     69:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
                     70: 
                     71:                WinQueryWindowRect (hwnd, &rcl) ;
                     72:                WinFillRect (hps, &rcl, CLR_CYAN) ;
                     73: 
                     74:                WinDrawPointer (hps, 0, 0, hIcon, DP_NORMAL) ;
                     75:                WinDrawPointer (hps, 0, cyClient - cyIcon, hIcon, DP_NORMAL) ;
                     76:                WinDrawPointer (hps, cxClient - cyIcon, 0, hIcon, DP_NORMAL) ;
                     77:                WinDrawPointer (hps, cxClient - cxIcon, cyClient - cyIcon,
                     78:                                     hIcon, DP_NORMAL) ;
                     79: 
                     80:                WinDrawPointer (hps, cxClient / 3, cyClient / 2, hIcon,
                     81:                                                        DP_HALFTONED) ;
                     82:                WinDrawPointer (hps, 2 * cxClient / 3, cyClient / 2, hIcon,
                     83:                                                        DP_INVERTED) ;
                     84:                WinEndPaint (hps) ;
                     85:                return 0 ;
                     86: 
                     87:           case WM_DESTROY:
                     88:                WinDestroyPointer (hIcon) ;
                     89:                WinDestroyPointer (hptr) ;
                     90:                return 0 ;
                     91:           }
                     92:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                     93:      }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.