2 * Copyright 1996 Jim Peterson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* Win32 counterpart for CalcChildScroll16 is not implemented */
22 /* even in MS Visual C++ */
25 /*#include <wine/winuser16.h>*/
27 void Write (HDC dc, int x, int y, char *s)
29 SetBkMode(dc, TRANSPARENT);
30 TextOut (dc, x, y, s, strlen (s));
33 LRESULT CALLBACK WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
35 static short xChar, yChar;
37 static char* strHola = "Hola";
45 GetTextMetrics (dc, &tm);
46 xChar = tm.tmAveCharWidth;
48 GetTextExtentPoint32( dc, strHola, strlen(strHola), ((LPSIZE)&rectHola) + 1 );
49 OffsetRect( &rectHola, xChar, yChar );
55 InvalidateRect(wnd, &rectHola, TRUE );
56 ScrollChildren(wnd, msg, w, l);
60 dc = BeginPaint (wnd, &ps);
61 Write (dc, xChar, yChar, strHola);
70 return DefWindowProc (wnd, msg, w, l);
75 LRESULT CALLBACK WndProc2 (HWND wnd, UINT msg, WPARAM w, LPARAM l)
77 static short xChar, yChar;
87 GetTextMetrics (dc, &tm);
88 xChar = tm.tmAveCharWidth;
94 dc = BeginPaint (wnd, &ps);
95 sprintf(buf,"ps.rcPaint = {left = %d, top = %d, right = %d, bottom = %d}",
96 ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom);
97 rectInfo.left = rectInfo.top = 0;
98 GetTextExtentPoint32 (dc, buf, strlen(buf), ((LPSIZE)&rectInfo) + 1 );
99 OffsetRect (&rectInfo, xChar, yChar );
100 Write (dc, xChar, yChar, buf);
106 InvalidateRect( wnd, &rectInfo, TRUE );
107 /*CalcChildScroll16( (UINT16)GetParent(wnd), SB_BOTH );*/
115 return DefWindowProc (wnd, msg, w, l);
120 int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
125 char className[] = "class"; /* To make sure className >= 0x10000 */
126 char class2Name[] = "class2";
127 char winName[] = "Test app";
130 class.style = CS_HREDRAW | CS_VREDRAW;
131 class.lpfnWndProc = WndProc;
132 class.cbClsExtra = 0;
133 class.cbWndExtra = 0;
134 class.hInstance = inst;
135 class.hIcon = LoadIcon (0, IDI_APPLICATION);
136 class.hCursor = LoadCursor (0, IDC_ARROW);
137 class.hbrBackground = GetStockObject (WHITE_BRUSH);
138 class.lpszMenuName = NULL;
139 class.lpszClassName = className;
140 if (!RegisterClass (&class))
144 wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
145 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
149 class.lpfnWndProc = WndProc2;
150 class.lpszClassName = class2Name;
151 class.hbrBackground = GetStockObject(GRAY_BRUSH);
152 if (!RegisterClass (&class))
156 wnd2= CreateWindow (class2Name,"Child window", WS_CAPTION | WS_CHILD | WS_THICKFRAME,
157 50, 50, 350, 100, wnd, 0, inst, 0);
159 ShowWindow (wnd, show);
161 ShowWindow (wnd2, show);
164 while (GetMessage (&msg, 0, 0, 0)){
165 TranslateMessage (&msg);
166 DispatchMessage (&msg);