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
)
83 class.style
= CS_HREDRAW
| CS_VREDRAW
;
84 class.lpfnWndProc
= WndProc
;
87 class.hInstance
= inst
;
88 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
89 class.hCursor
= LoadCursor (0, IDC_ARROW
);
90 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
91 class.lpszMenuName
= NULL
;
92 class.lpszClassName
= (SEGPTR
)"class";
93 if (!RegisterClass (&class))
97 wnd
= CreateWindow ("class", "Test app", WS_OVERLAPPEDWINDOW
,
98 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, 0,
102 class.lpfnWndProc
= WndProc2
;
103 class.lpszClassName
= (SEGPTR
)"class2";
104 if (!RegisterClass (&class))
108 wnd2
= CreateWindow ("class2","Test app", WS_BORDER
| WS_CHILD
,
109 50, 50, 350, 50, wnd
, 0, inst
, 0);
111 ShowWindow (wnd
, show
);
113 ShowWindow (wnd2
, show
);
116 while (GetMessage (&msg
, 0, 0, 0)){
117 TranslateMessage (&msg
);
118 DispatchMessage (&msg
);