Generate Perl modules defining prototypes for exported functions.
[wine] / libtest / new.c
1 #include <windows.h>
2
3 HANDLE ghInstance;
4
5
6 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
7 LRESULT CALLBACK ChildProc (HWND, UINT, WPARAM, LPARAM);
8
9 int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
10                     LPSTR lpszCmdParam, int nCmdShow)
11     {
12     char szAppName[] = "ClassLook" ;
13     HWND        hwnd ;
14     MSG         msg ;
15     WNDCLASS    wndclass ;
16
17     ghInstance = hInstance;
18     if (!hPrevInstance)
19          {
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 ;
30
31          RegisterClass (&wndclass) ;
32          }
33
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 */
45
46     ShowWindow (hwnd, nCmdShow) ;
47     UpdateWindow (hwnd) ;
48
49     while (GetMessage (&msg, NULL, 0, 0))
50          {
51          TranslateMessage (&msg) ;
52          DispatchMessage (&msg) ;
53          }
54     return msg.wParam ;
55     }
56
57 LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
58     {
59     HDC         hdc ;
60     PAINTSTRUCT ps ;
61     RECT        rect ;
62     WNDCLASS    wndclass ;
63     char clsName[] = "SecondClass";
64
65     static HWND hChild;
66
67     switch (message)
68          {
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;
80
81              RegisterClass (&wndclass);
82               
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) ;
89
90               GetClientRect (hwnd, &rect) ;
91
92               DrawText (hdc, "Hello, Windows!", -1, &rect,
93                         DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
94
95               EndPaint (hwnd, &ps);
96               return 0 ;
97
98          case WM_DESTROY :
99               PostQuitMessage (0) ;
100               return 0 ;
101          }
102     return DefWindowProc (hwnd, message, wParam, lParam) ;
103     }
104
105 LRESULT CALLBACK ChildProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
106 {
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;
115
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++;
140             }
141 /*            EndPaint(hwnd, &ps);
142             break;
143             hDC = BeginPaint(hwnd, &ps);
144 */
145             MoveToEx(hDC, 0, 0, NULL);
146             LineTo(hDC, 500, 500);
147             EndPaint(hwnd, &ps);
148             break;
149         default:
150             return DefWindowProc (hwnd, message, wParam, lParam) ;
151     }
152     return (0L);
153 }
154