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