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
24 LRESULT CALLBACK
WndProc (HWND
, UINT
, WPARAM
, LPARAM
);
25 LRESULT CALLBACK
ChildProc (HWND
, UINT
, WPARAM
, LPARAM
);
27 int PASCAL
WinMain (HINSTANCE hInstance
, HINSTANCE hPrevInstance
,
28 LPSTR lpszCmdParam
, int nCmdShow
)
30 char szAppName
[] = "ClassLook" ;
35 ghInstance
= hInstance
;
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
;
49 RegisterClass (&wndclass
) ;
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 */
64 ShowWindow (hwnd
, nCmdShow
) ;
67 while (GetMessage (&msg
, NULL
, 0, 0))
69 TranslateMessage (&msg
) ;
70 DispatchMessage (&msg
) ;
75 LRESULT CALLBACK
WndProc (HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
81 char clsName
[] = "SecondClass";
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
;
99 RegisterClass (&wndclass
);
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
);
106 hdc
= BeginPaint (hwnd
, &ps
) ;
108 GetClientRect (hwnd
, &rect
) ;
110 DrawText (hdc
, "Hello, Windows!", -1, &rect
,
111 DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
) ;
113 EndPaint (hwnd
, &ps
);
117 PostQuitMessage (0) ;
120 return DefWindowProc (hwnd
, message
, wParam
, lParam
) ;
123 LRESULT CALLBACK
ChildProc (HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
128 char *classes
[]={"EDIT","BUTTON","LISTBOX","STATIC","SCROLLBAR","COMBOBOX","COMBOLBOX", NULL
};
138 hDC
= BeginPaint(hwnd
, &ps
);
139 SelectObject(hDC
,GetStockObject(ANSI_FIXED_FONT
));
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
)) ;
159 /* EndPaint(hwnd, &ps);
161 hDC = BeginPaint(hwnd, &ps);
163 MoveToEx(hDC
, 0, 0, NULL
);
164 LineTo(hDC
, 500, 500);
168 return DefWindowProc (hwnd
, message
, wParam
, lParam
) ;