Release 960506
[wine/multimedia.git] / libtest / hello4.c
blob964c52192ee5ed964caee6749a32dfa04eb052ec
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;
81 char className[] = "class"; /* To make sure className >= 0x10000 */
82 char class2Name[] = "class2";
83 char winName[] = "Test app";
85 if (!prev){
86 class.style = CS_HREDRAW | CS_VREDRAW;
87 class.lpfnWndProc = WndProc;
88 class.cbClsExtra = 0;
89 class.cbWndExtra = 0;
90 class.hInstance = inst;
91 class.hIcon = LoadIcon (0, IDI_APPLICATION);
92 class.hCursor = LoadCursor (0, IDC_ARROW);
93 class.hbrBackground = GetStockObject (WHITE_BRUSH);
94 class.lpszMenuName = NULL;
95 class.lpszClassName = (SEGPTR)className;
96 if (!RegisterClass (&class))
97 return FALSE;
100 wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW,
101 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
102 0, inst, 0);
104 if (!prev){
105 class.lpfnWndProc = WndProc2;
106 class.lpszClassName = class2Name;
107 if (!RegisterClass (&class))
108 return FALSE;
111 wnd2= CreateWindow (class2Name,"Test app", WS_BORDER | WS_CHILD,
112 50, 50, 350, 50, wnd, 0, inst, 0);
114 ShowWindow (wnd, show);
115 UpdateWindow (wnd);
116 ShowWindow (wnd2, show);
117 UpdateWindow (wnd2);
119 while (GetMessage (&msg, 0, 0, 0)){
120 TranslateMessage (&msg);
121 DispatchMessage (&msg);
123 return 0;