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