4 void Write (HDC dc
, int x
, int y
, char *s
)
6 TextOut (dc
, x
, y
, s
, strlen (s
));
9 LRESULT
WndProc (HWND wnd
, UINT msg
, WPARAM w
, LPARAM l
)
11 static short xChar
, yChar
;
19 GetTextMetrics (dc
, &tm
);
20 xChar
= tm
.tmAveCharWidth
;
26 dc
= BeginPaint (wnd
, &ps
);
27 Write (dc
, xChar
, yChar
, "Hola");
36 return DefWindowProc (wnd
, msg
, w
, l
);
41 LRESULT
WndProc2 (HWND wnd
, UINT msg
, WPARAM w
, LPARAM l
)
43 static short xChar
, yChar
;
52 GetTextMetrics (dc
, &tm
);
53 xChar
= tm
.tmAveCharWidth
;
59 dc
= BeginPaint (wnd
, &ps
);
60 sprintf(buf
,"ps.rcPaint = {left = %d, top = %d, right = %d, bottom = %d}",
61 ps
.rcPaint
.left
,ps
.rcPaint
.top
,ps
.rcPaint
.right
,ps
.rcPaint
.bottom
);
62 Write (dc
, xChar
, yChar
, buf
);
71 return DefWindowProc (wnd
, msg
, w
, l
);
76 int PASCAL
WinMain (HANDLE inst
, HANDLE prev
, LPSTR cmdline
, int show
)
81 char className
[] = "class"; /* To make sure className >= 0x10000 */
82 char class2Name
[] = "class2";
83 char winName
[] = "Test app";
86 class.style
= CS_HREDRAW
| CS_VREDRAW
;
87 class.lpfnWndProc
= WndProc
;
90 class.hInstance
= inst
;
91 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
92 class.hCursor
= LoadCursor (0, IDC_ARROW
);
93 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
94 class.lpszMenuName
= NULL
;
95 class.lpszClassName
= (SEGPTR
)className
;
96 if (!RegisterClass (&class))
100 wnd
= CreateWindow (className
, winName
, WS_OVERLAPPEDWINDOW
,
101 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, 0,
105 class.lpfnWndProc
= WndProc2
;
106 class.lpszClassName
= class2Name
;
107 if (!RegisterClass (&class))
111 wnd2
= CreateWindow (class2Name
,"Test app", WS_BORDER
| WS_CHILD
,
112 50, 50, 350, 50, wnd
, 0, inst
, 0);
114 ShowWindow (wnd
, show
);
116 ShowWindow (wnd2
, show
);
119 while (GetMessage (&msg
, 0, 0, 0)){
120 TranslateMessage (&msg
);
121 DispatchMessage (&msg
);