Annotation of pmsdk/samples/petzold/chap09/loadbmp1.c, revision 1.1

1.1     ! root        1: /*----------------------------------------------------
        !             2:    LOADBMP1.C -- Loads a Bitmap Resource and Draws it
        !             3:   ----------------------------------------------------*/
        !             4: 
        !             5: #define INCL_WIN
        !             6: #define INCL_GPI
        !             7: 
        !             8: #include <os2.h>
        !             9: #include <stddef.h>
        !            10: #include "loadbmp.h"
        !            11: 
        !            12: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
        !            13: 
        !            14: int main (void)
        !            15:      {
        !            16:      static CHAR szClientClass [] = "LoadBmp1" ;
        !            17:      HAB         hab ;
        !            18:      HMQ         hmq ;
        !            19:      HWND        hwndFrame, hwndClient ;
        !            20:      QMSG        qmsg ;
        !            21:      ULONG       flFrameFlags = FCF_STANDARD & ~FCF_MENU ;
        !            22:      ULONG       flFrameStyle = WS_VISIBLE ;
        !            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, flFrameStyle,
        !            30:                                      &flFrameFlags, szClientClass,
        !            31:                                      "Load and Draw a Bitmap",
        !            32:                                      0L, NULL, 0, &hwndClient) ;
        !            33: 
        !            34:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
        !            35:           WinDispatchMsg (hab, &qmsg) ;
        !            36: 
        !            37:      WinDestroyWindow (hwndFrame) ;
        !            38:      WinDestroyMsgQueue (hmq) ;
        !            39:      WinTerminate (hab) ;
        !            40: 
        !            41:      return 0 ;
        !            42:      }
        !            43: 
        !            44: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
        !            45:      {
        !            46:      static SHORT cxClient, cyClient ;
        !            47:      HBITMAP      hbm ;
        !            48:      HPS          hps ;
        !            49:      POINTL       ptl ;
        !            50: 
        !            51:      switch (msg)
        !            52:           {
        !            53:           case WM_SIZE:
        !            54:                cxClient = SHORT1FROMMP (mp2) ;
        !            55:                cyClient = SHORT2FROMMP (mp2) ;
        !            56:                return 0 ;
        !            57: 
        !            58:           case WM_PAINT:
        !            59:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
        !            60: 
        !            61:                hbm = GpiLoadBitmap (hps, NULL, IDB_HELLO,
        !            62:                                     (LONG) cxClient, (LONG) cyClient) ;
        !            63:                if (hbm)
        !            64:                     {
        !            65:                     ptl.x = 0 ;
        !            66:                     ptl.y = 0 ;
        !            67: 
        !            68:                     WinDrawBitmap (hps, hbm, NULL, &ptl,
        !            69:                                    CLR_NEUTRAL, CLR_BACKGROUND, DBM_NORMAL) ;
        !            70: 
        !            71:                     GpiDeleteBitmap (hbm) ;               
        !            72:                     }
        !            73:                WinEndPaint (hps) ;
        !            74:                return 0 ;
        !            75:           }
        !            76:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
        !            77:      }

unix.superglobalmegacorp.com

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