|
|
1.1 root 1: /*----------------------------------------------------
2: LOADBMP2.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 [] = "LoadBmp2" ;
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 HBITMAP hbm ;
47: HPS hps ;
48: RECTL rcl ;
49:
50: switch (msg)
51: {
52: case WM_CREATE:
53: hps = WinGetPS (hwnd) ;
54: hbm = GpiLoadBitmap (hps, NULL, IDB_HELLO, 0L, 0L) ;
55: WinReleasePS (hps) ;
56: return 0 ;
57:
58: case WM_PAINT:
59: hps = WinBeginPaint (hwnd, NULL, NULL) ;
60:
61: WinQueryWindowRect (hwnd, &rcl) ;
62:
63: if (hbm)
64: WinDrawBitmap (hps, hbm, NULL, (PPOINTL) &rcl,
65: CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH) ;
66:
67: WinEndPaint (hps) ;
68: return 0 ;
69:
70: case WM_DESTROY:
71: if (hbm)
72: GpiDeleteBitmap (hbm) ;
73: return 0 ;
74: }
75: return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
76: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.