Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 270 lines (225 sloc) 7.81 kB
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored
1 /*
2 ** WinElvis.c -- MS-Windows port of elvis.
3 **
4 ** Copyright 1996, Serge Pirotte.
5 */
6
7 #define CHAR Char
8 #include "elvis.h"
9 #undef CHAR
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
10 #undef ELVBOOL
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored
11
12 #if defined (GUI_WIN32)
13
14 #define _WIN32_WINNT 0x400
15 #include <windows.h>
16 #include <commctrl.h>
17 #include "winelvis.h"
18 #include "elvisres.h"
19 #include "wintools.h"
20 #if _MSC_VER <= 900
21 #if defined (USE_CTL3D)
22 #include <ctl3d.h>
23 #endif
24 #endif
25
26 extern void main (int argc, char **argv);
27
28 HINSTANCE hInst;
29 HCURSOR hLeftArrow;
30 HCURSOR hRightArrow;
31 HCURSOR selectedCursor;
32
33 #if _MSC_VER <= 900
34 #if defined (USE_CTL3D)
35 HANDLE ctl3d_handle;
36 #endif
37 #endif
38
39 static int init_application (HINSTANCE hInst);
40 static int init_instance (HINSTANCE hInst);
41 static void exit_instance (HINSTANCE hInst);
42 static LONG APIENTRY FrameWndProc (HWND hwnd, UINT msg,
43 UINT wParam, LONG lParam);
44 static LONG APIENTRY ClientWndProc (HWND hwnd, UINT msg,
45 UINT wParam, LONG lParam);
46
47 /* ---[ WinMain ]------------------------------------------------------ */
48
49 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
50 LPSTR lpCmdLine, int nCmdShow)
51
52 {
53 hInst = hInstance;
54
55 /* register the window classes */
56 if (!hPrevInstance)
57 if (!init_application (hInstance))
58 return FALSE;
59
60 /* instance specific initialization */
61 if (!init_instance (hInstance))
62 return FALSE;
63
64 /* parse the command line */
65 parse_cmd_line (lpCmdLine);
66
67 /* call elvis */
68 main (cmd_line_argc, cmd_line_argv);
69
70 /* instance specific cleanup */
71 exit_instance (hInstance);
72
73 return 0;
74 }
75
76 /* ---[ init_application ]--------------------------------------------- */
77
78 static int init_application (HINSTANCE hInst)
79
80 {
81 WNDCLASS wndclass;
82
83 /* find common controls library */
84 InitCommonControls ();
85
86 /* get cursors */
87 hLeftArrow = LoadCursor (NULL, IDC_ARROW);
88 hRightArrow = LoadCursor (hInst, MAKEINTRESOURCE (IDC_RIGHTARROW));
89 selectedCursor = hLeftArrow;
90
91 /* register frame window */
92 wndclass.style = CS_HREDRAW | CS_VREDRAW;
93 wndclass.lpfnWndProc = (WNDPROC)FrameWndProc;
94 wndclass.cbClsExtra = 0;
95 wndclass.cbWndExtra = 0;
96 wndclass.hInstance = hInst;
97 wndclass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE (IDI_ELVIS));
98 wndclass.hCursor = NULL;
99 wndclass.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);
100 wndclass.lpszMenuName = MAKEINTRESOURCE (IDM_ELVIS);
101 wndclass.lpszClassName = "ElvisFrameWnd";
102
103 if (!RegisterClass (&wndclass))
104 return FALSE;
105
106 /* register client window */
107 wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
108 wndclass.lpfnWndProc = (WNDPROC)ClientWndProc;
109 wndclass.hbrBackground = NULL;
110 wndclass.lpszMenuName = NULL;
111 wndclass.lpszClassName = "ElvisClientWnd";
112
113 if (!RegisterClass (&wndclass))
114 return FALSE;
115
116 /* indicate success */
117 return TRUE;
118 }
119
120 /* ---[ init_instance ]------------------------------------------------ */
121
122 static int init_instance (HINSTANCE hInstance)
123
124 {
125 #if _MSC_VER < 900
126 #if defined (USE_CTL3D)
127 /* try to register to the 3D controls library */
128 if ((ctl3d_handle = LoadLibrary ("CTL3D32.DLL")) != NULL) {
129 Ctl3dRegister (hInstance);
130 Ctl3dAutoSubclass (hInstance);
131 }
132 #endif
133 #endif
134
135 return TRUE;
136 }
137
138 /* ---[ exit_instance ]------------------------------------------------ */
139
140 static void exit_instance (HINSTANCE hInstance)
141
142 {
143 #if _MSC_VER < 900
144 #if defined (USE_CTL3D)
145 /* try to unregister to the 3D controls library */
146 if (ctl3d_handle != NULL) {
147 Ctl3dUnregister (hInstance);
148 FreeLibrary (ctl3d_handle);
149 }
150 #endif
151 #endif
152 }
153
154 /* ---[ FrameWndProc ]------------------------------------------------- */
155
156 LONG APIENTRY FrameWndProc (HWND hwnd, UINT msg, UINT wParam, LONG lParam)
157
158 {
159 LONG rc = 1;
160
161 switch (msg) {
162 case WM_COMMAND:
163 rc = gwcmd (gw_find_frame (hwnd), wParam);
164 break;
165 case WM_CLOSE:
166 rc = gwcmd (gw_find_frame (hwnd), (UINT)IDM_FILE_EXIT);
167 break;
168 case WM_GETMINMAXINFO:
169 rc = gwframe_WM_GETMINMAXINFO (gw_find_frame (hwnd), wParam, lParam);
170 break;
171 case WM_INITMENU:
172 rc = gwframe_WM_INITMENU (gw_find_frame (hwnd), wParam, lParam);
173 break;
174 case WM_MENUSELECT:
175 rc = gwframe_WM_MENUSELECT (gw_find_frame (hwnd), wParam, lParam);
176 break;
177 #if _MSC_VER > 900
178 case WM_NOTIFY:
179 rc = gwframe_WM_NOTIFY (gw_find_frame (hwnd), wParam, lParam);
180 break;
181 #endif
182 case WM_PAINT:
183 rc = gwframe_WM_PAINT (gw_find_frame (hwnd), wParam, lParam);
184 break;
185 case WM_SETFOCUS:
186 rc = gwframe_WM_SETFOCUS (gw_find_frame (hwnd), wParam, lParam);
187 break;
188 case WM_SIZE:
189 rc = gwframe_WM_SIZE (gw_find_frame (hwnd), wParam, lParam);
190 break;
191 }
192
193 return (rc == 0) ? 0 : DefWindowProc (hwnd, msg, wParam, lParam);
194 }
195
196 /* ---[ ClientWndProc ]------------------------------------------------ */
197
198 LONG APIENTRY ClientWndProc (HWND hwnd, UINT msg, UINT wParam, LONG lParam)
199
200 {
201 LONG rc = 1;
202
203 switch (msg) {
204 case WM_CHAR:
205 rc = gwclient_WM_CHAR (gw_find_client (hwnd), wParam, lParam);
206 break;
207 case WM_DROPFILES:
208 rc = gwclient_WM_DROPFILES (gw_find_client (hwnd), wParam, lParam);
209 break;
210 case WM_ERASEBKGND:
211 rc = gwclient_WM_ERASEBKGND (gw_find_client (hwnd), wParam, lParam);
212 break;
213 case WM_KEYDOWN:
214 rc = gwclient_WM_KEYDOWN (gw_find_client (hwnd), wParam, lParam);
215 break;
216 case WM_KEYUP:
217 rc = gwclient_WM_KEYUP (gw_find_client (hwnd), wParam, lParam);
218 break;
219 case WM_KILLFOCUS:
220 rc = gwclient_WM_KILLFOCUS (gw_find_client (hwnd), wParam, lParam);
221 break;
222 case WM_LBUTTONDBLCLK:
223 rc = gwclient_WM_LBUTTONDBLCLK (gw_find_client (hwnd), wParam, lParam);
224 break;
225 case WM_LBUTTONDOWN:
226 rc = gwclient_WM_LBUTTONDOWN (gw_find_client (hwnd), wParam, lParam);
227 break;
228 case WM_LBUTTONUP:
229 rc = gwclient_WM_LBUTTONUP (gw_find_client (hwnd), wParam, lParam);
230 break;
231 case WM_MOUSEMOVE:
232 rc = gwclient_WM_MOUSEMOVE (gw_find_client (hwnd), wParam, lParam);
233 break;
234 #if defined (WM_MOUSEWHEEL)
235 case WM_MOUSEWHEEL:
236 rc = gwclient_WM_MOUSEWHEEL (gw_find_client (hwnd), wParam, lParam);
237 break;
238 #endif
239 case WM_PAINT:
240 rc = gwclient_WM_PAINT (gw_find_client (hwnd), wParam, lParam);
241 break;
242 case WM_RBUTTONDBLCLK:
243 rc = gwclient_WM_RBUTTONDBLCLK (gw_find_client (hwnd), wParam, lParam);
244 break;
245 case WM_RBUTTONDOWN:
246 rc = gwclient_WM_RBUTTONDOWN (gw_find_client (hwnd), wParam, lParam);
247 break;
248 case WM_RBUTTONUP:
249 rc = gwclient_WM_RBUTTONUP (gw_find_client (hwnd), wParam, lParam);
250 break;
251 case WM_SETFOCUS:
252 rc = gwclient_WM_SETFOCUS (gw_find_client (hwnd), wParam, lParam);
253 break;
254 case WM_SIZE:
255 rc = gwclient_WM_SIZE (gw_find_client (hwnd), wParam, lParam);
256 break;
257 case WM_SYSKEYDOWN:
258 rc = gwclient_WM_SYSKEYDOWN (gw_find_client (hwnd), wParam, lParam);
259 break;
260 case WM_VSCROLL:
261 rc = gwclient_WM_VSCROLL (gw_find_client (hwnd), wParam, lParam);
262 break;
263 }
264
265 return (rc == 0) ? 0 : DefWindowProc (hwnd, msg, wParam, lParam);
266 }
267
268 #endif
3a9bb55 @mbert Import Elvis 2.1_3 (written by Steve Kirkendall)
authored
269 /* ex:se ts=4 sw=4: */
Something went wrong with that request. Please try again.