Mention free Truetype font servers (Xfstt and xfsft).
[wine/dcerpc.git] / libtest / hello4.c
blob259d4554a39fd207c28007b369778ed6e56b95b6
1 #include <stdio.h>
2 #include <windows.h>
3 /* Win32 counterpart for CalcChildScroll16 is not implemented */
4 /* even in MS Visual C++ */
5 #include <wine/winuser16.h>
7 void Write (HDC dc, int x, int y, char *s)
9 SetBkMode(dc, TRANSPARENT);
10 TextOut (dc, x, y, s, strlen (s));
13 LRESULT CALLBACK WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
15 static short xChar, yChar;
16 static RECT rectHola;
17 static char* strHola = "Hola";
18 HDC dc;
19 PAINTSTRUCT ps;
20 TEXTMETRIC tm;
22 switch (msg){
23 case WM_CREATE:
24 dc = GetDC (wnd);
25 GetTextMetrics (dc, &tm);
26 xChar = tm.tmAveCharWidth;
27 yChar = tm.tmHeight;
28 GetTextExtentPoint32( dc, strHola, strlen(strHola), ((LPSIZE)&rectHola) + 1 );
29 OffsetRect( &rectHola, xChar, yChar );
30 ReleaseDC (wnd, dc);
31 break;
33 case WM_HSCROLL:
34 case WM_VSCROLL:
35 InvalidateRect(wnd, &rectHola, TRUE );
36 ScrollChildren(wnd, msg, w, l);
37 return 0;
39 case WM_PAINT:
40 dc = BeginPaint (wnd, &ps);
41 Write (dc, xChar, yChar, strHola);
42 EndPaint (wnd, &ps);
43 break;
45 case WM_DESTROY:
46 PostQuitMessage (0);
47 break;
49 default:
50 return DefWindowProc (wnd, msg, w, l);
52 return 0l;
55 LRESULT CALLBACK WndProc2 (HWND wnd, UINT msg, WPARAM w, LPARAM l)
57 static short xChar, yChar;
58 static RECT rectInfo;
59 char buf[128];
60 HDC dc;
61 PAINTSTRUCT ps;
62 TEXTMETRIC tm;
64 switch (msg){
65 case WM_CREATE:
66 dc = GetDC (wnd);
67 GetTextMetrics (dc, &tm);
68 xChar = tm.tmAveCharWidth;
69 yChar = tm.tmHeight;
70 ReleaseDC (wnd, dc);
71 break;
73 case WM_PAINT:
74 dc = BeginPaint (wnd, &ps);
75 sprintf(buf,"ps.rcPaint = {left = %d, top = %d, right = %d, bottom = %d}",
76 ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom);
77 rectInfo.left = rectInfo.top = 0;
78 GetTextExtentPoint32 (dc, buf, strlen(buf), ((LPSIZE)&rectInfo) + 1 );
79 OffsetRect (&rectInfo, xChar, yChar );
80 Write (dc, xChar, yChar, buf);
81 EndPaint (wnd, &ps);
82 break;
84 case WM_MOVE:
85 case WM_SIZE:
86 InvalidateRect( wnd, &rectInfo, TRUE );
87 CalcChildScroll16( (UINT16)GetParent(wnd), SB_BOTH );
88 break;
90 case WM_DESTROY:
91 PostQuitMessage (0);
92 break;
94 default:
95 return DefWindowProc (wnd, msg, w, l);
97 return 0l;
100 int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
102 HWND wnd,wnd2;
103 MSG msg;
104 WNDCLASS class;
105 char className[] = "class"; /* To make sure className >= 0x10000 */
106 char class2Name[] = "class2";
107 char winName[] = "Test app";
109 if (!prev){
110 class.style = CS_HREDRAW | CS_VREDRAW;
111 class.lpfnWndProc = WndProc;
112 class.cbClsExtra = 0;
113 class.cbWndExtra = 0;
114 class.hInstance = inst;
115 class.hIcon = LoadIcon (0, IDI_APPLICATION);
116 class.hCursor = LoadCursor (0, IDC_ARROW);
117 class.hbrBackground = GetStockObject (WHITE_BRUSH);
118 class.lpszMenuName = NULL;
119 class.lpszClassName = className;
120 if (!RegisterClass (&class))
121 return FALSE;
124 wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
125 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
126 0, inst, 0);
128 if (!prev){
129 class.lpfnWndProc = WndProc2;
130 class.lpszClassName = class2Name;
131 class.hbrBackground = GetStockObject(GRAY_BRUSH);
132 if (!RegisterClass (&class))
133 return FALSE;
136 wnd2= CreateWindow (class2Name,"Child window", WS_CAPTION | WS_CHILD | WS_THICKFRAME,
137 50, 50, 350, 100, wnd, 0, inst, 0);
139 ShowWindow (wnd, show);
140 UpdateWindow (wnd);
141 ShowWindow (wnd2, show);
142 UpdateWindow (wnd2);
144 while (GetMessage (&msg, 0, 0, 0)){
145 TranslateMessage (&msg);
146 DispatchMessage (&msg);
148 return 0;