4 void Write (HDC dc
, int x
, int y
, char *s
)
6 SetBkMode(dc
, TRANSPARENT
);
7 TextOut (dc
, x
, y
, s
, strlen (s
));
10 LRESULT
WndProc (HWND wnd
, UINT msg
, WPARAM w
, LPARAM l
)
12 static short xChar
, yChar
;
14 static char* strHola
= "Hola";
22 GetTextMetrics (dc
, &tm
);
23 xChar
= tm
.tmAveCharWidth
;
25 GetTextExtentPoint32( dc
, strHola
, strlen(strHola
), ((LPSIZE
)&rectHola
) + 1 );
26 OffsetRect( &rectHola
, xChar
, yChar
);
32 InvalidateRect(wnd
, &rectHola
, TRUE
);
33 ScrollChildren(wnd
, msg
, w
, l
);
37 dc
= BeginPaint (wnd
, &ps
);
38 Write (dc
, xChar
, yChar
, strHola
);
47 return DefWindowProc (wnd
, msg
, w
, l
);
52 LRESULT
WndProc2 (HWND wnd
, UINT msg
, WPARAM w
, LPARAM l
)
54 static short xChar
, yChar
;
64 GetTextMetrics (dc
, &tm
);
65 xChar
= tm
.tmAveCharWidth
;
71 dc
= BeginPaint (wnd
, &ps
);
72 sprintf(buf
,"ps.rcPaint = {left = %d, top = %d, right = %d, bottom = %d}",
73 ps
.rcPaint
.left
,ps
.rcPaint
.top
,ps
.rcPaint
.right
,ps
.rcPaint
.bottom
);
74 rectInfo
.left
= rectInfo
.top
= 0;
75 GetTextExtentPoint32 (dc
, buf
, strlen(buf
), ((LPSIZE
)&rectInfo
) + 1 );
76 OffsetRect (&rectInfo
, xChar
, yChar
);
77 Write (dc
, xChar
, yChar
, buf
);
83 InvalidateRect( wnd
, &rectInfo
, TRUE
);
84 CalcChildScroll16( (UINT16
)GetParent(wnd
), SB_BOTH
);
92 return DefWindowProc (wnd
, msg
, w
, l
);
97 int PASCAL
WinMain (HANDLE inst
, HANDLE prev
, LPSTR cmdline
, int show
)
102 char className
[] = "class"; /* To make sure className >= 0x10000 */
103 char class2Name
[] = "class2";
104 char winName
[] = "Test app";
107 class.style
= CS_HREDRAW
| CS_VREDRAW
;
108 class.lpfnWndProc
= WndProc
;
109 class.cbClsExtra
= 0;
110 class.cbWndExtra
= 0;
111 class.hInstance
= inst
;
112 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
113 class.hCursor
= LoadCursor (0, IDC_ARROW
);
114 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
115 class.lpszMenuName
= NULL
;
116 class.lpszClassName
= (SEGPTR
)className
;
117 if (!RegisterClass (&class))
121 wnd
= CreateWindow (className
, winName
, WS_OVERLAPPEDWINDOW
| WS_CLIPCHILDREN
| WS_VSCROLL
| WS_HSCROLL
,
122 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, 0,
126 class.lpfnWndProc
= WndProc2
;
127 class.lpszClassName
= class2Name
;
128 class.hbrBackground
= GetStockObject(GRAY_BRUSH
);
129 if (!RegisterClass (&class))
133 wnd2
= CreateWindow (class2Name
,"Child window", WS_CAPTION
| WS_CHILD
| WS_THICKFRAME
,
134 50, 50, 350, 100, wnd
, 0, inst
, 0);
136 ShowWindow (wnd
, show
);
138 ShowWindow (wnd2
, show
);
141 while (GetMessage (&msg
, 0, 0, 0)){
142 TranslateMessage (&msg
);
143 DispatchMessage (&msg
);