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