Don't prepend '--' to the command line when starting a Windows binary.
[wine/multimedia.git] / libtest / hello4.c
blob485e417b842db85d20f305198d43df732142dd95
1 /*
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
19 #include <stdio.h>
20 #include <windows.h>
21 /* Win32 counterpart for CalcChildScroll16 is not implemented */
22 /* even in MS Visual C++ */
23 #include "windef.h"
24 #include "wingdi.h"
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;
36 static RECT rectHola;
37 static char* strHola = "Hola";
38 HDC dc;
39 PAINTSTRUCT ps;
40 TEXTMETRIC tm;
42 switch (msg){
43 case WM_CREATE:
44 dc = GetDC (wnd);
45 GetTextMetrics (dc, &tm);
46 xChar = tm.tmAveCharWidth;
47 yChar = tm.tmHeight;
48 GetTextExtentPoint32( dc, strHola, strlen(strHola), ((LPSIZE)&rectHola) + 1 );
49 OffsetRect( &rectHola, xChar, yChar );
50 ReleaseDC (wnd, dc);
51 break;
53 case WM_HSCROLL:
54 case WM_VSCROLL:
55 InvalidateRect(wnd, &rectHola, TRUE );
56 ScrollChildren(wnd, msg, w, l);
57 return 0;
59 case WM_PAINT:
60 dc = BeginPaint (wnd, &ps);
61 Write (dc, xChar, yChar, strHola);
62 EndPaint (wnd, &ps);
63 break;
65 case WM_DESTROY:
66 PostQuitMessage (0);
67 break;
69 default:
70 return DefWindowProc (wnd, msg, w, l);
72 return 0l;
75 LRESULT CALLBACK WndProc2 (HWND wnd, UINT msg, WPARAM w, LPARAM l)
77 static short xChar, yChar;
78 static RECT rectInfo;
79 char buf[128];
80 HDC dc;
81 PAINTSTRUCT ps;
82 TEXTMETRIC tm;
84 switch (msg){
85 case WM_CREATE:
86 dc = GetDC (wnd);
87 GetTextMetrics (dc, &tm);
88 xChar = tm.tmAveCharWidth;
89 yChar = tm.tmHeight;
90 ReleaseDC (wnd, dc);
91 break;
93 case WM_PAINT:
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);
101 EndPaint (wnd, &ps);
102 break;
104 case WM_MOVE:
105 case WM_SIZE:
106 InvalidateRect( wnd, &rectInfo, TRUE );
107 /*CalcChildScroll16( (UINT16)GetParent(wnd), SB_BOTH );*/
108 break;
110 case WM_DESTROY:
111 PostQuitMessage (0);
112 break;
114 default:
115 return DefWindowProc (wnd, msg, w, l);
117 return 0l;
120 int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
122 HWND wnd,wnd2;
123 MSG msg;
124 WNDCLASS class;
125 char className[] = "class"; /* To make sure className >= 0x10000 */
126 char class2Name[] = "class2";
127 char winName[] = "Test app";
129 if (!prev){
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))
141 return FALSE;
144 wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
145 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
146 0, inst, 0);
148 if (!prev){
149 class.lpfnWndProc = WndProc2;
150 class.lpszClassName = class2Name;
151 class.hbrBackground = GetStockObject(GRAY_BRUSH);
152 if (!RegisterClass (&class))
153 return FALSE;
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);
160 UpdateWindow (wnd);
161 ShowWindow (wnd2, show);
162 UpdateWindow (wnd2);
164 while (GetMessage (&msg, 0, 0, 0)){
165 TranslateMessage (&msg);
166 DispatchMessage (&msg);
168 return 0;