Added some CLSIDs.
[wine] / libtest / new.c
1 /*
2  * Copyright 1996 Jim Peterson
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <windows.h>
20
21 HANDLE ghInstance;
22
23
24 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
25 LRESULT CALLBACK ChildProc (HWND, UINT, WPARAM, LPARAM);
26
27 int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
28                     LPSTR lpszCmdParam, int nCmdShow)
29     {
30     char szAppName[] = "ClassLook" ;
31     HWND        hwnd ;
32     MSG         msg ;
33     WNDCLASS    wndclass ;
34
35     ghInstance = hInstance;
36     if (!hPrevInstance)
37          {
38          wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
39          wndclass.lpfnWndProc   = WndProc ;
40          wndclass.cbClsExtra    = 0 ;
41          wndclass.cbWndExtra    = 0 ;
42          wndclass.hInstance     = hInstance ;
43          wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
44          wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
45          wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
46          wndclass.lpszMenuName  = NULL ;
47          wndclass.lpszClassName = szAppName ;
48
49          RegisterClass (&wndclass) ;
50          }
51
52     hwnd = CreateWindow (szAppName,     /* window class name */
53                   szAppName,            /* window caption */
54                   WS_OVERLAPPEDWINDOW,  /* window style */
55                   CW_USEDEFAULT,        /* initial x position */
56                   CW_USEDEFAULT,        /* initial y position */
57                   600,  /* initial x size */
58                   400,  /* initial y size */
59                   NULL,                 /* parent window handle */
60                   NULL,                 /* window menu handle */
61                   hInstance,            /* program instance handle */
62                   NULL) ;               /* creation parameters */
63
64     ShowWindow (hwnd, nCmdShow) ;
65     UpdateWindow (hwnd) ;
66
67     while (GetMessage (&msg, NULL, 0, 0))
68          {
69          TranslateMessage (&msg) ;
70          DispatchMessage (&msg) ;
71          }
72     return msg.wParam ;
73     }
74
75 LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
76     {
77     HDC         hdc ;
78     PAINTSTRUCT ps ;
79     RECT        rect ;
80     WNDCLASS    wndclass ;
81     char clsName[] = "SecondClass";
82
83     static HWND hChild;
84
85     switch (message)
86          {
87          case WM_CREATE :
88              wndclass.style             = CS_PARENTDC | CS_HREDRAW | CS_VREDRAW;
89              wndclass.lpfnWndProc       = ChildProc ;
90              wndclass.cbClsExtra        = 0 ;
91              wndclass.cbWndExtra        = 0 ;
92              wndclass.hInstance         = ghInstance ;
93              wndclass.hIcon             = NULL ;
94              wndclass.hCursor           = LoadCursor (NULL, IDC_CROSS) ;
95              wndclass.hbrBackground     = GetStockObject (LTGRAY_BRUSH) ;
96              wndclass.lpszMenuName      = NULL ;
97              wndclass.lpszClassName     = clsName;
98
99              RegisterClass (&wndclass);
100               
101              hChild = CreateWindow(clsName,"Child Window",
102                  WS_CHILD | WS_VISIBLE | WS_BORDER,
103                  10, 10, 580, 380, hwnd, NULL, ghInstance, NULL);
104              ShowWindow(hChild, SW_SHOW);
105          case WM_PAINT :
106               hdc = BeginPaint (hwnd, &ps) ;
107
108               GetClientRect (hwnd, &rect) ;
109
110               DrawText (hdc, "Hello, Windows!", -1, &rect,
111                         DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
112
113               EndPaint (hwnd, &ps);
114               return 0 ;
115
116          case WM_DESTROY :
117               PostQuitMessage (0) ;
118               return 0 ;
119          }
120     return DefWindowProc (hwnd, message, wParam, lParam) ;
121     }
122
123 LRESULT CALLBACK ChildProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
124 {
125     HDC                 hDC;
126     PAINTSTRUCT         ps;
127     WNDCLASS            wndClass;
128     char                *classes[]={"EDIT","BUTTON","LISTBOX","STATIC","SCROLLBAR","COMBOBOX","COMBOLBOX", NULL};
129     char**              curr;
130     char                buf[256];
131     RECT        rect ;
132     int i;
133
134     switch (message) {
135         case WM_PAINT:
136             curr = classes;
137             i=0;
138             hDC = BeginPaint(hwnd, &ps);
139             SelectObject(hDC,GetStockObject(ANSI_FIXED_FONT));
140             while (*curr) {
141               wsprintf(buf,"%12s:",*curr);
142               GetClassInfo(NULL, *curr, &wndClass);
143               if(wndClass.style&CS_VREDRAW)  lstrcat(buf," | CS_VREDRAW");
144               if(wndClass.style&CS_HREDRAW)  lstrcat(buf," | CS_HREDRAW" );
145               if(wndClass.style&CS_KEYCVTWINDOW) lstrcat(buf," | CS_KEYCVTWINDOW" );
146               if(wndClass.style&CS_DBLCLKS) lstrcat(buf," | CS_DBLCLKS" );
147               if(wndClass.style&CS_OWNDC) lstrcat(buf," | CS_OWNDC" );
148               if(wndClass.style&CS_CLASSDC) lstrcat(buf," | CS_CLASSDC" );
149               if(wndClass.style&CS_PARENTDC) lstrcat(buf," | CS_PARENTDC" );
150               if(wndClass.style&CS_NOKEYCVT) lstrcat(buf," | CS_NOKEYCVT" );
151               if(wndClass.style&CS_NOCLOSE) lstrcat(buf," | CS_NOCLOSE" );
152               if(wndClass.style&CS_SAVEBITS) lstrcat(buf," | CS_SAVEBITS" );
153               if(wndClass.style&CS_GLOBALCLASS) lstrcat(buf," | CS_GLOBALCLASS");
154               GetClientRect (hwnd, &rect) ;
155               TextOut (hDC, 5,20+i,buf,lstrlen(buf)) ;
156               i += 15;
157               curr++;
158             }
159 /*            EndPaint(hwnd, &ps);
160             break;
161             hDC = BeginPaint(hwnd, &ps);
162 */
163             MoveToEx(hDC, 0, 0, NULL);
164             LineTo(hDC, 500, 500);
165             EndPaint(hwnd, &ps);
166             break;
167         default:
168             return DefWindowProc (hwnd, message, wParam, lParam) ;
169     }
170     return (0L);
171 }
172