Release 960225
[wine/multimedia.git] / libtest / hello4.c
blob9e8f8001d79b217f0f0651db111aae1f8fd5bd39
1 #include <stdio.h>
2 #include <windows.h>
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;
12 HDC dc;
13 PAINTSTRUCT ps;
14 TEXTMETRIC tm;
16 switch (msg){
17 case WM_CREATE:
18 dc = GetDC (wnd);
19 GetTextMetrics (dc, &tm);
20 xChar = tm.tmAveCharWidth;
21 yChar = tm.tmHeight;
22 ReleaseDC (wnd, dc);
23 break;
25 case WM_PAINT:
26 dc = BeginPaint (wnd, &ps);
27 Write (dc, xChar, yChar, "Hola");
28 EndPaint (wnd, &ps);
29 break;
31 case WM_DESTROY:
32 PostQuitMessage (0);
33 break;
35 default:
36 return DefWindowProc (wnd, msg, w, l);
38 return 0l;
41 LRESULT WndProc2 (HWND wnd, UINT msg, WPARAM w, LPARAM l)
43 static short xChar, yChar;
44 char buf[128];
45 HDC dc;
46 PAINTSTRUCT ps;
47 TEXTMETRIC tm;
49 switch (msg){
50 case WM_CREATE:
51 dc = GetDC (wnd);
52 GetTextMetrics (dc, &tm);
53 xChar = tm.tmAveCharWidth;
54 yChar = tm.tmHeight;
55 ReleaseDC (wnd, dc);
56 break;
58 case WM_PAINT:
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);
63 EndPaint (wnd, &ps);
64 break;
66 case WM_DESTROY:
67 PostQuitMessage (0);
68 break;
70 default:
71 return DefWindowProc (wnd, msg, w, l);
73 return 0l;
76 int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
78 HWND wnd,wnd2;
79 MSG msg;
80 WNDCLASS class;
82 if (!prev){
83 class.style = CS_HREDRAW | CS_VREDRAW;
84 class.lpfnWndProc = WndProc;
85 class.cbClsExtra = 0;
86 class.cbWndExtra = 0;
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))
94 return FALSE;
97 wnd = CreateWindow ("class", "Test app", WS_OVERLAPPEDWINDOW,
98 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
99 0, inst, 0);
101 if (!prev){
102 class.lpfnWndProc = WndProc2;
103 class.lpszClassName = (SEGPTR)"class2";
104 if (!RegisterClass (&class))
105 return FALSE;
108 wnd2= CreateWindow ("class2","Test app", WS_BORDER | WS_CHILD,
109 50, 50, 350, 50, wnd, 0, inst, 0);
111 ShowWindow (wnd, show);
112 UpdateWindow (wnd);
113 ShowWindow (wnd2, show);
114 UpdateWindow (wnd2);
116 while (GetMessage (&msg, 0, 0, 0)){
117 TranslateMessage (&msg);
118 DispatchMessage (&msg);
120 return 0;