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