[30] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: datamin.c 1482 2009-12-13 19:59:47Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Minimized data bar
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1335] | 9 | Copyright (c) 2001, 2008 Steven H. Levine
|
---|
[30] | 10 |
|
---|
[130] | 11 | 14 Sep 02 SHL Handle large partitions
|
---|
| 12 | 16 Oct 02 SHL Handle large partitions better
|
---|
| 13 | 23 May 05 SHL Use QWL_USER
|
---|
[136] | 14 | 23 May 05 SHL Avoid delays for inaccessible drives
|
---|
[162] | 15 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL
|
---|
[204] | 16 | 06 Jun 05 SHL Drop unused code
|
---|
[346] | 17 | 22 Jul 06 SHL Check more run time errors
|
---|
[552] | 18 | 02 Jan 07 GKY Changed drive information string formating to accomodate 6 char FS names
|
---|
| 19 | 07 Jan 07 GKY Move error strings etc. to string file
|
---|
[593] | 20 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
[793] | 21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[828] | 22 | 02 Sep 07 GKY Replaced DosQProcStatus with DosQuerySysState to fix trap in thunk code
|
---|
[1335] | 23 | 10 Dec 08 SHL Integrate exception handler support
|
---|
[1375] | 24 | 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent
|
---|
| 25 | Dos/Win programs from being inserted into the execute dialog with message why.
|
---|
[1391] | 26 | 11 Jan 09 GKY Replace font names in the string file with global set at compile in init.c
|
---|
[1395] | 27 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
|
---|
| 28 | 07 Feb 09 GKY Add *DateFormat functions to format dates based on locale
|
---|
[1400] | 29 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
|
---|
[1480] | 30 | 12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory
|
---|
[1482] | 31 | 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
|
---|
| 32 | profile calls for user settings that work and are setable in more than one
|
---|
| 33 | miniapp; FM3Str should be used for setting only relavent to FM/2 or that
|
---|
| 34 | aren't user settable; realappname should be used for setting applicable to
|
---|
| 35 | one or more miniapp but not to FM/2
|
---|
[30] | 36 |
|
---|
| 37 | ***********************************************************************/
|
---|
| 38 |
|
---|
[907] | 39 | #include <string.h>
|
---|
| 40 | #include <ctype.h>
|
---|
| 41 | #include <limits.h>
|
---|
[1335] | 42 | // #include <process.h> // _beginthread
|
---|
[907] | 43 |
|
---|
[2] | 44 | #define INCL_DOS
|
---|
[136] | 45 | #define INCL_DOSERRORS
|
---|
[2] | 46 | #define INCL_WIN
|
---|
| 47 | #define INCL_GPI
|
---|
[162] | 48 | #define INCL_LONGLONG
|
---|
[2] | 49 |
|
---|
[1178] | 50 | #include "fm3dll.h"
|
---|
[1222] | 51 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1206] | 52 | #include "info.h" // Data declaration(s)
|
---|
| 53 | #include "notebook.h" // Data declaration(s)
|
---|
| 54 | #include "inis.h" // Data declaration(s)
|
---|
| 55 | #include "init.h" // Data declaration(s)
|
---|
| 56 | #include "defview.h" // Data declaration(s)
|
---|
[2] | 57 | #include "fm3dlg.h"
|
---|
| 58 | #include "fm3str.h"
|
---|
| 59 | #include "procstat.h"
|
---|
[136] | 60 | #include "datamin.h"
|
---|
[907] | 61 | #include "errutil.h" // Dos_Error...
|
---|
| 62 | #include "strutil.h" // GetPString
|
---|
[1400] | 63 | #include "i18nutil.h" // CommaFmtUL
|
---|
[1156] | 64 | #include "killproc.h" // KillDlgProc
|
---|
| 65 | #include "sysinfo.h" // SysInfoDlgProc
|
---|
| 66 | #include "mainwnd.h" // TopWindowName
|
---|
[1178] | 67 | #include "common.h" // OpenDirCnr
|
---|
| 68 | #include "shadow.h" // OpenObject
|
---|
| 69 | #include "chklist.h" // PopupMenu
|
---|
| 70 | #include "presparm.h" // SetPresParams
|
---|
| 71 | #include "undel.h" // UndeleteDlgProc
|
---|
| 72 | #include "misc.h" // GetCmdSpec
|
---|
| 73 | #include "wrappers.h" // xDosFindFirst
|
---|
| 74 | #include "systemf.h" // runemf2
|
---|
[1038] | 75 | #include "fortify.h"
|
---|
[1335] | 76 | #include "excputil.h" // 06 May 08 SHL added
|
---|
[2] | 77 |
|
---|
[136] | 78 | APIRET16 APIENTRY16 Dos16MemAvail(PULONG pulAvailMem);
|
---|
[2] | 79 |
|
---|
[136] | 80 | static volatile HEV G_hevDataMin = NULLHANDLE;
|
---|
| 81 | static volatile HWND G_hwndSingle = NULLHANDLE;
|
---|
[2] | 82 |
|
---|
[551] | 83 | static VOID dataminThread(VOID * pv);
|
---|
[2] | 84 |
|
---|
[1206] | 85 | // Data definitions
|
---|
| 86 | #pragma data_seg(GLOBAL1)
|
---|
| 87 | HWND DataHwnd;
|
---|
| 88 | BOOL fDataInclRemote;
|
---|
| 89 | BOOL fDataShowDrives;
|
---|
| 90 | BOOL fDataToFore;
|
---|
| 91 | BOOL fDullMin;
|
---|
| 92 |
|
---|
| 93 | #pragma data_seg(DATA2)
|
---|
| 94 |
|
---|
| 95 | static PSZ pszSrcFile = __FILE__;
|
---|
| 96 |
|
---|
[136] | 97 | long MINI_X = 208, MINI_Y = 16;
|
---|
[2] | 98 |
|
---|
[136] | 99 | //=== MiniTimeProc - time, swap and drive status mini windows procedure ===
|
---|
[2] | 100 |
|
---|
[136] | 101 | MRESULT EXPENTRY MiniTimeProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 102 | {
|
---|
| 103 | APIRET rc;
|
---|
[551] | 104 |
|
---|
| 105 | switch (msg) {
|
---|
[136] | 106 | case WM_CREATE:
|
---|
| 107 | {
|
---|
[551] | 108 | PVOID pv = xmalloc(sizeof(tDataMin), pszSrcFile, __LINE__);
|
---|
[959] | 109 | if (pv)
|
---|
[1335] | 110 | WinSetWindowPtr(hwnd, QWL_DATAMIN_PTR, pv);
|
---|
[136] | 111 | }
|
---|
| 112 | break;
|
---|
[2] | 113 |
|
---|
[136] | 114 | case WM_BUTTON1CLICK:
|
---|
| 115 | {
|
---|
| 116 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 117 |
|
---|
[551] | 118 | if (id >= MINI_DRIVEA) {
|
---|
| 119 | if (G_hevDataMin != NULLHANDLE) {
|
---|
[136] | 120 | G_hwndSingle = hwnd;
|
---|
| 121 | rc = DosPostEventSem(G_hevDataMin);
|
---|
[551] | 122 | if (rc) {
|
---|
[1335] | 123 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 124 | GetPString(IDS_POSTSEMFAILED));
|
---|
[136] | 125 | }
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 | else if (id == MINI_TIME)
|
---|
[551] | 129 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP6, // Up time
|
---|
| 130 | MPVOID, MPVOID);
|
---|
[136] | 131 | else if (id == MINI_PROC)
|
---|
| 132 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
[551] | 133 | WM_SYSCOMMAND, MPFROM2SHORT(SC_TASKMANAGER, 0), MPVOID);
|
---|
[136] | 134 | }
|
---|
| 135 | break;
|
---|
[2] | 136 |
|
---|
[136] | 137 | case WM_BUTTON1DBLCLK:
|
---|
| 138 | {
|
---|
| 139 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
[2] | 140 |
|
---|
[551] | 141 | if (id >= MINI_DRIVEA && !hwndMain) {
|
---|
[136] | 142 | CHAR s[] = " :\\";
|
---|
[2] | 143 |
|
---|
[136] | 144 | *s = (CHAR) (id - MINI_DRIVEA) + 'A';
|
---|
[551] | 145 | OpenDirCnr((HWND) 0, HWND_DESKTOP, (HWND) 0, FALSE, s);
|
---|
[136] | 146 | return MRFROMLONG(1L);
|
---|
| 147 | }
|
---|
[551] | 148 | else if (id == MINI_TIME) {
|
---|
[136] | 149 | OpenObject("<WP_CLOCK>",
|
---|
[551] | 150 | (SHORT2FROMMP(mp2) & KC_SHIFT) ? Default : Settings, hwnd);
|
---|
[136] | 151 | return MRFROMLONG(1L);
|
---|
| 152 | }
|
---|
[2] | 153 |
|
---|
| 154 | #ifdef NEVER
|
---|
[551] | 155 | else if (id == MINI_MEM) {
|
---|
[136] | 156 | WinDlgBox(HWND_DESKTOP,
|
---|
| 157 | HWND_DESKTOP,
|
---|
[551] | 158 | SysInfoDlgProc, FM3ModHandle, SYS_FRAME, NULL);
|
---|
[136] | 159 | return MRFROMLONG(1L);
|
---|
| 160 | }
|
---|
[2] | 161 | #endif
|
---|
| 162 |
|
---|
[551] | 163 | else if (id == MINI_PROC || id == MINI_MEM) {
|
---|
[136] | 164 | WinDlgBox(HWND_DESKTOP,
|
---|
[551] | 165 | hwnd, KillDlgProc, FM3ModHandle, KILL_FRAME, NULL);
|
---|
[136] | 166 | return MRFROMLONG(1L);
|
---|
| 167 | }
|
---|
[551] | 168 | else if (id == MINI_SWAP && *SwapperDat) {
|
---|
[2] | 169 |
|
---|
[136] | 170 | char s[5];
|
---|
[2] | 171 |
|
---|
[136] | 172 | strncpy(s, SwapperDat, 4);
|
---|
| 173 | s[3] = 0;
|
---|
| 174 | WinDlgBox(HWND_DESKTOP,
|
---|
| 175 | hwndMain,
|
---|
[551] | 176 | UndeleteDlgProc, FM3ModHandle, UNDEL_FRAME, MPFROMP(s));
|
---|
[136] | 177 | return MRFROMLONG(1L);
|
---|
[2] | 178 | }
|
---|
[136] | 179 | }
|
---|
| 180 | break;
|
---|
[2] | 181 |
|
---|
[136] | 182 | case WM_BUTTON1MOTIONSTART:
|
---|
| 183 | PostMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
[551] | 184 | UM_BUTTON1MOTIONSTART, MPVOID, MPVOID);
|
---|
[136] | 185 | break;
|
---|
[2] | 186 |
|
---|
[136] | 187 | case WM_CONTEXTMENU:
|
---|
[551] | 188 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_CONTEXTMENU, MPVOID, MPVOID);
|
---|
[136] | 189 | break;
|
---|
[2] | 190 |
|
---|
[136] | 191 | case WM_PAINT:
|
---|
| 192 | {
|
---|
| 193 | MRESULT mr = 0;
|
---|
| 194 | USHORT id;
|
---|
| 195 |
|
---|
| 196 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
[551] | 197 | if (id >= MINI_DRIVEA) {
|
---|
[136] | 198 | HPS hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
|
---|
[551] | 199 |
|
---|
| 200 | if (hps) {
|
---|
[136] | 201 | mr = WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
[551] | 202 | UM_PAINT, MPFROM2SHORT(id, 0), MPFROMLONG(hps));
|
---|
[136] | 203 | WinEndPaint(hps);
|
---|
[551] | 204 | return mr; // Bypass default paint
|
---|
[136] | 205 | }
|
---|
| 206 | }
|
---|
| 207 | }
|
---|
| 208 | break;
|
---|
[2] | 209 |
|
---|
[551] | 210 | case WM_DESTROY:
|
---|
| 211 | {
|
---|
| 212 | PVOID pv = WinQueryWindowPtr(hwnd, QWL_DATAMIN_PTR);
|
---|
| 213 |
|
---|
[1009] | 214 | xfree(pv, pszSrcFile, __LINE__);
|
---|
[551] | 215 | }
|
---|
| 216 | break;
|
---|
[2] | 217 | }
|
---|
[136] | 218 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
[2] | 219 |
|
---|
[551] | 220 | } // MiniTimeProc
|
---|
[2] | 221 |
|
---|
[136] | 222 | //=== DataProc - databar client window procedure ===
|
---|
[2] | 223 |
|
---|
[136] | 224 | MRESULT EXPENTRY DataProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 225 | {
|
---|
| 226 | APIRET rc;
|
---|
| 227 |
|
---|
[2] | 228 | static ULONG counter;
|
---|
[136] | 229 | static BOOL NoFloat, noqproc = FALSE, Positioned;
|
---|
[551] | 230 | static HWND hwndMenu = (HWND) 0;
|
---|
[2] | 231 |
|
---|
[551] | 232 | switch (msg) {
|
---|
[136] | 233 | case WM_CREATE:
|
---|
[377] | 234 | if (DataHwnd) {
|
---|
[551] | 235 | WinSetWindowPos(DataHwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_SHOW);
|
---|
[136] | 236 | return MRFROMLONG(1L);
|
---|
| 237 | }
|
---|
| 238 | DataHwnd = WinQueryWindow(hwnd, QW_PARENT);
|
---|
| 239 | NoFloat = FALSE;
|
---|
| 240 | Positioned = FALSE;
|
---|
[1391] | 241 | //fixme to allow user to change presparams 1-10-09 GKY
|
---|
[136] | 242 | SetPresParams(hwnd,
|
---|
[1391] | 243 | &RGBGREY, &RGBBLACK, &RGBBLACK, FNT_8HELVETICA);
|
---|
[136] | 244 | {
|
---|
| 245 | int c;
|
---|
| 246 | long x = 3;
|
---|
[551] | 247 | USHORT ids[] = { MINI_TIME, MINI_MEM, MINI_SWAP, MINI_PROC, 0 };
|
---|
[136] | 248 | POINTL aptl[TXTBOX_COUNT];
|
---|
| 249 | HPS hps;
|
---|
| 250 |
|
---|
| 251 | hps = WinGetPS(hwnd);
|
---|
[551] | 252 | if (hps) {
|
---|
[136] | 253 | GpiQueryTextBox(hps,
|
---|
| 254 | 34,
|
---|
| 255 | " -=03:08:22 SMW 1998/08/02=- ",
|
---|
[551] | 256 | TXTBOX_COUNT, aptl);
|
---|
[136] | 257 | WinReleasePS(hps);
|
---|
| 258 | MINI_X = aptl[TXTBOX_TOPRIGHT].x + 6;
|
---|
| 259 | MINI_Y = aptl[TXTBOX_TOPRIGHT].y + 6;
|
---|
[2] | 260 | }
|
---|
[551] | 261 | for (c = 0; ids[c]; c++) {
|
---|
[377] | 262 | if (!WinCreateWindow(hwnd,
|
---|
[593] | 263 | WC_MINITIME,
|
---|
[551] | 264 | NullStr,
|
---|
| 265 | SS_TEXT | DT_CENTER | DT_VCENTER | WS_VISIBLE,
|
---|
| 266 | x,
|
---|
| 267 | 3,
|
---|
| 268 | MINI_X,
|
---|
| 269 | MINI_Y, hwnd, HWND_TOP, ids[c], NULL, NULL)) {
|
---|
[1395] | 270 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
| 271 | PCSZ_WINCREATEWINDOW);
|
---|
[377] | 272 | }
|
---|
[136] | 273 | x += (MINI_X + 4);
|
---|
[2] | 274 | }
|
---|
[136] | 275 | }
|
---|
[551] | 276 | if (!hwndMain) {
|
---|
[136] | 277 | SWCNTRL swctl;
|
---|
[2] | 278 |
|
---|
[136] | 279 | memset(&swctl, 0, sizeof(swctl));
|
---|
| 280 | swctl.hwnd = WinQueryWindow(hwnd, QW_PARENT);
|
---|
| 281 | swctl.uchVisibility = SWL_VISIBLE;
|
---|
| 282 | swctl.fbJump = (fDataToFore) ? SWL_NOTJUMPABLE : SWL_JUMPABLE;
|
---|
| 283 | swctl.bProgType = PROG_PM;
|
---|
[551] | 284 | strcpy(swctl.szSwtitle, GetPString(IDS_DATABARTITLETEXT));
|
---|
| 285 | WinCreateSwitchEntry(WinQueryAnchorBlock(hwnd), &swctl);
|
---|
[136] | 286 | }
|
---|
[551] | 287 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
[136] | 288 | return 0;
|
---|
[2] | 289 |
|
---|
[136] | 290 | case WM_MENUEND:
|
---|
| 291 | NoFloat = FALSE;
|
---|
[551] | 292 | if (hwndMenu == (HWND) mp2) {
|
---|
[136] | 293 | WinDestroyWindow(hwndMenu);
|
---|
[551] | 294 | hwndMenu = (HWND) 0;
|
---|
[136] | 295 | }
|
---|
| 296 | break;
|
---|
| 297 |
|
---|
| 298 | case UM_RESTORE:
|
---|
| 299 | WinSetWindowPtr(hwnd, QWL_USER, mp1);
|
---|
| 300 | return 0;
|
---|
| 301 |
|
---|
| 302 | case UM_SETUP:
|
---|
| 303 | {
|
---|
| 304 | long x, y;
|
---|
| 305 | SWP swp, swpD;
|
---|
| 306 | int c;
|
---|
| 307 | ULONG size = sizeof(SWP);
|
---|
| 308 | ULONG numdrives = 0;
|
---|
| 309 | ULONG drivestyle = (DRIVE_REMOVABLE | DRIVE_INVALID |
|
---|
[553] | 310 | DRIVE_IGNORE | DRIVE_ZIPSTREAM | DRIVE_NOSTATS);
|
---|
[136] | 311 | ULONG ulDriveNum, ulDriveMap;
|
---|
| 312 |
|
---|
| 313 | if (!fDataInclRemote)
|
---|
[553] | 314 | drivestyle |= DRIVE_REMOTE || DRIVE_VIRTUAL || DRIVE_RAMDISK;
|
---|
[551] | 315 | if (fDataShowDrives) {
|
---|
[136] | 316 | DosError(FERR_DISABLEHARDERR);
|
---|
| 317 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
---|
| 318 | x = 3;
|
---|
| 319 | y = MINI_Y + 4;
|
---|
| 320 | // Drive status windows
|
---|
[551] | 321 | for (c = 2; c < 26; c++) {
|
---|
| 322 | if ((ulDriveMap & (1L << c)) && !(driveflags[c] & drivestyle)) {
|
---|
[377] | 323 | if (!WinCreateWindow(hwnd,
|
---|
[593] | 324 | WC_MINITIME,
|
---|
[551] | 325 | NullStr,
|
---|
| 326 | SS_TEXT | DT_CENTER | DT_VCENTER |
|
---|
| 327 | WS_VISIBLE, x, y, MINI_X, MINI_Y, hwnd,
|
---|
| 328 | HWND_TOP, MINI_DRIVEA + c, NULL, NULL)) {
|
---|
[1395] | 329 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
| 330 | PCSZ_WINCREATEWINDOW);
|
---|
[377] | 331 | }
|
---|
[136] | 332 | numdrives++;
|
---|
| 333 | x += (MINI_X + 4);
|
---|
[551] | 334 | if ((numdrives % 4) == 0) {
|
---|
[136] | 335 | y += (MINI_Y + 4);
|
---|
| 336 | x = 3;
|
---|
| 337 | }
|
---|
| 338 | }
|
---|
| 339 | }
|
---|
[2] | 340 | }
|
---|
[136] | 341 | x = (MINI_X * 4) + 18;
|
---|
| 342 | y = (MINI_Y + 4) + ((numdrives / 4) * (MINI_Y + 4)) +
|
---|
| 343 | (((numdrives % 4) != 0) * (MINI_Y + 4));
|
---|
[551] | 344 | if (!Positioned) {
|
---|
| 345 | if (PrfQueryProfileData(fmprof, appname, "DataMinPos", &swp, &size)) {
|
---|
[136] | 346 | WinQueryWindowPos(HWND_DESKTOP, &swpD);
|
---|
| 347 | if (swp.x > swpD.cx - 16)
|
---|
| 348 | swp.x = swpD.cx - 16;
|
---|
| 349 | if (swp.y > swpD.cy - 16)
|
---|
| 350 | swp.y = swpD.cy - 16;
|
---|
| 351 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 352 | HWND_TOP,
|
---|
| 353 | swp.x,
|
---|
| 354 | swp.y,
|
---|
[551] | 355 | x, y, SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER);
|
---|
[136] | 356 | }
|
---|
| 357 | else
|
---|
| 358 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 359 | HWND_TOP,
|
---|
| 360 | 0,
|
---|
| 361 | 0,
|
---|
[551] | 362 | x, y, SWP_SHOW | SWP_SIZE | SWP_MOVE | SWP_ZORDER);
|
---|
[136] | 363 | Positioned = TRUE;
|
---|
| 364 | }
|
---|
| 365 | else
|
---|
| 366 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 367 | HWND_TOP,
|
---|
[551] | 368 | 0, 0, x, y, SWP_SHOW | SWP_SIZE | SWP_ZORDER);
|
---|
| 369 | WinShowWindow(WinQueryWindow(hwnd, QW_PARENT), TRUE);
|
---|
[136] | 370 | if (numdrives) {
|
---|
[1335] | 371 | if (xbeginthread(dataminThread,
|
---|
| 372 | 32768,
|
---|
| 373 | (PVOID)hwnd,
|
---|
| 374 | pszSrcFile,
|
---|
| 375 | __LINE__) == -1)
|
---|
| 376 | {
|
---|
[551] | 377 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[136] | 378 | }
|
---|
| 379 | }
|
---|
| 380 | counter = 0;
|
---|
[551] | 381 | PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID);
|
---|
[136] | 382 | }
|
---|
[551] | 383 | return 0; // UM_SETUP
|
---|
[136] | 384 |
|
---|
| 385 | case WM_BUTTON1DBLCLK:
|
---|
| 386 | if (hwndMain)
|
---|
[551] | 387 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[136] | 388 | break;
|
---|
| 389 |
|
---|
| 390 | case UM_CONTEXTMENU:
|
---|
| 391 | case WM_CONTEXTMENU:
|
---|
| 392 | if (!hwndMenu)
|
---|
[551] | 393 | hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MINI_FRAME);
|
---|
| 394 | if (hwndMenu) {
|
---|
| 395 | WinCheckMenuItem(hwndMenu, MINI_FLOAT, fDataToFore);
|
---|
| 396 | WinCheckMenuItem(hwndMenu, MINI_SHOW, fDataShowDrives);
|
---|
| 397 | WinCheckMenuItem(hwndMenu, MINI_BORING, fDullMin);
|
---|
| 398 | WinCheckMenuItem(hwndMenu, MINI_INCLREMOTE, fDataInclRemote);
|
---|
[1369] | 399 | if (fProtectOnly) {
|
---|
| 400 | WinEnableMenuItem(hwndMenu, IDM_DOSCOMMANDLINE, FALSE);
|
---|
| 401 | WinEnableMenuItem(hwndMenu, IDM_WINFULLSCREEN, FALSE);
|
---|
| 402 | }
|
---|
[136] | 403 | NoFloat = TRUE;
|
---|
[551] | 404 | if (!PopupMenu(hwnd, hwnd, hwndMenu))
|
---|
[136] | 405 | NoFloat = FALSE;
|
---|
| 406 | }
|
---|
| 407 | if (msg == UM_CONTEXTMENU)
|
---|
[2] | 408 | return 0;
|
---|
[136] | 409 | break;
|
---|
[2] | 410 |
|
---|
[136] | 411 | case WM_BUTTON2DBLCLK:
|
---|
[551] | 412 | if (!(SHORT2FROMMP(mp2) & KC_SHIFT)) {
|
---|
| 413 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(MINI_FLOAT, 0), MPVOID);
|
---|
[2] | 414 | break;
|
---|
[136] | 415 | }
|
---|
| 416 | /* else intentional fallthru */
|
---|
| 417 | case WM_CHORD:
|
---|
| 418 | case WM_BUTTON3DBLCLK:
|
---|
[551] | 419 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(MINI_SHOW, 0), MPVOID);
|
---|
[136] | 420 | break;
|
---|
[2] | 421 |
|
---|
[136] | 422 | case UM_BUTTON1MOTIONSTART:
|
---|
| 423 | case WM_BUTTON1MOTIONSTART:
|
---|
| 424 | {
|
---|
| 425 | TRACKINFO TrackInfo;
|
---|
| 426 | SWP Position;
|
---|
[2] | 427 |
|
---|
[136] | 428 | memset(&TrackInfo, 0, sizeof(TrackInfo));
|
---|
| 429 | TrackInfo.cxBorder = 1;
|
---|
| 430 | TrackInfo.cyBorder = 1;
|
---|
| 431 | TrackInfo.cxGrid = 1;
|
---|
| 432 | TrackInfo.cyGrid = 1;
|
---|
| 433 | TrackInfo.cxKeyboard = 8;
|
---|
| 434 | TrackInfo.cyKeyboard = 8;
|
---|
| 435 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &Position);
|
---|
| 436 | TrackInfo.rclTrack.xLeft = Position.x;
|
---|
| 437 | TrackInfo.rclTrack.xRight = Position.x + Position.cx;
|
---|
| 438 | TrackInfo.rclTrack.yBottom = Position.y;
|
---|
| 439 | TrackInfo.rclTrack.yTop = Position.y + Position.cy;
|
---|
| 440 | WinQueryWindowPos(HWND_DESKTOP, &Position);
|
---|
| 441 | TrackInfo.rclBoundary.xLeft = Position.x;
|
---|
| 442 | TrackInfo.rclBoundary.xRight = Position.x + Position.cx;
|
---|
| 443 | TrackInfo.rclBoundary.yBottom = Position.y;
|
---|
| 444 | TrackInfo.rclBoundary.yTop = Position.y + Position.cy;
|
---|
| 445 | TrackInfo.ptlMinTrackSize.x = 0;
|
---|
| 446 | TrackInfo.ptlMinTrackSize.y = 0;
|
---|
| 447 | TrackInfo.ptlMaxTrackSize.x = Position.cx;
|
---|
| 448 | TrackInfo.ptlMaxTrackSize.y = Position.cy;
|
---|
| 449 | TrackInfo.fs = TF_MOVE | TF_STANDARD | TF_ALLINBOUNDARY;
|
---|
[551] | 450 | if (WinTrackRect(HWND_DESKTOP, (HPS) 0, &TrackInfo)) {
|
---|
[136] | 451 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 452 | HWND_TOP, TrackInfo.rclTrack.xLeft,
|
---|
| 453 | TrackInfo.rclTrack.yBottom, 0, 0, SWP_MOVE);
|
---|
| 454 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
---|
| 455 | }
|
---|
| 456 | }
|
---|
| 457 | break;
|
---|
[2] | 458 |
|
---|
[136] | 459 | case WM_HELP:
|
---|
| 460 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HELP, 0), MPVOID);
|
---|
| 461 | break;
|
---|
| 462 |
|
---|
| 463 | case WM_COMMAND:
|
---|
[551] | 464 | switch (SHORT1FROMMP(mp1)) {
|
---|
[136] | 465 | case IDM_COMMANDLINE:
|
---|
| 466 | case IDM_DOSCOMMANDLINE:
|
---|
| 467 | case IDM_WINFULLSCREEN:
|
---|
| 468 | {
|
---|
| 469 | CHAR *env = GetCmdSpec(FALSE), path[CCHMAXPATH];
|
---|
| 470 | INT type = SEPARATE | WINDOWED;
|
---|
| 471 |
|
---|
| 472 | *path = 0;
|
---|
[551] | 473 | TopWindowName(hwnd, (HWND) 0, path);
|
---|
[136] | 474 | if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE)
|
---|
| 475 | env = GetCmdSpec(TRUE);
|
---|
[551] | 476 | else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) {
|
---|
[136] | 477 | env = "WINOS2.COM";
|
---|
| 478 | type = SEPARATE | FULLSCREEN;
|
---|
| 479 | }
|
---|
[1335] | 480 | runemf2(type, hwnd, pszSrcFile, __LINE__,
|
---|
| 481 | path, NULL, "%s", env);
|
---|
[2] | 482 | }
|
---|
[136] | 483 | break;
|
---|
[2] | 484 |
|
---|
[136] | 485 | case IDM_HELP:
|
---|
| 486 | if (hwndHelp)
|
---|
| 487 | WinSendMsg(hwndHelp,
|
---|
| 488 | HM_DISPLAY_HELP,
|
---|
[551] | 489 | MPFROM2SHORT(HELP_DATABAR, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
[2] | 490 | break;
|
---|
| 491 |
|
---|
[136] | 492 | case MINI_CLOSE:
|
---|
[551] | 493 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 494 | break;
|
---|
| 495 |
|
---|
[136] | 496 | case MINI_BORING:
|
---|
| 497 | fDullMin = (fDullMin) ? FALSE : TRUE;
|
---|
[1482] | 498 | PrfWriteProfileData(fmprof, appname, "DullDatabar", &fDullMin, sizeof(BOOL));
|
---|
[551] | 499 | if (G_hevDataMin != NULLHANDLE) {
|
---|
[136] | 500 | rc = DosPostEventSem(G_hevDataMin);
|
---|
| 501 | if (rc) {
|
---|
[1335] | 502 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 503 | GetPString(IDS_POSTSEMFAILED));
|
---|
[136] | 504 | }
|
---|
[2] | 505 | }
|
---|
[136] | 506 |
|
---|
[2] | 507 | break;
|
---|
| 508 |
|
---|
[136] | 509 | case MINI_INCLREMOTE:
|
---|
| 510 | case MINI_SHOW:
|
---|
[551] | 511 | if (SHORT1FROMMP(mp1) == MINI_SHOW) {
|
---|
[136] | 512 | fDataShowDrives = (fDataShowDrives) ? FALSE : TRUE;
|
---|
[1482] | 513 | PrfWriteProfileData(fmprof, appname, "DataShowDrives",
|
---|
| 514 | &fDataShowDrives, sizeof(BOOL));
|
---|
[136] | 515 | }
|
---|
[551] | 516 | else {
|
---|
[136] | 517 | fDataInclRemote = (fDataInclRemote) ? FALSE : TRUE;
|
---|
[1482] | 518 | PrfWriteProfileData(fmprof, appname, "DataInclRemote",
|
---|
| 519 | &fDataInclRemote, sizeof(BOOL));
|
---|
[136] | 520 | }
|
---|
| 521 | {
|
---|
| 522 | HENUM henum;
|
---|
| 523 | HWND hwndChild;
|
---|
| 524 | USHORT id;
|
---|
[2] | 525 |
|
---|
[136] | 526 | henum = WinBeginEnumWindows(hwnd);
|
---|
[551] | 527 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
[136] | 528 | id = WinQueryWindowUShort(hwndChild, QWS_ID);
|
---|
| 529 | if (id >= MINI_DRIVEA)
|
---|
| 530 | WinDestroyWindow(hwndChild);
|
---|
| 531 | }
|
---|
| 532 | WinEndEnumWindows(henum);
|
---|
[2] | 533 | }
|
---|
[136] | 534 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
[2] | 535 | break;
|
---|
| 536 |
|
---|
[136] | 537 | case MINI_FLOAT:
|
---|
| 538 | fDataToFore = (fDataToFore) ? FALSE : TRUE;
|
---|
[1482] | 539 | PrfWriteProfileData(fmprof, appname, "DataToFore", &fDataToFore, sizeof(BOOL));
|
---|
[551] | 540 | if (!hwndMain) {
|
---|
[136] | 541 |
|
---|
| 542 | SWCNTRL swcntrl;
|
---|
| 543 | HSWITCH hswitch;
|
---|
| 544 |
|
---|
| 545 | hswitch = (HSWITCH) WinQuerySwitchHandle(hwnd, (PID) 0);
|
---|
[551] | 546 | if (hswitch) {
|
---|
[136] | 547 | memset(&swcntrl, 0, sizeof(SWCNTRL));
|
---|
[551] | 548 | if (!WinQuerySwitchEntry(hswitch, &swcntrl)) {
|
---|
[136] | 549 | swcntrl.fbJump = (fDataToFore) ? SWL_NOTJUMPABLE : SWL_JUMPABLE;
|
---|
[551] | 550 | WinChangeSwitchEntry(hswitch, &swcntrl);
|
---|
[136] | 551 | }
|
---|
| 552 | }
|
---|
| 553 | }
|
---|
[2] | 554 | break;
|
---|
[136] | 555 | }
|
---|
| 556 | return 0;
|
---|
[2] | 557 |
|
---|
[136] | 558 | case WM_SIZE:
|
---|
| 559 | WinSetWindowPos(hwnd,
|
---|
| 560 | HWND_TOP,
|
---|
| 561 | 0,
|
---|
| 562 | 0,
|
---|
| 563 | SHORT1FROMMP(mp2),
|
---|
[551] | 564 | SHORT2FROMMP(mp2), SWP_MOVE | SWP_SIZE);
|
---|
[136] | 565 | break;
|
---|
[2] | 566 |
|
---|
[136] | 567 | case WM_PAINT:
|
---|
| 568 | {
|
---|
| 569 | HPS hps;
|
---|
| 570 | POINTL ptl;
|
---|
| 571 | SWP swp;
|
---|
| 572 | RECTL rcl;
|
---|
[2] | 573 |
|
---|
[551] | 574 | hps = WinBeginPaint(hwnd, (HPS) 0, &rcl);
|
---|
| 575 | if (hps) {
|
---|
| 576 | WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY);
|
---|
[136] | 577 | GpiSetMix(hps, FM_OVERPAINT);
|
---|
| 578 | GpiSetColor(hps, CLR_WHITE);
|
---|
| 579 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 580 | ptl.x = 0;
|
---|
| 581 | ptl.y = 0;
|
---|
| 582 | GpiMove(hps, &ptl);
|
---|
| 583 | ptl.y = swp.cy - 1;
|
---|
| 584 | GpiLine(hps, &ptl);
|
---|
| 585 | ptl.x = swp.cx - 1;
|
---|
| 586 | GpiLine(hps, &ptl);
|
---|
| 587 | GpiSetColor(hps, CLR_DARKGRAY);
|
---|
| 588 | ptl.y = 0;
|
---|
| 589 | GpiLine(hps, &ptl);
|
---|
| 590 | ptl.x = 0;
|
---|
| 591 | GpiLine(hps, &ptl);
|
---|
| 592 | {
|
---|
| 593 | HENUM henum;
|
---|
| 594 | HWND hwndTemp;
|
---|
[2] | 595 |
|
---|
[136] | 596 | henum = WinBeginEnumWindows(hwnd);
|
---|
[551] | 597 | while ((hwndTemp = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
[136] | 598 | PaintRecessedWindow(hwndTemp,
|
---|
[551] | 599 | hps, (WinQueryWindowUShort(hwndTemp, QWS_ID)
|
---|
| 600 | != MINI_TIME), FALSE);
|
---|
[136] | 601 | }
|
---|
| 602 | WinEndEnumWindows(henum);
|
---|
| 603 | }
|
---|
| 604 | WinEndPaint(hps);
|
---|
| 605 | }
|
---|
| 606 | }
|
---|
| 607 | return 0;
|
---|
[2] | 608 |
|
---|
[136] | 609 | case UM_PAINT:
|
---|
| 610 | {
|
---|
| 611 | CHAR s[90];
|
---|
| 612 | CHAR szFreeQty[38];
|
---|
| 613 | CHAR szDrvLtr[] = " :";
|
---|
| 614 | CHAR *pszFSystem;
|
---|
[162] | 615 | ULONGLONG ullFreeQty;
|
---|
[136] | 616 | ULONG ulPercentFree;
|
---|
| 617 | ULONG wasx;
|
---|
| 618 | HPS hps = (HPS) mp2;
|
---|
| 619 | HWND hwndChild;
|
---|
| 620 | USHORT id;
|
---|
| 621 | SWP swp;
|
---|
| 622 | POINTL ptl;
|
---|
| 623 | tDataMin *pDM;
|
---|
[2] | 624 |
|
---|
[136] | 625 | id = SHORT1FROMMP(mp1);
|
---|
[551] | 626 | if (id >= MINI_DRIVEA) {
|
---|
[136] | 627 | hwndChild = WinWindowFromID(hwnd, id);
|
---|
| 628 | if (!hwndChild)
|
---|
| 629 | return 0;
|
---|
| 630 | if (!WinQueryWindowPos(hwndChild, &swp))
|
---|
| 631 | return 0;
|
---|
| 632 | pDM = WinQueryWindowPtr(hwndChild, QWL_DATAMIN_PTR);
|
---|
[551] | 633 | if (!pDM || pDM->qfsi_rc) {
|
---|
[162] | 634 | ullFreeQty = 0;
|
---|
[136] | 635 | ulPercentFree = 0;
|
---|
| 636 | }
|
---|
[551] | 637 | else {
|
---|
| 638 | ullFreeQty = (ULONGLONG) pDM->fsa.cUnitAvail *
|
---|
| 639 | (pDM->fsa.cSectorUnit * pDM->fsa.cbSector);
|
---|
[2] | 640 |
|
---|
[551] | 641 | ulPercentFree = (pDM->fsa.cUnit && pDM->fsa.cUnitAvail) ?
|
---|
| 642 | (pDM->fsa.cUnitAvail * 100) / pDM->fsa.cUnit : 0;
|
---|
[136] | 643 | }
|
---|
[2] | 644 |
|
---|
[551] | 645 | CommaFmtULL(szFreeQty, sizeof(szFreeQty), ullFreeQty, ' ');
|
---|
| 646 | *szDrvLtr = (CHAR) (id - MINI_DRIVEA) + 'A';
|
---|
[2] | 647 |
|
---|
[551] | 648 | if (!pDM || pDM->qfsi_rc || pDM->qfsa_rc)
|
---|
[136] | 649 | pszFSystem = "N/A";
|
---|
[551] | 650 | else {
|
---|
[689] | 651 | pszFSystem = (PCHAR)(pDM->fsqb2.szName) + pDM->fsqb2.cbName + 1;
|
---|
[136] | 652 | pszFSystem[15] = 0;
|
---|
| 653 | }
|
---|
| 654 | sprintf(s,
|
---|
[549] | 655 | "%s %13s %lu%%-%s %6s ",
|
---|
[136] | 656 | szDrvLtr,
|
---|
| 657 | szFreeQty,
|
---|
[551] | 658 | ulPercentFree, GetPString(IDS_FREETEXT), pszFSystem);
|
---|
[136] | 659 | if (!hps)
|
---|
| 660 | hps = WinGetPS(hwndChild);
|
---|
[551] | 661 | if (hps) {
|
---|
| 662 | if (!fDullMin) {
|
---|
[136] | 663 | ptl.x = 0;
|
---|
| 664 | ptl.y = 0;
|
---|
[551] | 665 | GpiMove(hps, &ptl);
|
---|
| 666 | GpiSetColor(hps, CLR_BLACK);
|
---|
[136] | 667 | ptl.x = swp.cx - 1;
|
---|
| 668 | ptl.y = swp.cy - 1;
|
---|
[551] | 669 | GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
|
---|
[136] | 670 | ptl.x = 1;
|
---|
| 671 | ptl.y = 1;
|
---|
[551] | 672 | if (ulPercentFree) {
|
---|
[136] | 673 | GpiMove(hps, &ptl);
|
---|
| 674 | GpiSetColor(hps,
|
---|
| 675 | (ulPercentFree < 11) ? CLR_DARKRED :
|
---|
| 676 | (ulPercentFree < 26) ? CLR_DARKBLUE :
|
---|
| 677 | CLR_DARKGREEN);
|
---|
| 678 | ptl.y = swp.cy - 2;
|
---|
| 679 | ptl.x = ((swp.cx - 2) * ulPercentFree) / 100;
|
---|
| 680 | wasx = ptl.x;
|
---|
[551] | 681 | GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
|
---|
[136] | 682 | GpiSetColor(hps,
|
---|
| 683 | (ulPercentFree < 11) ? CLR_RED :
|
---|
| 684 | (ulPercentFree < 26) ? CLR_BLUE : CLR_GREEN);
|
---|
| 685 | ptl.x = wasx;
|
---|
| 686 | ptl.y = swp.cy - 2;
|
---|
[551] | 687 | GpiMove(hps, &ptl);
|
---|
[136] | 688 | ptl.x = 1;
|
---|
[551] | 689 | GpiLine(hps, &ptl);
|
---|
[136] | 690 | ptl.y = 2;
|
---|
| 691 | ptl.x = 1;
|
---|
[551] | 692 | GpiLine(hps, &ptl);
|
---|
[136] | 693 | ptl.x = wasx;
|
---|
| 694 | }
|
---|
[551] | 695 | if (ulPercentFree < 99) {
|
---|
| 696 | GpiSetColor(hps, CLR_DARKGRAY);
|
---|
[136] | 697 | wasx = ptl.x;
|
---|
| 698 | ptl.y = 2;
|
---|
| 699 | GpiMove(hps, &ptl);
|
---|
| 700 | ptl.y = swp.cy - 2;
|
---|
| 701 | ptl.x = swp.cx - 2;
|
---|
[551] | 702 | GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
|
---|
[136] | 703 | ptl.x = wasx;
|
---|
[551] | 704 | GpiMove(hps, &ptl);
|
---|
| 705 | GpiSetColor(hps, CLR_PALEGRAY);
|
---|
[136] | 706 | ptl.x = swp.cx - 3;
|
---|
| 707 | GpiLine(hps, &ptl);
|
---|
| 708 | ptl.x = wasx;
|
---|
| 709 | ptl.y = 1;
|
---|
| 710 | GpiMove(hps, &ptl);
|
---|
[551] | 711 | GpiSetColor(hps, CLR_BLACK);
|
---|
[136] | 712 | ptl.x = swp.cx - 2;
|
---|
| 713 | GpiLine(hps, &ptl);
|
---|
| 714 | ptl.y = swp.cy - 3;
|
---|
| 715 | GpiLine(hps, &ptl);
|
---|
| 716 | }
|
---|
[551] | 717 | GpiSetColor(hps, CLR_WHITE);
|
---|
[136] | 718 | }
|
---|
[551] | 719 | else {
|
---|
| 720 | GpiSetColor(hps, CLR_PALEGRAY);
|
---|
[136] | 721 | ptl.x = 0;
|
---|
| 722 | ptl.y = 0;
|
---|
[551] | 723 | GpiMove(hps, &ptl);
|
---|
[136] | 724 | ptl.x = swp.cx - 1;
|
---|
| 725 | ptl.y = swp.cy - 1;
|
---|
[551] | 726 | GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
|
---|
[136] | 727 | GpiSetColor(hps,
|
---|
[551] | 728 | (ulPercentFree < 11) ? CLR_DARKRED : CLR_DARKBLUE);
|
---|
[136] | 729 | }
|
---|
[551] | 730 | GpiSetBackMix(hps, BM_LEAVEALONE);
|
---|
| 731 | GpiSetMix(hps, FM_OVERPAINT);
|
---|
[136] | 732 | {
|
---|
| 733 | POINTL aptl[TXTBOX_COUNT];
|
---|
[2] | 734 |
|
---|
[551] | 735 | GpiQueryTextBox(hps, strlen(s), s, TXTBOX_COUNT, aptl);
|
---|
[136] | 736 | ptl.y = ((swp.cy / 2) -
|
---|
| 737 | ((aptl[TXTBOX_TOPRIGHT].y +
|
---|
| 738 | aptl[TXTBOX_BOTTOMLEFT].y) / 2));
|
---|
| 739 | ptl.y++;
|
---|
| 740 | ptl.x = (swp.cx / 2) - (aptl[TXTBOX_TOPRIGHT].x / 2);
|
---|
| 741 | if (ptl.x < 2)
|
---|
| 742 | ptl.x = 2;
|
---|
[551] | 743 | GpiCharStringAt(hps, &ptl, strlen(s), s);
|
---|
[136] | 744 | }
|
---|
| 745 | if (!mp2)
|
---|
| 746 | WinReleasePS(hps);
|
---|
| 747 | }
|
---|
[551] | 748 | } // if drive window
|
---|
[136] | 749 | }
|
---|
| 750 | return 0;
|
---|
| 751 |
|
---|
| 752 | case UM_TIMER:
|
---|
| 753 | {
|
---|
[1397] | 754 | CHAR s[134], szDate[DATE_BUF_BYTES];
|
---|
[136] | 755 | DATETIME dt;
|
---|
| 756 |
|
---|
| 757 | if (fDataToFore && !NoFloat)
|
---|
| 758 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 759 | HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
|
---|
[551] | 760 | if (counter && (counter % 19) && (counter % 20)) {
|
---|
[1395] | 761 | if (!DosGetDateTime(&dt)) {
|
---|
| 762 | DTDateFormat(szDate, dt);
|
---|
[136] | 763 | sprintf(s,
|
---|
[1395] | 764 | " %02hu%s%02hu%s%02hu %s %s",
|
---|
| 765 | dt.hours, TimeSeparator,
|
---|
| 766 | dt.minutes, TimeSeparator,
|
---|
[136] | 767 | dt.seconds,
|
---|
| 768 | GetPString(IDS_SUNDAY + dt.weekday),
|
---|
[1395] | 769 | szDate);
|
---|
[551] | 770 | WinSetDlgItemText(hwnd, MINI_TIME, s);
|
---|
[136] | 771 | }
|
---|
[2] | 772 | }
|
---|
[136] | 773 | else if (!counter || !(counter % 19))
|
---|
| 774 | PostMsg(hwnd, UM_SETUP6, MPVOID, MPVOID); // Uptime
|
---|
[551] | 775 | if (!(counter % 4)) {
|
---|
[136] | 776 | PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID); // Memory utilization
|
---|
[551] | 777 | if (!(counter % 10)) {
|
---|
[136] | 778 | PostMsg(hwnd, UM_SETUP5, MPVOID, MPVOID); // Process status
|
---|
[551] | 779 | if (!(counter % 20)) {
|
---|
[136] | 780 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID); // Swapper
|
---|
| 781 | }
|
---|
| 782 | }
|
---|
| 783 | }
|
---|
| 784 | }
|
---|
| 785 | counter++;
|
---|
| 786 | return 0;
|
---|
[2] | 787 |
|
---|
[136] | 788 | case UM_SETUP2:
|
---|
| 789 | {
|
---|
[204] | 790 | CHAR s[134], szFileQty[38], szFreeQty[38];
|
---|
[841] | 791 | FILEFINDBUF3L ffb;
|
---|
[761] | 792 | ULONG nm = 1;
|
---|
[162] | 793 | ULONGLONG ullFreeQty;
|
---|
[136] | 794 | HDIR hdir = HDIR_CREATE;
|
---|
| 795 | FSALLOCATE fsa;
|
---|
[2] | 796 |
|
---|
[551] | 797 | if (*SwapperDat) {
|
---|
[136] | 798 | DosError(FERR_DISABLEHARDERR);
|
---|
[838] | 799 | if (!xDosFindFirst(SwapperDat, &hdir, FILE_NORMAL | FILE_HIDDEN |
|
---|
| 800 | FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY,
|
---|
[841] | 801 | &ffb, sizeof(ffb), &nm, FIL_STANDARDL)) {
|
---|
[136] | 802 | priority_bumped();
|
---|
| 803 | DosFindClose(hdir);
|
---|
| 804 | DosError(FERR_DISABLEHARDERR);
|
---|
| 805 | if (!DosQueryFSInfo(toupper(*SwapperDat) - '@', FSIL_ALLOC,
|
---|
[551] | 806 | &fsa, sizeof(FSALLOCATE))) {
|
---|
| 807 | ullFreeQty =
|
---|
| 808 | (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector);
|
---|
| 809 | CommaFmtULL(szFreeQty, sizeof(szFreeQty), ullFreeQty, ' ');
|
---|
[136] | 810 | }
|
---|
| 811 | else
|
---|
[162] | 812 | *szFreeQty = 0;
|
---|
| 813 |
|
---|
[551] | 814 | CommaFmtULL(szFileQty, sizeof(szFileQty), ffb.cbFile, ' ');
|
---|
[162] | 815 | sprintf(s, " %s %s%s%s",
|
---|
[136] | 816 | GetPString(IDS_SWAPTITLETEXT),
|
---|
[551] | 817 | szFileQty, *szFreeQty ? "/" : NullStr, szFreeQty);
|
---|
| 818 | WinSetDlgItemText(hwnd, MINI_SWAP, s);
|
---|
[136] | 819 | }
|
---|
| 820 | }
|
---|
| 821 | }
|
---|
| 822 | return 0;
|
---|
[2] | 823 |
|
---|
[136] | 824 | case UM_SETUP3: // Memory utilization
|
---|
| 825 | {
|
---|
[162] | 826 | CHAR s[134], tm[38], szQty[38];
|
---|
[136] | 827 | ULONG amem = 0;
|
---|
[2] | 828 |
|
---|
[136] | 829 | if (!DosQuerySysInfo(QSV_TOTAVAILMEM, QSV_TOTAVAILMEM,
|
---|
[551] | 830 | (PVOID) & amem, (ULONG) sizeof(amem))) {
|
---|
| 831 | CommaFmtUL(tm, sizeof(tm), amem, 'M');
|
---|
[162] | 832 | if (!Dos16MemAvail(&amem))
|
---|
[551] | 833 | CommaFmtUL(szQty, sizeof(szQty), amem, 'M');
|
---|
[136] | 834 | else
|
---|
[162] | 835 | *szQty = 0;
|
---|
| 836 | sprintf(s, " %s%s%s%s",
|
---|
[136] | 837 | GetPString(IDS_MEMTITLETEXT),
|
---|
[551] | 838 | szQty, (*szQty) ? "/" : NullStr, tm);
|
---|
| 839 | WinSetDlgItemText(hwnd, MINI_MEM, s);
|
---|
[2] | 840 | }
|
---|
[136] | 841 | }
|
---|
| 842 | return 0;
|
---|
[2] | 843 |
|
---|
[551] | 844 | case UM_SETUP5: // Process status
|
---|
[136] | 845 | {
|
---|
[828] | 846 | CHAR s[134], tm[38], szQty[38];
|
---|
[136] | 847 |
|
---|
[828] | 848 | if (fUseQProcStat && !noqproc) {
|
---|
[2] | 849 |
|
---|
[136] | 850 | PROCESSINFO *ppi;
|
---|
| 851 | BUFFHEADER *pbh = NULL;
|
---|
| 852 | MODINFO *pmi;
|
---|
| 853 | ULONG numprocs = 0, numthreads = 0;
|
---|
[346] | 854 | APIRET rc;
|
---|
[136] | 855 |
|
---|
[1438] | 856 | rc = xDosAllocMem((PVOID)&pbh, USHRT_MAX + 4096,
|
---|
[1439] | 857 | PAG_COMMIT | PAG_READ | PAG_WRITE,
|
---|
| 858 | pszSrcFile, __LINE__);
|
---|
[346] | 859 | if (rc)
|
---|
[551] | 860 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
| 861 | GetPString(IDS_OUTOFMEMORY));
|
---|
| 862 | else {
|
---|
[829] | 863 | if (DosQProcStatus((ULONG *)pbh, USHRT_MAX))
|
---|
[346] | 864 | noqproc = TRUE;
|
---|
| 865 | else {
|
---|
[551] | 866 | ppi = pbh->ppi;
|
---|
| 867 | while (ppi->ulEndIndicator != PROCESS_END_INDICATOR) {
|
---|
| 868 | pmi = pbh->pmi;
|
---|
| 869 | while (pmi && ppi->hModRef != pmi->hMod)
|
---|
| 870 | pmi = pmi->pNext;
|
---|
| 871 | if (pmi) {
|
---|
[136] | 872 | numprocs++;
|
---|
[551] | 873 | numthreads += ppi->usThreadCount;
|
---|
[136] | 874 | }
|
---|
[551] | 875 | ppi = (PPROCESSINFO) (ppi->ptiFirst + ppi->usThreadCount);
|
---|
[36] | 876 | }
|
---|
[136] | 877 | commafmt(szQty, sizeof(szQty), numprocs);
|
---|
| 878 | commafmt(tm, sizeof(tm), numthreads);
|
---|
| 879 | sprintf(s,
|
---|
| 880 | " %s%s %s%s",
|
---|
| 881 | GetPString(IDS_PROCSTITLETEXT),
|
---|
[551] | 882 | szQty, GetPString(IDS_THRDSTITLETEXT), tm);
|
---|
| 883 | WinSetDlgItemText(hwnd, MINI_PROC, s);
|
---|
[136] | 884 | }
|
---|
| 885 | DosFreeMem(pbh);
|
---|
| 886 | }
|
---|
[2] | 887 | }
|
---|
[828] | 888 | else if (fUseQSysState && !noqproc) {
|
---|
| 889 |
|
---|
| 890 | QSPREC *ppi;
|
---|
| 891 | QSPTRREC *pbh = NULL;
|
---|
| 892 | QSLREC *pmi;
|
---|
| 893 | ULONG numprocs = 0, numthreads = 0;
|
---|
| 894 | APIRET rc;
|
---|
| 895 |
|
---|
[1438] | 896 | rc = xDosAllocMem((PVOID) & pbh, USHRT_MAX + 4096,
|
---|
[1439] | 897 | PAG_COMMIT | PAG_READ | PAG_WRITE,
|
---|
| 898 | pszSrcFile, __LINE__);
|
---|
[828] | 899 | if (rc)
|
---|
| 900 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
| 901 | GetPString(IDS_OUTOFMEMORY));
|
---|
| 902 | else { //2 Sep 07 GKY 0x05 = process & Mod data only
|
---|
| 903 | if (DosQuerySysState(QS_PROCESS | QS_MTE, 0, 0, 0, pbh, USHRT_MAX))
|
---|
| 904 | noqproc = TRUE;
|
---|
| 905 | else {
|
---|
| 906 | ppi = pbh->pProcRec;
|
---|
| 907 | while (ppi->RecType == 1) {
|
---|
| 908 | pmi = pbh->pLibRec;
|
---|
| 909 | while (pmi && ppi->hMte != pmi->hmte)
|
---|
| 910 | pmi = pmi->pNextRec;
|
---|
| 911 | if (pmi) {
|
---|
| 912 | numprocs++;
|
---|
| 913 | numthreads += ppi->cTCB;
|
---|
| 914 | }
|
---|
| 915 | ppi = (QSPREC *) (ppi->pThrdRec + ppi->cTCB);
|
---|
| 916 | }
|
---|
| 917 | commafmt(szQty, sizeof(szQty), numprocs);
|
---|
| 918 | commafmt(tm, sizeof(tm), numthreads);
|
---|
| 919 | sprintf(s,
|
---|
| 920 | " %s%s %s%s",
|
---|
| 921 | GetPString(IDS_PROCSTITLETEXT),
|
---|
| 922 | szQty, GetPString(IDS_THRDSTITLETEXT), tm);
|
---|
| 923 | WinSetDlgItemText(hwnd, MINI_PROC, s);
|
---|
| 924 | }
|
---|
| 925 | DosFreeMem(pbh);
|
---|
| 926 | }
|
---|
| 927 | }
|
---|
[551] | 928 | else {
|
---|
[136] | 929 | commafmt(szQty, sizeof(szQty),
|
---|
[551] | 930 | WinQuerySwitchList(WinQueryAnchorBlock(hwnd), (PSWBLOCK) 0,
|
---|
| 931 | 0));
|
---|
| 932 | sprintf(s, " %s%s", GetPString(IDS_TASKSTITLETEXT), szQty);
|
---|
| 933 | WinSetDlgItemText(hwnd, MINI_PROC, s);
|
---|
[2] | 934 | }
|
---|
[136] | 935 | }
|
---|
| 936 | return 0;
|
---|
[2] | 937 |
|
---|
[136] | 938 | case UM_SETUP6: // Uptime
|
---|
| 939 | {
|
---|
| 940 | ULONG val = 0, numdays, nummins;
|
---|
| 941 | CHAR s[128];
|
---|
| 942 |
|
---|
| 943 | if (!DosQuerySysInfo(QSV_MS_COUNT,
|
---|
| 944 | QSV_MS_COUNT,
|
---|
[551] | 945 | (PVOID) & val, (ULONG) sizeof(val))) {
|
---|
[136] | 946 | val /= 60000L;
|
---|
| 947 | numdays = val / (60L * 24L);
|
---|
| 948 | strcpy(s, GetPString(IDS_ELAPSEDTITLETEXT));
|
---|
| 949 | if (numdays)
|
---|
| 950 | sprintf(s + strlen(s),
|
---|
| 951 | " %lu %s%s, ",
|
---|
[551] | 952 | numdays, GetPString(IDS_DAYTEXT), &"s"[numdays == 1L]);
|
---|
[136] | 953 | nummins = val % (60L * 24L);
|
---|
[1395] | 954 | sprintf(s + strlen(s), " %lu%s%02lu", nummins / 60, TimeSeparator, nummins % 60);
|
---|
[551] | 955 | WinSetDlgItemText(hwnd, MINI_TIME, s);
|
---|
[2] | 956 | }
|
---|
[136] | 957 | }
|
---|
| 958 | return 0;
|
---|
[2] | 959 |
|
---|
[136] | 960 | case WM_SAVEAPPLICATION:
|
---|
| 961 | {
|
---|
| 962 | SWP swp;
|
---|
[2] | 963 |
|
---|
[136] | 964 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
|
---|
[551] | 965 | PrfWriteProfileData(fmprof, appname, "DataMinPos", &swp, sizeof(SWP));
|
---|
[136] | 966 | }
|
---|
| 967 | break;
|
---|
[2] | 968 |
|
---|
[136] | 969 | case WM_CLOSE:
|
---|
[551] | 970 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
---|
[136] | 971 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 972 | return 0;
|
---|
[2] | 973 |
|
---|
[136] | 974 | case WM_DESTROY:
|
---|
[551] | 975 | if (DataHwnd == WinQueryWindow(hwnd, QW_PARENT)) {
|
---|
| 976 | DataHwnd = (HWND) 0;
|
---|
[136] | 977 | if (hwndMenu)
|
---|
| 978 | WinDestroyWindow(hwndMenu);
|
---|
[551] | 979 | hwndMenu = (HWND) 0;
|
---|
[136] | 980 | }
|
---|
[551] | 981 | if (hwndMain) {
|
---|
[2] | 982 |
|
---|
[136] | 983 | SWP swp;
|
---|
| 984 | ULONG fl = SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE, ofl;
|
---|
[2] | 985 |
|
---|
[136] | 986 | ofl = WinQueryWindowULong(hwnd, QWL_USER);
|
---|
| 987 | WinQueryWindowPos(WinQueryWindow(hwndMain, QW_PARENT), &swp);
|
---|
| 988 | if (swp.fl & SWP_MINIMIZE)
|
---|
| 989 | fl |= ((ofl & SWP_MAXIMIZE) ? SWP_MAXIMIZE : SWP_RESTORE);
|
---|
| 990 | WinSetWindowPos(WinQueryWindow(hwndMain, QW_PARENT),
|
---|
[551] | 991 | HWND_TOP, 0, 0, 0, 0, fl);
|
---|
[136] | 992 | }
|
---|
[551] | 993 | else if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 994 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
[136] | 995 | break;
|
---|
| 996 | }
|
---|
| 997 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 998 |
|
---|
[551] | 999 | } // DataProc
|
---|
[2] | 1000 |
|
---|
[136] | 1001 | //=== CreateDataBar - create databar windows ===
|
---|
[2] | 1002 |
|
---|
[136] | 1003 | HWND CreateDataBar(HWND hwndParent, ULONG fl)
|
---|
| 1004 | {
|
---|
[551] | 1005 | HWND hwndClient = (HWND) 0;
|
---|
[136] | 1006 | ULONG FrameFlags = 0;
|
---|
[2] | 1007 |
|
---|
[136] | 1008 | if (WinCreateStdWindow(hwndParent,
|
---|
| 1009 | WS_VISIBLE,
|
---|
| 1010 | &FrameFlags,
|
---|
[593] | 1011 | WC_DATABAR,
|
---|
[551] | 1012 | NULL, WS_VISIBLE, 0, MINI_FRAME, &hwndClient)) {
|
---|
| 1013 | WinSendMsg(hwndClient, UM_RESTORE, MPFROMLONG(fl), MPVOID);
|
---|
[136] | 1014 | }
|
---|
| 1015 | return hwndClient;
|
---|
[2] | 1016 |
|
---|
[551] | 1017 | } // CreateDataBar
|
---|
[2] | 1018 |
|
---|
[136] | 1019 | //=== dataminThread - drive status thread ===
|
---|
[2] | 1020 |
|
---|
[551] | 1021 | static VOID dataminThread(VOID * pv)
|
---|
[136] | 1022 | {
|
---|
[551] | 1023 | HAB hab = NULLHANDLE;
|
---|
| 1024 | HMQ hmq = NULLHANDLE;
|
---|
| 1025 | HWND hwndParent = (HWND) pv;
|
---|
| 1026 | HWND hwnd;
|
---|
| 1027 | HENUM henum;
|
---|
[136] | 1028 | BOOL busy = TRUE;
|
---|
| 1029 | APIRET rc;
|
---|
| 1030 | USHORT id;
|
---|
| 1031 |
|
---|
[1038] | 1032 | # ifdef FORTIFY
|
---|
| 1033 | Fortify_EnterScope();
|
---|
[1063] | 1034 | # endif
|
---|
[551] | 1035 | if (G_hevDataMin == NULLHANDLE) {
|
---|
[136] | 1036 | // Create just once for any thread that might use it
|
---|
| 1037 | // Kernel will clean up on exit
|
---|
[551] | 1038 | rc = DosCreateEventSem(NULL, (PHEV) & G_hevDataMin, 0L, FALSE);
|
---|
[136] | 1039 | if (rc) {
|
---|
[1335] | 1040 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 1041 | GetPString(IDS_CREATESEMFAILED));
|
---|
[136] | 1042 | busy = FALSE;
|
---|
| 1043 | }
|
---|
| 1044 | }
|
---|
| 1045 |
|
---|
[179] | 1046 | // fixme to report errors
|
---|
[136] | 1047 | hab = WinInitialize(0);
|
---|
| 1048 | if (hab == NULLHANDLE)
|
---|
| 1049 | busy = FALSE;
|
---|
[551] | 1050 | else {
|
---|
| 1051 | hmq = WinCreateMsgQueue(hab, 0);
|
---|
[136] | 1052 | if (hmq == NULLHANDLE)
|
---|
| 1053 | busy = FALSE;
|
---|
| 1054 | else
|
---|
[551] | 1055 | WinCancelShutdown(hmq, TRUE);
|
---|
[136] | 1056 | }
|
---|
| 1057 |
|
---|
[551] | 1058 | while (busy) {
|
---|
[136] | 1059 | HWND hwndSingle = G_hwndSingle;
|
---|
[551] | 1060 |
|
---|
[136] | 1061 | G_hwndSingle = NULLHANDLE;
|
---|
| 1062 |
|
---|
| 1063 | busy = FALSE;
|
---|
| 1064 |
|
---|
[551] | 1065 | if (!WinIsWindow(hab, hwndParent))
|
---|
[2] | 1066 | break;
|
---|
| 1067 |
|
---|
[136] | 1068 | henum = WinBeginEnumWindows(hwndParent);
|
---|
[551] | 1069 | while (henum && (hwnd = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
| 1070 | if (!WinIsWindow(hab, hwnd))
|
---|
[136] | 1071 | continue;
|
---|
| 1072 | if (hwndSingle && hwndSingle != hwnd)
|
---|
| 1073 | continue;
|
---|
[551] | 1074 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 1075 | if (id > MINI_DRIVEA) {
|
---|
[136] | 1076 | ULONG dskNum = id - MINI_DRIVEA + 1;
|
---|
| 1077 | tDataMin *pDM = WinQueryWindowPtr(hwnd, QWL_DATAMIN_PTR);
|
---|
| 1078 | SWP swp;
|
---|
| 1079 | CHAR szPath[] = " :";
|
---|
[551] | 1080 |
|
---|
[136] | 1081 | if (!pDM)
|
---|
| 1082 | continue;
|
---|
| 1083 | busy = TRUE;
|
---|
| 1084 | if (!WinQueryWindowPos(hwnd, &swp))
|
---|
| 1085 | continue;
|
---|
[2] | 1086 |
|
---|
[136] | 1087 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 1088 | pDM->qfsi_rc = DosQueryFSInfo(dskNum,
|
---|
| 1089 | FSIL_ALLOC,
|
---|
| 1090 | &pDM->fsa, sizeof(FSALLOCATE));
|
---|
[2] | 1091 |
|
---|
[551] | 1092 | if (!pDM->qfsi_rc) {
|
---|
[136] | 1093 | *szPath = (CHAR) dskNum + 'A' - 1;
|
---|
[551] | 1094 | pDM->qfsa_cb = sizeof(FSQBUFFER2) + 256; // se tDataMin
|
---|
[136] | 1095 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 1096 | pDM->qfsa_rc = DosQueryFSAttach(szPath, 0, /* Ordinal */
|
---|
| 1097 | FSAIL_QUERYNAME,
|
---|
| 1098 | &pDM->fsqb2, &pDM->qfsa_cb);
|
---|
[136] | 1099 | }
|
---|
| 1100 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
[551] | 1101 | } // if drive window
|
---|
| 1102 | } // while henum
|
---|
[136] | 1103 | WinEndEnumWindows(henum);
|
---|
[2] | 1104 |
|
---|
[551] | 1105 | if (busy) {
|
---|
[136] | 1106 | ULONG clPosted;
|
---|
[551] | 1107 |
|
---|
| 1108 | rc = DosWaitEventSem(G_hevDataMin, 20000L);
|
---|
| 1109 | if (rc && rc != ERROR_TIMEOUT) {
|
---|
[1335] | 1110 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 1111 | GetPString(IDS_POSTSEMFAILED));
|
---|
[2] | 1112 | }
|
---|
| 1113 |
|
---|
[551] | 1114 | rc = DosResetEventSem(G_hevDataMin, &clPosted);
|
---|
| 1115 | if (rc && rc != ERROR_ALREADY_RESET) {
|
---|
[1335] | 1116 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 1117 | GetPString(IDS_POSTSEMFAILED));
|
---|
[136] | 1118 | }
|
---|
| 1119 | }
|
---|
[2] | 1120 |
|
---|
[551] | 1121 | } // while
|
---|
[2] | 1122 |
|
---|
[136] | 1123 | if (hmq != NULLHANDLE)
|
---|
| 1124 | WinDestroyMsgQueue(hmq);
|
---|
[2] | 1125 |
|
---|
[136] | 1126 | if (hab != NULLHANDLE)
|
---|
| 1127 | WinTerminate(hab);
|
---|
[1063] | 1128 | # ifdef FORTIFY
|
---|
[1038] | 1129 | Fortify_LeaveScope();
|
---|
[1063] | 1130 | # endif
|
---|
[551] | 1131 | } // dataminThread
|
---|
[793] | 1132 |
|
---|
| 1133 | #pragma alloc_text(DATAMIN,DataDlgProc,MiniTimeProc)
|
---|