Hacked stdio functions to use Win32 file handles. Still needs a proper
[wine/multimedia.git] / libtest / new.c
blob67f68f5ddd801ba1a55ba7bedebabbfc56bb858f
1 #include <windows.h>
3 HANDLE ghInstance;
6 long FAR PASCAL WndProc (HWND, WORD, WPARAM, LPARAM);
7 long FAR PASCAL ChildProc(HWND, WORD, WPARAM, LPARAM);
9 int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
10 LPSTR lpszCmdParam, int nCmdShow)
12 char szAppName[] = "ClassLook" ;
13 HWND hwnd ;
14 MSG msg ;
15 WNDCLASS wndclass ;
17 ghInstance = hInstance;
18 if (!hPrevInstance)
20 wndclass.style = CS_HREDRAW | CS_VREDRAW ;
21 wndclass.lpfnWndProc = WndProc ;
22 wndclass.cbClsExtra = 0 ;
23 wndclass.cbWndExtra = 0 ;
24 wndclass.hInstance = hInstance ;
25 wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
26 wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
27 wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
28 wndclass.lpszMenuName = NULL ;
29 wndclass.lpszClassName = szAppName ;
31 RegisterClass (&wndclass) ;
34 hwnd = CreateWindow (szAppName, /* window class name */
35 szAppName, /* window caption */
36 WS_OVERLAPPEDWINDOW, /* window style */
37 CW_USEDEFAULT, /* initial x position */
38 CW_USEDEFAULT, /* initial y position */
39 600, /* initial x size */
40 400, /* initial y size */
41 NULL, /* parent window handle */
42 NULL, /* window menu handle */
43 hInstance, /* program instance handle */
44 NULL) ; /* creation parameters */
46 ShowWindow (hwnd, nCmdShow) ;
47 UpdateWindow (hwnd) ;
49 while (GetMessage (&msg, NULL, 0, 0))
51 TranslateMessage (&msg) ;
52 DispatchMessage (&msg) ;
54 return msg.wParam ;
57 long FAR PASCAL WndProc (HWND hwnd, WORD message, WPARAM wParam, LPARAM lParam)
59 HDC hdc ;
60 PAINTSTRUCT ps ;
61 RECT rect ;
62 WNDCLASS wndclass ;
63 char clsName[] = "SecondClass";
65 static HWND hChild;
67 switch (message)
69 case WM_CREATE :
70 wndclass.style = CS_PARENTDC | CS_HREDRAW | CS_VREDRAW;
71 wndclass.lpfnWndProc = ChildProc ;
72 wndclass.cbClsExtra = 0 ;
73 wndclass.cbWndExtra = 0 ;
74 wndclass.hInstance = ghInstance ;
75 wndclass.hIcon = NULL ;
76 wndclass.hCursor = LoadCursor (NULL, IDC_CROSS) ;
77 wndclass.hbrBackground = GetStockObject (LTGRAY_BRUSH) ;
78 wndclass.lpszMenuName = NULL ;
79 wndclass.lpszClassName = clsName;
81 RegisterClass (&wndclass);
83 hChild = CreateWindow(clsName,"Child Window",
84 WS_CHILD | WS_VISIBLE | WS_BORDER,
85 10, 10, 580, 380, hwnd, NULL, ghInstance, NULL);
86 ShowWindow(hChild, SW_SHOW);
87 case WM_PAINT :
88 hdc = BeginPaint (hwnd, &ps) ;
90 GetClientRect (hwnd, &rect) ;
92 DrawText (hdc, "Hello, Windows!", -1, &rect,
93 DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
95 EndPaint (hwnd, &ps);
96 return 0 ;
98 case WM_DESTROY :
99 PostQuitMessage (0) ;
100 return 0 ;
102 return DefWindowProc (hwnd, message, wParam, lParam) ;
105 long FAR PASCAL ChildProc(HWND hwnd, WORD message, WPARAM wParam, LPARAM lParam)
107 HDC hDC;
108 PAINTSTRUCT ps;
109 WNDCLASS wndClass;
110 char *classes[]={"EDIT","BUTTON","LISTBOX","STATIC","SCROLLBAR","COMBOBOX","COMBOLBOX", NULL};
111 char** curr;
112 char buf[256];
113 RECT rect ;
114 int i;
116 switch (message) {
117 case WM_PAINT:
118 curr = classes;
119 i=0;
120 hDC = BeginPaint(hwnd, &ps);
121 SelectObject(hDC,GetStockObject(ANSI_FIXED_FONT));
122 while (*curr) {
123 wsprintf(buf,"%12s:",*curr);
124 GetClassInfo(NULL, *curr, &wndClass);
125 if(wndClass.style&CS_VREDRAW) lstrcat(buf," | CS_VREDRAW");
126 if(wndClass.style&CS_HREDRAW) lstrcat(buf," | CS_HREDRAW" );
127 if(wndClass.style&CS_KEYCVTWINDOW) lstrcat(buf," | CS_KEYCVTWINDOW" );
128 if(wndClass.style&CS_DBLCLKS) lstrcat(buf," | CS_DBLCLKS" );
129 if(wndClass.style&CS_OWNDC) lstrcat(buf," | CS_OWNDC" );
130 if(wndClass.style&CS_CLASSDC) lstrcat(buf," | CS_CLASSDC" );
131 if(wndClass.style&CS_PARENTDC) lstrcat(buf," | CS_PARENTDC" );
132 if(wndClass.style&CS_NOKEYCVT) lstrcat(buf," | CS_NOKEYCVT" );
133 if(wndClass.style&CS_NOCLOSE) lstrcat(buf," | CS_NOCLOSE" );
134 if(wndClass.style&CS_SAVEBITS) lstrcat(buf," | CS_SAVEBITS" );
135 if(wndClass.style&CS_GLOBALCLASS) lstrcat(buf," | CS_GLOBALCLASS");
136 GetClientRect (hwnd, &rect) ;
137 TextOut (hDC, 5,20+i,buf,lstrlen(buf)) ;
138 i += 15;
139 curr++;
141 /* EndPaint(hwnd, &ps);
142 break;
143 hDC = BeginPaint(hwnd, &ps);
145 MoveTo(hDC, 0, 0);
146 LineTo(hDC, 500, 500);
147 EndPaint(hwnd, &ps);
148 break;
149 default:
150 return DefWindowProc (hwnd, message, wParam, lParam) ;
152 return (0L);