source: trunk/dll/key.c@ 1157

Last change on this file since 1157 was 1157, checked in by John Small, 17 years ago

Ticket 187: Draft 1: Functions only

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: key.c 1157 2008-09-05 21:39:52Z jbs $
5
6 About dialogs
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2004 Steven H. Levine
10
11 Revisions
12 01 Nov 04 SHL Rename SKULL? defines to avoid rc issues
13 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
14 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
15
16
17***********************************************************************/
18
19#include <string.h>
20
21#define INCL_DOS
22#define INCL_WIN
23#define INCL_LONGLONG // dircnrs.h
24
25#include "fm3dlg.h"
26#include "fm3str.h"
27#include "version.h"
28#include "errutil.h" // Dos_Error...
29#include "strutil.h" // GetPString
30#include "key.h" // AboutDlgProc
31#include "fm3dll.h"
32
33#pragma data_seg(DATA1)
34
35MRESULT EXPENTRY AuthorDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
36{
37 return WinDefDlgProc(hwnd, msg, mp1, mp2);
38}
39
40MRESULT EXPENTRY AboutDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
41{
42 SWP swp;
43 static HAB hab = 0;
44 BOOL no = FALSE;
45 static BOOL pause = FALSE;
46 static INT width, direction, ticktock, counter = 0;
47 static HPOINTER stick1, stick2, stick3, stick4, stick12, stick22, stick32,
48 stick42, stick5, stick52;
49
50 switch (msg) {
51 case WM_INITDLG:
52 if (hab) {
53 WinDismissDlg(hwnd, 0);
54 break;
55 }
56 if (mp2)
57 pause = TRUE;
58 else
59 pause = FALSE;
60 AboutBox = hwnd;
61 hab = WinQueryAnchorBlock(hwnd);
62 WinQueryWindowPos(hwnd, &swp);
63 width = swp.cx;
64 {
65 CHAR s[81];
66
67 sprintf(s,
68 "%s %d.%02d%s",
69 GetPString(IDS_VERSIONTEXT), VERMAJOR, VERMINOR, VERREALMINOR);
70 WinSetDlgItemText(hwnd, ABT_VERSION, s);
71 }
72 if (!strcmp(realappname, "FM/4"))
73 WinSetDlgItemText(hwnd, ABT_PROGNAME, GetPString(IDS_FM2LITETEXT));
74 if (!pause) {
75 stick1 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK1);
76 stick2 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK2);
77 stick3 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK3);
78 stick4 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK4);
79 stick5 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK5);
80 stick12 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK12);
81 stick22 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK22);
82 stick32 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK32);
83 stick42 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK42);
84 stick52 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ID_STICK52);
85 direction = 2;
86 ticktock = 0;
87 WinStartTimer(hab, hwnd, ID_TIMER, 164);
88 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
89 }
90 break;
91
92 case UM_SETUP:
93 if (counter++ > 1) {
94
95 HPOINTER hbm, sk0, sk1, sk2, sk3, sk4, sk5, sk6, sk7, sk8, sk9;
96
97 hbm = (HPOINTER) WinSendDlgItemMsg(hwnd,
98 ABT_ICON,
99 SM_QUERYHANDLE, MPVOID, MPVOID);
100 if (hbm) {
101 sk0 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL0_ICON);
102 sk1 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL1_ICON);
103 sk2 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL2_ICON);
104 sk3 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL3_ICON);
105 sk4 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL4_ICON);
106 sk5 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL5_ICON);
107 sk6 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL6_ICON);
108 sk7 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL7_ICON);
109 sk8 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL8_ICON);
110 sk9 = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SKULL9_ICON);
111 if (sk0 && sk1 && sk2 && sk3 && sk4 && sk5 && sk6 && sk7 &&
112 sk8 && sk9) {
113 WinShowWindow(WinWindowFromID(hwnd, ABT_ICON), FALSE);
114 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
115 MPFROMLONG(sk0), MPVOID);
116 WinShowWindow(WinWindowFromID(hwnd, ABT_ICON), TRUE);
117 DosSleep(16);
118 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
119 MPFROMLONG(sk1), MPVOID);
120 DosSleep(16);//05 Aug 07 GKY 33
121 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
122 MPFROMLONG(sk2), MPVOID);
123 DosSleep(16);//05 Aug 07 GKY 33
124 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
125 MPFROMLONG(sk3), MPVOID);
126 DosSleep(16);//05 Aug 07 GKY 33
127 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
128 MPFROMLONG(sk4), MPVOID);
129 DosSleep(16);//05 Aug 07 GKY 33
130 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
131 MPFROMLONG(sk5), MPVOID);
132 DosSleep(16);//05 Aug 07 GKY 33
133 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
134 MPFROMLONG(sk6), MPVOID);
135 DosSleep(16);//05 Aug 07 GKY 33
136 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
137 MPFROMLONG(sk7), MPVOID);
138 DosSleep(16);//05 Aug 07 GKY 33
139 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
140 MPFROMLONG(sk8), MPVOID);
141 DosSleep(16);//05 Aug 07 GKY 33
142 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
143 MPFROMLONG(sk9), MPVOID);
144 DosSleep(100);//05 Aug 07 GKY 257
145 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
146 MPFROMLONG(sk8), MPVOID);
147 DosSleep(16);//05 Aug 07 GKY 33
148 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
149 MPFROMLONG(sk7), MPVOID);
150 DosSleep(16);//05 Aug 07 GKY 33
151 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
152 MPFROMLONG(sk6), MPVOID);
153 DosSleep(16);//05 Aug 07 GKY 33
154 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
155 MPFROMLONG(sk5), MPVOID);
156 DosSleep(16);//05 Aug 07 GKY 33
157 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
158 MPFROMLONG(sk4), MPVOID);
159 DosSleep(16);//05 Aug 07 GKY 33
160 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
161 MPFROMLONG(sk3), MPVOID);
162 DosSleep(16);//05 Aug 07 GKY 33
163 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
164 MPFROMLONG(sk2), MPVOID);
165 DosSleep(16);//05 Aug 07 GKY 33
166 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
167 MPFROMLONG(sk1), MPVOID);
168 DosSleep(16);//05 Aug 07 GKY 33
169 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
170 MPFROMLONG(sk0), MPVOID);
171 DosSleep(16);//05 Aug 07 GKY 33
172 WinShowWindow(WinWindowFromID(hwnd, ABT_ICON), FALSE);
173 WinSendDlgItemMsg(hwnd, ABT_ICON, SM_SETHANDLE,
174 MPFROMLONG(hbm), MPVOID);
175 WinShowWindow(WinWindowFromID(hwnd, ABT_ICON), TRUE);
176 }
177 if (sk0)
178 WinDestroyPointer(sk0);
179 if (sk1)
180 WinDestroyPointer(sk1);
181 if (sk2)
182 WinDestroyPointer(sk2);
183 if (sk3)
184 WinDestroyPointer(sk3);
185 if (sk4)
186 WinDestroyPointer(sk4);
187 if (sk5)
188 WinDestroyPointer(sk5);
189 if (sk6)
190 WinDestroyPointer(sk6);
191 if (sk7)
192 WinDestroyPointer(sk7);
193 if (sk8)
194 WinDestroyPointer(sk8);
195 if (sk9)
196 WinDestroyPointer(sk9);
197 }
198 }
199 if (counter > 4)
200 WinDlgBox(HWND_DESKTOP,
201 hwnd, AuthorDlgProc, FM3ModHandle, AUTHOR_FRAME, NULL);
202 return 0;
203
204 case UM_SETDIR:
205 WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
206 DosSleep(250);//05 Aug 07 GKY 2500
207 return 0;
208
209 case WM_TIMER:
210 WinQueryWindowPos(WinWindowFromID(hwnd, ABT_STICK1), &swp);
211 if (swp.x + (swp.cx * 3) > width - 3) {
212 direction = -2;
213 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK1), FALSE);
214 WinSendDlgItemMsg(hwnd,
215 ABT_STICK1, SM_SETHANDLE, MPFROMLONG(stick3), MPVOID);
216 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK1), TRUE);
217 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK2), FALSE);
218 WinSendDlgItemMsg(hwnd,
219 ABT_STICK2,
220 SM_SETHANDLE, MPFROMLONG(stick32), MPVOID);
221 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK2), TRUE);
222 no = TRUE;
223 }
224 else if (swp.x < 3) {
225 direction = 2;
226 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK2), FALSE);
227 WinSendDlgItemMsg(hwnd, ABT_STICK2,
228 SM_SETHANDLE, MPFROMLONG(stick32), MPVOID);
229 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK2), TRUE);
230 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK1), FALSE);
231 WinSendDlgItemMsg(hwnd,
232 ABT_STICK1, SM_SETHANDLE, MPFROMLONG(stick3), MPVOID);
233 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK1), TRUE);
234 no = TRUE;
235 }
236 swp.x += direction;
237 WinSetWindowPos(WinWindowFromID(hwnd, ABT_STICK1),
238 HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_MOVE);
239 WinSetWindowPos(WinWindowFromID(hwnd, ABT_ICON),
240 HWND_TOP,
241 swp.x + swp.cx, swp.y, swp.cx, swp.cy, SWP_MOVE);
242 WinSetWindowPos(WinWindowFromID(hwnd, ABT_STICK2),
243 HWND_TOP,
244 swp.x + (swp.cx * 2), swp.y, swp.cx, swp.cy, SWP_MOVE);
245 if (!no) {
246 if (direction > 0) {
247 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK1), FALSE);
248 WinSendDlgItemMsg(hwnd,
249 ABT_STICK1,
250 SM_SETHANDLE,
251 MPFROMLONG((ticktock) ? stick1 : stick2), MPVOID);
252 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK1), TRUE);
253 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK2), FALSE);
254 WinSendDlgItemMsg(hwnd,
255 ABT_STICK2,
256 SM_SETHANDLE,
257 MPFROMLONG((ticktock) ? stick42 : stick52), MPVOID);
258 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK2), TRUE);
259 }
260 else {
261 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK2), FALSE);
262 WinSendDlgItemMsg(hwnd,
263 ABT_STICK2,
264 SM_SETHANDLE,
265 MPFROMLONG((ticktock) ? stick12 : stick22), MPVOID);
266 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK2), TRUE);
267 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK1), FALSE);
268 WinSendDlgItemMsg(hwnd,
269 ABT_STICK1,
270 SM_SETHANDLE,
271 MPFROMLONG((ticktock) ? stick4 : stick5), MPVOID);
272 WinShowWindow(WinWindowFromID(hwnd, ABT_STICK1), TRUE);
273 }
274 }
275 ticktock = (ticktock) ? 0 : 1;
276 break;
277
278 case WM_COMMAND:
279 switch (SHORT1FROMMP(mp1)) {
280 case ABT_VERSION:
281 case DID_CANCEL:
282 WinDismissDlg(hwnd, 0);
283 break;
284 }
285 return 0;
286
287 case WM_CLOSE:
288 WinDestroyWindow(hwnd);
289 return 0;
290
291 case WM_DESTROY:
292 if (hab) {
293 if (!pause) {
294 WinStopTimer(hab, hwnd, ID_TIMER);
295 WinDestroyPointer(stick1);
296 WinDestroyPointer(stick2);
297 WinDestroyPointer(stick3);
298 WinDestroyPointer(stick4);
299 WinDestroyPointer(stick5);
300 WinDestroyPointer(stick12);
301 WinDestroyPointer(stick22);
302 WinDestroyPointer(stick32);
303 WinDestroyPointer(stick42);
304 WinDestroyPointer(stick52);
305 }
306 hab = 0;
307 }
308 AboutBox = (HWND) 0;
309 break;
310 }
311 return WinDefDlgProc(hwnd, msg, mp1, mp2);
312}
313
314#pragma alloc_text(ABOUT,AboutDlgProc,AuthorDlgProc)
Note: See TracBrowser for help on using the repository browser.