Annotation of pmsdk/samples/petzold/chap12/loadbmp2.c, revision 1.1

1.1     ! root        1: /*----------------------------------------------------
        !             2:    LOADBMP2.C -- Loads a Bitmap Resource and Draws it
        !             3:   ----------------------------------------------------*/
        !             4: 
        !             5: #define INCL_WIN
        !             6: #include <os2.h>
        !             7: #include "loadbmp.h"
        !             8: 
        !             9: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
        !            10: 
        !            11: int main (void)
        !            12:      {
        !            13:      static CHAR  szClientClass [] = "LoadBmp2" ;
        !            14:      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU |
        !            15:                                  FCF_SIZEBORDER    | FCF_MINMAX  |
        !            16:                                  FCF_SHELLPOSITION | FCF_TASKLIST ;
        !            17:      HAB          hab ;
        !            18:      HMQ          hmq ;
        !            19:      HWND         hwndFrame, hwndClient ;
        !            20:      QMSG         qmsg ;
        !            21: 
        !            22:      hab = WinInitialize (0) ;
        !            23:      hmq = WinCreateMsgQueue (hab, 0) ;
        !            24: 
        !            25:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
        !            26: 
        !            27:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
        !            28:                                      &flFrameFlags, szClientClass, NULL,
        !            29:                                      0L, NULL, 0, &hwndClient) ;
        !            30: 
        !            31:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
        !            32:           WinDispatchMsg (hab, &qmsg) ;
        !            33: 
        !            34:      WinDestroyWindow (hwndFrame) ;
        !            35:      WinDestroyMsgQueue (hmq) ;
        !            36:      WinTerminate (hab) ;
        !            37:      return 0 ;
        !            38:      }
        !            39: 
        !            40: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
        !            41:      {
        !            42:      static HBITMAP hbm ;
        !            43:      HPS            hps ;
        !            44:      RECTL          rcl ;
        !            45: 
        !            46:      switch (msg)
        !            47:           {
        !            48:           case WM_CREATE:
        !            49:                hps = WinGetPS (hwnd) ;
        !            50:                hbm = GpiLoadBitmap (hps, NULL, IDB_HELLO, 0L, 0L) ;
        !            51:                WinReleasePS (hps) ;
        !            52:                return 0 ;
        !            53: 
        !            54:           case WM_PAINT:
        !            55:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
        !            56:                GpiErase (hps) ;
        !            57: 
        !            58:                WinQueryWindowRect (hwnd, &rcl) ;
        !            59: 
        !            60:                if (hbm)
        !            61:                     WinDrawBitmap (hps, hbm, NULL, (PPOINTL) &rcl,
        !            62:                                    CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH) ;
        !            63: 
        !            64:                WinEndPaint (hps) ;
        !            65:                return 0 ;
        !            66: 
        !            67:           case WM_DESTROY:
        !            68:                if (hbm)
        !            69:                     GpiDeleteBitmap (hbm) ;               
        !            70:                return 0 ;
        !            71:           }
        !            72:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
        !            73:      }

unix.superglobalmegacorp.com

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