Extended __wine_enter_vm86 to handle pending interrupts.
[wine/multimedia.git] / libtest / hello4.c
bloba633db29b39c130aded2bf9b8af94deff505c38e
1 #include <stdio.h>
2 #include <windows.h>
3 /* Win32 counterpart for CalcChildScroll16 is not implemented */
4 /* even in MS Visual C++ */
5 #include "windef.h"
6 #include "wingdi.h"
7 /*#include <wine/winuser16.h>*/
9 void Write (HDC dc, int x, int y, char *s)
11 SetBkMode(dc, TRANSPARENT);
12 TextOut (dc, x, y, s, strlen (s));
15 LRESULT CALLBACK WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
17 static short xChar, yChar;
18 static RECT rectHola;
19 static char* strHola = "Hola";
20 HDC dc;
21 PAINTSTRUCT ps;
22 TEXTMETRIC tm;
24 switch (msg){
25 case WM_CREATE:
26 dc = GetDC (wnd);
27 GetTextMetrics (dc, &tm);
28 xChar = tm.tmAveCharWidth;
29 yChar = tm.tmHeight;
30 GetTextExtentPoint32( dc, strHola, strlen(strHola), ((LPSIZE)&rectHola) + 1 );
31 OffsetRect( &rectHola, xChar, yChar );
32 ReleaseDC (wnd, dc);
33 break;
35 case WM_HSCROLL:
36 case WM_VSCROLL:
37 InvalidateRect(wnd, &rectHola, TRUE );
38 ScrollChildren(wnd, msg, w, l);
39 return 0;
41 case WM_PAINT:
42 dc = BeginPaint (wnd, &ps);
43 Write (dc, xChar, yChar, strHola);
44 EndPaint (wnd, &ps);
45 break;
47 case WM_DESTROY:
48 PostQuitMessage (0);
49 break;
51 default:
52 return DefWindowProc (wnd, msg, w, l);
54 return 0l;
57 LRESULT CALLBACK WndProc2 (HWND wnd, UINT msg, WPARAM w, LPARAM l)
59 static short xChar, yChar;
60 static RECT rectInfo;
61 char buf[128];
62 HDC dc;
63 PAINTSTRUCT ps;
64 TEXTMETRIC tm;
66 switch (msg){
67 case WM_CREATE:
68 dc = GetDC (wnd);
69 GetTextMetrics (dc, &tm);
70 xChar = tm.tmAveCharWidth;
71 yChar = tm.tmHeight;
72 ReleaseDC (wnd, dc);
73 break;
75 case WM_PAINT:
76 dc = BeginPaint (wnd, &ps);
77 sprintf(buf,"ps.rcPaint = {left = %d, top = %d, right = %d, bottom = %d}",
78 ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom);
79 rectInfo.left = rectInfo.top = 0;
80 GetTextExtentPoint32 (dc, buf, strlen(buf), ((LPSIZE)&rectInfo) + 1 );
81 OffsetRect (&rectInfo, xChar, yChar );
82 Write (dc, xChar, yChar, buf);
83 EndPaint (wnd, &ps);
84 break;
86 case WM_MOVE:
87 case WM_SIZE:
88 InvalidateRect( wnd, &rectInfo, TRUE );
89 /*CalcChildScroll16( (UINT16)GetParent(wnd), SB_BOTH );*/
90 break;
92 case WM_DESTROY:
93 PostQuitMessage (0);
94 break;
96 default:
97 return DefWindowProc (wnd, msg, w, l);
99 return 0l;
102 int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
104 HWND wnd,wnd2;
105 MSG msg;
106 WNDCLASS class;
107 char className[] = "class"; /* To make sure className >= 0x10000 */
108 char class2Name[] = "class2";
109 char winName[] = "Test app";
111 if (!prev){
112 class.style = CS_HREDRAW | CS_VREDRAW;
113 class.lpfnWndProc = WndProc;
114 class.cbClsExtra = 0;
115 class.cbWndExtra = 0;
116 class.hInstance = inst;
117 class.hIcon = LoadIcon (0, IDI_APPLICATION);
118 class.hCursor = LoadCursor (0, IDC_ARROW);
119 class.hbrBackground = GetStockObject (WHITE_BRUSH);
120 class.lpszMenuName = NULL;
121 class.lpszClassName = className;
122 if (!RegisterClass (&class))
123 return FALSE;
126 wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
127 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
128 0, inst, 0);
130 if (!prev){
131 class.lpfnWndProc = WndProc2;
132 class.lpszClassName = class2Name;
133 class.hbrBackground = GetStockObject(GRAY_BRUSH);
134 if (!RegisterClass (&class))
135 return FALSE;
138 wnd2= CreateWindow (class2Name,"Child window", WS_CAPTION | WS_CHILD | WS_THICKFRAME,
139 50, 50, 350, 100, wnd, 0, inst, 0);
141 ShowWindow (wnd, show);
142 UpdateWindow (wnd);
143 ShowWindow (wnd2, show);
144 UpdateWindow (wnd2);
146 while (GetMessage (&msg, 0, 0, 0)){
147 TranslateMessage (&msg);
148 DispatchMessage (&msg);
150 return 0;