[356] | 1 | /***********************************************************************
|
---|
| 2 |
|
---|
| 3 | $Id: notify.c 1395 2009-02-08 01:48:16Z gyoung $
|
---|
| 4 |
|
---|
[1002] | 5 | Thread notes window and popup notification status line
|
---|
[356] | 6 |
|
---|
| 7 | Copyright (c) 1993-98 M. Kimes
|
---|
[1394] | 8 | Copyright (c) 2006, 2009 Steven H.Levine
|
---|
[356] | 9 |
|
---|
| 10 | 17 Jul 06 SHL Use Win_Error
|
---|
| 11 | 22 Jul 06 SHL Check more run time errors
|
---|
[593] | 12 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
[775] | 13 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
[793] | 14 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[1002] | 15 | 16 Apr 08 SHL Comment and clean up logic
|
---|
[1335] | 16 | 10 Dec 08 SHL Integrate exception handler support
|
---|
[1391] | 17 | 11 Jan 09 GKY Replace font names in the string file with global set at compile in init.c
|
---|
[1395] | 18 | 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
|
---|
| 19 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
|
---|
[356] | 20 |
|
---|
| 21 | ***********************************************************************/
|
---|
| 22 |
|
---|
[2] | 23 | #include <stdlib.h>
|
---|
| 24 | #include <string.h>
|
---|
| 25 | #include <ctype.h>
|
---|
[1163] | 26 | #include <stddef.h> // _threadid
|
---|
[1335] | 27 | // #include <process.h> // _beginthread
|
---|
[356] | 28 |
|
---|
[907] | 29 | #define INCL_DOS
|
---|
| 30 | #define INCL_WIN
|
---|
| 31 | #define INCL_GPI
|
---|
[1163] | 32 | #define INCL_LONGLONG // dircnrs.h
|
---|
[907] | 33 |
|
---|
[1211] | 34 | #include "fm3dll.h"
|
---|
[1225] | 35 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1211] | 36 | #include "collect.h" // Data declaration(s)
|
---|
| 37 | #include "grep.h" // Data declaration(s)
|
---|
| 38 | #include "notebook.h" // Data declaration(s)
|
---|
| 39 | #include "init.h" // Data declaration(s)
|
---|
[2] | 40 | #include "fm3dlg.h"
|
---|
| 41 | #include "fm3str.h"
|
---|
[1163] | 42 | #include "errutil.h" // Dos_Error...
|
---|
| 43 | #include "strutil.h" // GetPString
|
---|
| 44 | #include "notify.h"
|
---|
[1188] | 45 | #include "presparm.h" // SetPresParams
|
---|
[1211] | 46 | #include "mainwnd.h" // Data declaration(s)
|
---|
[1188] | 47 | #include "wrappers.h" // xmalloc
|
---|
| 48 | #include "misc.h" // PostMsg
|
---|
[1038] | 49 | #include "fortify.h"
|
---|
[1335] | 50 | #include "excputil.h" // xbeginthread
|
---|
[2] | 51 |
|
---|
| 52 | #pragma data_seg(DATA1)
|
---|
[356] | 53 |
|
---|
[1211] | 54 | // Data definitions
|
---|
[356] | 55 | static PSZ pszSrcFile = __FILE__;
|
---|
[1163] | 56 | static volatile HWND hwndNotify; // 16 Apr 08 SHL
|
---|
[2] | 57 |
|
---|
[1211] | 58 | #pragma data_seg(GLOBAL1)
|
---|
| 59 | BOOL fThreadNotes;
|
---|
| 60 |
|
---|
[1163] | 61 | VOID StartNotes(CHAR * s);
|
---|
| 62 |
|
---|
[1002] | 63 | /**
|
---|
| 64 | * Popup notification message window procedure
|
---|
| 65 | * Display timed message over status line
|
---|
| 66 | */
|
---|
| 67 |
|
---|
[551] | 68 | MRESULT EXPENTRY NotifyWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[356] | 69 | {
|
---|
[2] | 70 | static ULONG showing = 0;
|
---|
| 71 |
|
---|
[551] | 72 | switch (msg) {
|
---|
| 73 | case WM_CREATE:
|
---|
| 74 | showing++;
|
---|
| 75 | {
|
---|
[1002] | 76 | MRESULT rc = PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
[2] | 77 |
|
---|
[551] | 78 | if (!WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_TIMER2, 5000)) {
|
---|
[1335] | 79 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "WinStartTimer");
|
---|
| 80 | WinDestroyWindow(hwnd);
|
---|
[551] | 81 | }
|
---|
| 82 | else {
|
---|
[2] | 83 |
|
---|
[1335] | 84 | RGB2 rgb2F, rgb2;
|
---|
[2] | 85 |
|
---|
[1335] | 86 | memset(&rgb2F, 0, sizeof(RGB2));
|
---|
| 87 | rgb2F.bRed = (BYTE)65;
|
---|
| 88 | rgb2.bRed = rgb2.bGreen = rgb2.bBlue = (BYTE)255;
|
---|
[1394] | 89 | rgb2.fcOptions = 0;
|
---|
| 90 | //fixme to allow user to change presparams 1-10-09 GKY
|
---|
[1391] | 91 | SetPresParams(hwnd, &rgb2, &rgb2F, &rgb2, FNT_8HELVETICA);
|
---|
[1335] | 92 | if (hwndMain) {
|
---|
| 93 | if (hwndStatus)
|
---|
| 94 | WinShowWindow(hwndStatus, FALSE);
|
---|
| 95 | if (hwndStatus2)
|
---|
| 96 | WinShowWindow(hwndStatus2, FALSE);
|
---|
| 97 | }
|
---|
| 98 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
[2] | 99 | }
|
---|
[551] | 100 | return rc;
|
---|
| 101 | }
|
---|
[2] | 102 |
|
---|
[551] | 103 | case UM_SETUP:
|
---|
| 104 | WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_SHOW);
|
---|
| 105 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
| 106 | return 0;
|
---|
[2] | 107 |
|
---|
[551] | 108 | case WM_SETFOCUS:
|
---|
| 109 | if (mp2)
|
---|
| 110 | PostMsg(hwnd, UM_REPLACEFOCUS, mp1, MPVOID);
|
---|
| 111 | break;
|
---|
[2] | 112 |
|
---|
[551] | 113 | case UM_REPLACEFOCUS:
|
---|
| 114 | if (mp1)
|
---|
| 115 | WinSetFocus(HWND_DESKTOP, (HWND) mp1);
|
---|
| 116 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 117 | return 0;
|
---|
[2] | 118 |
|
---|
[551] | 119 | case WM_PAINT:
|
---|
| 120 | {
|
---|
| 121 | SWP swp;
|
---|
| 122 | POINTL ptl;
|
---|
[2] | 123 |
|
---|
[1002] | 124 | MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
| 125 | HPS hps = WinGetPS(hwnd);
|
---|
[551] | 126 | if (hps) {
|
---|
[1335] | 127 | if (WinQueryWindowPos(hwnd, &swp)) {
|
---|
| 128 | ptl.x = 0;
|
---|
| 129 | ptl.y = 0;
|
---|
| 130 | GpiMove(hps, &ptl);
|
---|
| 131 | GpiSetColor(hps, CLR_RED);
|
---|
| 132 | ptl.x = swp.cx - 1;
|
---|
| 133 | ptl.y = swp.cy - 1;
|
---|
| 134 | GpiBox(hps, DRO_OUTLINE, &ptl, 2, 2);
|
---|
| 135 | }
|
---|
| 136 | WinReleasePS(hwnd);
|
---|
[2] | 137 | }
|
---|
[551] | 138 | return mr;
|
---|
| 139 | }
|
---|
[2] | 140 |
|
---|
[551] | 141 | case WM_BUTTON1DOWN:
|
---|
| 142 | case WM_BUTTON2DOWN:
|
---|
| 143 | case WM_BUTTON3DOWN:
|
---|
| 144 | case WM_TIMER:
|
---|
| 145 | case WM_CLOSE:
|
---|
| 146 | WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_TIMER2);
|
---|
| 147 | WinDestroyWindow(hwnd);
|
---|
| 148 | return 0;
|
---|
[2] | 149 |
|
---|
[551] | 150 | case WM_DESTROY:
|
---|
| 151 | showing--;
|
---|
| 152 | if (!showing && hwndMain) {
|
---|
| 153 | if (hwndStatus)
|
---|
[1335] | 154 | WinShowWindow(hwndStatus, TRUE);
|
---|
[551] | 155 | if (hwndStatus2)
|
---|
[1335] | 156 | WinShowWindow(hwndStatus2, TRUE);
|
---|
[551] | 157 | }
|
---|
| 158 | break;
|
---|
[2] | 159 | }
|
---|
[551] | 160 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
[2] | 161 | }
|
---|
| 162 |
|
---|
[1002] | 163 | /**
|
---|
| 164 | * Display timed notification window over status line
|
---|
| 165 | */
|
---|
| 166 |
|
---|
[1394] | 167 | HWND DoNotify(PCSZ str)
|
---|
[356] | 168 | {
|
---|
[551] | 169 | char *p;
|
---|
| 170 | HWND hwnd = (HWND) 0, hwndP;
|
---|
| 171 | LONG x, y, cx, cy;
|
---|
| 172 | SWP swp, swpS, swpS2;
|
---|
[2] | 173 | static USHORT id = NOTE_FRAME;
|
---|
| 174 |
|
---|
[551] | 175 | if (str && *str) {
|
---|
[1002] | 176 | // figure out what size the window should be and where it should be
|
---|
| 177 | hwndP = hwndMain ? WinQueryWindow(hwndMain, QW_PARENT) : HWND_DESKTOP;
|
---|
[551] | 178 | WinQueryWindowPos(hwndP, &swp);
|
---|
| 179 | if (hwndStatus)
|
---|
| 180 | WinQueryWindowPos(hwndStatus, &swpS);
|
---|
| 181 | if (hwndStatus2)
|
---|
| 182 | WinQueryWindowPos(hwndStatus2, &swpS2);
|
---|
[1002] | 183 | x = hwndMain ? (hwndStatus ? swpS.x - 1 :
|
---|
[1335] | 184 | WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER)) : 0;
|
---|
[1002] | 185 | y = hwndMain ? (hwndStatus ? swpS.y - 1 :
|
---|
[1335] | 186 | WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER)) : 0;
|
---|
[551] | 187 | if (hwndMain && hwndStatus) {
|
---|
| 188 | if (hwndStatus2)
|
---|
[1335] | 189 | cx = swpS2.cx + swpS.cx + 8;
|
---|
[2] | 190 | else
|
---|
[1335] | 191 | cx = swpS.cx + 6;
|
---|
[2] | 192 | }
|
---|
| 193 | else
|
---|
| 194 | cx = (swp.cx - ((x * 2) + 4));
|
---|
[1002] | 195 | cy = hwndMain ? (hwndStatus ? swpS.cy + 2 : 28) : 28;
|
---|
[2] | 196 |
|
---|
[1002] | 197 | // pretty-up the note by putting on a leading space
|
---|
[551] | 198 | if (*str != ' ') {
|
---|
| 199 | p = xmalloc(strlen(str) + 2, pszSrcFile, __LINE__);
|
---|
| 200 | if (!p)
|
---|
[1394] | 201 | p = (PSZ)str;
|
---|
[2] | 202 | else {
|
---|
[1335] | 203 | strcpy(p + 1, str);
|
---|
| 204 | *p = ' ';
|
---|
[2] | 205 | }
|
---|
| 206 | }
|
---|
| 207 | else
|
---|
[1394] | 208 | p = (PSZ)str;
|
---|
[2] | 209 |
|
---|
| 210 | hwnd = WinCreateWindow(hwndP,
|
---|
[1335] | 211 | WC_ERRORWND,
|
---|
| 212 | p,
|
---|
| 213 | SS_TEXT | DT_LEFT | DT_VCENTER | WS_VISIBLE,
|
---|
| 214 | x, y, cx, cy, hwndP, HWND_TOP, id++, NULL, NULL);
|
---|
[377] | 215 | if (!hwndP)
|
---|
[1395] | 216 | Win_Error(hwndP, hwndP, pszSrcFile, __LINE__,
|
---|
| 217 | PCSZ_WINCREATEWINDOW);
|
---|
[377] | 218 |
|
---|
[551] | 219 | if (p != str)
|
---|
[1039] | 220 | free(p);
|
---|
[551] | 221 | if (id > NOTE_MAX)
|
---|
[2] | 222 | id = NOTE_FRAME;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | AddNote(str);
|
---|
| 226 |
|
---|
| 227 | return hwnd;
|
---|
| 228 | }
|
---|
| 229 |
|
---|
[1002] | 230 | /**
|
---|
| 231 | * Add message to thread notes window
|
---|
| 232 | */
|
---|
| 233 |
|
---|
[1394] | 234 | HWND Notify(PCSZ str)
|
---|
[356] | 235 | {
|
---|
[1002] | 236 | return (HWND)WinSendMsg(MainObjectHwnd, UM_NOTIFY, MPFROMP(str), MPVOID);
|
---|
[2] | 237 | }
|
---|
| 238 |
|
---|
[1002] | 239 | /**
|
---|
| 240 | * Add error message to thread notes window
|
---|
| 241 | */
|
---|
| 242 |
|
---|
[1394] | 243 | VOID NotifyError(PCSZ filename, APIRET status)
|
---|
[356] | 244 | {
|
---|
[2] | 245 | CHAR errortext[512];
|
---|
| 246 |
|
---|
[551] | 247 | if (!filename)
|
---|
[2] | 248 | return;
|
---|
[551] | 249 | sprintf(errortext, GetPString(IDS_ERRORACCESSTEXT), status, filename);
|
---|
| 250 | if (toupper(*filename) > 'B') {
|
---|
| 251 | if (status == 21)
|
---|
| 252 | strcat(errortext, GetPString(IDS_EMPTYREMOVETEXT));
|
---|
| 253 | else if (status == 27)
|
---|
[2] | 254 | strcat(errortext, GetPString(IDS_CDMUSICTEXT));
|
---|
[551] | 255 | else if (status == 19)
|
---|
| 256 | strcat(errortext, GetPString(IDS_WRITEPROTECTTEXT));
|
---|
| 257 | else if (status == 108)
|
---|
| 258 | strcat(errortext, GetPString(IDS_DRIVELOCKEDTEXT));
|
---|
[2] | 259 | }
|
---|
| 260 | else {
|
---|
[551] | 261 | if (status == 21)
|
---|
| 262 | strcat(errortext, GetPString(IDS_EMPTYFLOPPYTEXT));
|
---|
| 263 | else if (status == 27)
|
---|
| 264 | strcat(errortext, GetPString(IDS_UNFORMATEDTEXT));
|
---|
| 265 | else if (status == 107)
|
---|
[2] | 266 | sprintf(&errortext[strlen(errortext)],
|
---|
[1335] | 267 | GetPString(IDS_PHANTOMTEXT), toupper(*filename));
|
---|
[551] | 268 | else if (status == 19)
|
---|
| 269 | strcat(errortext, GetPString(IDS_DISKWRITEPROTEXTTEXT));
|
---|
| 270 | else if (status == 108)
|
---|
| 271 | strcat(errortext, GetPString(IDS_DISKLOCKEDTEXT));
|
---|
[2] | 272 | }
|
---|
[1395] | 273 | if (!fErrorBeepOff) {
|
---|
| 274 | DosBeep(250, 10);
|
---|
| 275 | DosBeep(500, 10);
|
---|
| 276 | DosBeep(250, 10);
|
---|
| 277 | DosBeep(500, 10);
|
---|
| 278 | }
|
---|
[2] | 279 | Notify(errortext);
|
---|
| 280 | }
|
---|
| 281 |
|
---|
[1002] | 282 | /**
|
---|
| 283 | * Thread notes dialog window dialog procedure
|
---|
| 284 | */
|
---|
| 285 |
|
---|
[551] | 286 | MRESULT EXPENTRY NoteWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[356] | 287 | {
|
---|
[551] | 288 | static HPOINTER hptrIcon = (HPOINTER) 0;
|
---|
[2] | 289 |
|
---|
[551] | 290 | switch (msg) {
|
---|
| 291 | case WM_INITDLG:
|
---|
[1002] | 292 | if (hwndNotify != (HWND)0) {
|
---|
| 293 | // Already have notes dialog - pass message on
|
---|
[551] | 294 | if (mp2) {
|
---|
[1335] | 295 | WinSendDlgItemMsg(hwndNotify,
|
---|
| 296 | NOTE_LISTBOX,
|
---|
| 297 | LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0), mp2);
|
---|
| 298 | PostMsg(hwndNotify, UM_NOTIFY, MPVOID, MPVOID);
|
---|
| 299 | free((CHAR *)mp2);
|
---|
[2] | 300 | }
|
---|
[551] | 301 | WinDismissDlg(hwnd, 0);
|
---|
| 302 | break;
|
---|
| 303 | }
|
---|
| 304 | hwndNotify = hwnd;
|
---|
| 305 | fThreadNotes = FALSE;
|
---|
[1002] | 306 | // Remember showing
|
---|
[551] | 307 | {
|
---|
| 308 | BOOL dummy = TRUE;
|
---|
| 309 | PrfWriteProfileData(fmprof,
|
---|
[1335] | 310 | FM3Str, "ThreadNotes", &dummy, sizeof(BOOL));
|
---|
[551] | 311 | }
|
---|
| 312 | if (mp2) {
|
---|
| 313 | WinSendDlgItemMsg(hwnd,
|
---|
[1335] | 314 | NOTE_LISTBOX,
|
---|
| 315 | LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0), mp2);
|
---|
[1039] | 316 | free((CHAR *)mp2);
|
---|
[551] | 317 | }
|
---|
[1002] | 318 |
|
---|
[551] | 319 | {
|
---|
[1002] | 320 | // Return focus
|
---|
| 321 | HWND hwndActive = WinQueryActiveWindow(HWND_DESKTOP);
|
---|
[551] | 322 | PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(hwndActive), MPVOID);
|
---|
| 323 | }
|
---|
[1002] | 324 |
|
---|
[551] | 325 | hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, NOTE_FRAME);
|
---|
| 326 | if (hptrIcon)
|
---|
| 327 | WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPFROMLONG(0L));
|
---|
| 328 | break;
|
---|
[2] | 329 |
|
---|
[551] | 330 | case UM_FOCUSME:
|
---|
| 331 | {
|
---|
| 332 | ULONG size = sizeof(SWP),
|
---|
[1335] | 333 | fl = SWP_ZORDER | SWP_FOCUSDEACTIVATE | SWP_SHOW;
|
---|
[551] | 334 | SWP swp;
|
---|
[2] | 335 |
|
---|
[551] | 336 | if (PrfQueryProfileData(fmprof,
|
---|
[1335] | 337 | FM3Str, "NoteWndSwp", (PVOID) & swp, &size)) {
|
---|
| 338 | if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
|
---|
| 339 | fl |= SWP_MINIMIZE;
|
---|
| 340 | fl &= (~SWP_SHOW);
|
---|
| 341 | }
|
---|
| 342 | else
|
---|
| 343 | fl |= (SWP_MOVE | SWP_SIZE);
|
---|
[2] | 344 | }
|
---|
[551] | 345 | WinSetWindowPos(hwnd, HWND_BOTTOM, swp.x, swp.y, swp.cx, swp.cy, fl);
|
---|
| 346 | if (fl & SWP_MINIMIZE) {
|
---|
[1335] | 347 | WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT) swp.x);
|
---|
| 348 | WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT) swp.cx);
|
---|
| 349 | WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT) swp.y);
|
---|
| 350 | WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT) swp.cy);
|
---|
[551] | 351 | }
|
---|
| 352 | }
|
---|
| 353 | if (mp1)
|
---|
| 354 | WinSetActiveWindow(HWND_DESKTOP, (HWND) mp1);
|
---|
| 355 | return 0;
|
---|
[2] | 356 |
|
---|
[551] | 357 | case UM_STRETCH:
|
---|
| 358 | {
|
---|
| 359 | SWP swp;
|
---|
| 360 | LONG titl, szbx, szby;
|
---|
[2] | 361 |
|
---|
[551] | 362 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 363 | if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) {
|
---|
[1335] | 364 | szbx = SysVal(SV_CXSIZEBORDER);
|
---|
| 365 | szby = SysVal(SV_CYSIZEBORDER);
|
---|
| 366 | titl = SysVal(SV_CYTITLEBAR);
|
---|
| 367 | WinSetWindowPos(WinWindowFromID(hwnd, NOTE_LISTBOX),
|
---|
| 368 | HWND_TOP,
|
---|
| 369 | szbx,
|
---|
| 370 | szby,
|
---|
| 371 | swp.cx - (szbx * 2L),
|
---|
| 372 | (swp.cy - titl) - (szby * 2L), SWP_MOVE | SWP_SIZE);
|
---|
[2] | 373 | }
|
---|
[551] | 374 | if (!(swp.fl & SWP_MAXIMIZE)) {
|
---|
[1335] | 375 | if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
|
---|
| 376 | swp.x = WinQueryWindowUShort(hwnd, QWS_XRESTORE);
|
---|
| 377 | swp.y = WinQueryWindowUShort(hwnd, QWS_YRESTORE);
|
---|
| 378 | swp.cx = WinQueryWindowUShort(hwnd, QWS_CXRESTORE);
|
---|
| 379 | swp.cy = WinQueryWindowUShort(hwnd, QWS_CYRESTORE);
|
---|
| 380 | }
|
---|
| 381 | PrfWriteProfileData(fmprof,
|
---|
| 382 | FM3Str, "NoteWndSwp", (PVOID) & swp, sizeof(SWP));
|
---|
[551] | 383 | }
|
---|
| 384 | }
|
---|
| 385 | return 0;
|
---|
[2] | 386 |
|
---|
[551] | 387 | case WM_ADJUSTWINDOWPOS:
|
---|
| 388 | PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
|
---|
| 389 | break;
|
---|
[2] | 390 |
|
---|
[551] | 391 | case UM_CONTAINER_FILLED:
|
---|
| 392 | {
|
---|
[1002] | 393 | SHORT y;
|
---|
| 394 | SHORT x = (SHORT)WinSendDlgItemMsg(hwnd,
|
---|
[1335] | 395 | NOTE_LISTBOX,
|
---|
| 396 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
[551] | 397 | if (x > 60) {
|
---|
[1335] | 398 | for (y = 0; y < x - 50; y++) {
|
---|
| 399 | WinSendDlgItemMsg(hwnd,
|
---|
| 400 | NOTE_LISTBOX,
|
---|
| 401 | LM_DELETEITEM, MPFROMSHORT(y), MPVOID);
|
---|
| 402 | }
|
---|
[2] | 403 | }
|
---|
[551] | 404 | }
|
---|
| 405 | return 0;
|
---|
[2] | 406 |
|
---|
[551] | 407 | case UM_NOTIFY:
|
---|
| 408 | {
|
---|
[1002] | 409 | SHORT x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
[1335] | 410 | NOTE_LISTBOX,
|
---|
| 411 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
[551] | 412 | if (x > 0)
|
---|
[1335] | 413 | WinSendDlgItemMsg(hwnd,
|
---|
| 414 | NOTE_LISTBOX,
|
---|
| 415 | LM_SETTOPINDEX, MPFROMSHORT(x), MPVOID);
|
---|
[551] | 416 | }
|
---|
| 417 | return 0;
|
---|
[2] | 418 |
|
---|
[551] | 419 | case UM_SHOWME:
|
---|
| 420 | WinSetWindowPos(hwnd,
|
---|
[1335] | 421 | HWND_TOP,
|
---|
| 422 | 0,
|
---|
| 423 | 0,
|
---|
| 424 | 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER | SWP_ACTIVATE);
|
---|
[551] | 425 | return 0;
|
---|
[2] | 426 |
|
---|
[551] | 427 | case WM_COMMAND:
|
---|
| 428 | return 0;
|
---|
[2] | 429 |
|
---|
[551] | 430 | case WM_CLOSE:
|
---|
| 431 | WinDismissDlg(hwnd, 0);
|
---|
| 432 | return 0;
|
---|
[2] | 433 |
|
---|
[551] | 434 | case WM_DESTROY:
|
---|
| 435 | if (hwndNotify == hwnd) {
|
---|
| 436 | fThreadNotes = FALSE;
|
---|
| 437 | PrfWriteProfileData(fmprof,
|
---|
[1335] | 438 | FM3Str, "ThreadNotes", &fThreadNotes, sizeof(BOOL));
|
---|
[551] | 439 | hwndNotify = (HWND) 0;
|
---|
| 440 | }
|
---|
| 441 | if (hptrIcon)
|
---|
| 442 | WinDestroyPointer(hptrIcon);
|
---|
| 443 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 444 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
| 445 | break;
|
---|
[2] | 446 | }
|
---|
[551] | 447 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 448 | }
|
---|
| 449 |
|
---|
[1002] | 450 | /**
|
---|
| 451 | * Thread notes dialog window thread
|
---|
| 452 | */
|
---|
| 453 |
|
---|
[551] | 454 | static VOID NoteThread(VOID * args)
|
---|
[356] | 455 | {
|
---|
[1002] | 456 | HAB hab = WinInitialize(0);
|
---|
[1038] | 457 | # ifdef FORTIFY
|
---|
| 458 | Fortify_EnterScope();
|
---|
[1063] | 459 | # endif
|
---|
[1002] | 460 | if (hab) {
|
---|
| 461 | HMQ hmq = WinCreateMsgQueue(hab, 0);
|
---|
| 462 | if (hmq) {
|
---|
[551] | 463 | if (!hwndNotify)
|
---|
[1335] | 464 | WinDlgBox(HWND_DESKTOP,
|
---|
| 465 | HWND_DESKTOP,
|
---|
| 466 | NoteWndProc, FM3ModHandle, NOTE_FRAME, (CHAR *)args);
|
---|
[1002] | 467 | WinDestroyMsgQueue(hmq);
|
---|
[2] | 468 | }
|
---|
[1002] | 469 | WinTerminate(hab);
|
---|
[2] | 470 | }
|
---|
[1038] | 471 | # ifdef FORTIFY
|
---|
[1063] | 472 | Fortify_LeaveScope();
|
---|
| 473 | # endif
|
---|
[2] | 474 | }
|
---|
| 475 |
|
---|
[1002] | 476 | /**
|
---|
| 477 | * Start thread notes dialog window thread
|
---|
| 478 | */
|
---|
| 479 |
|
---|
[551] | 480 | VOID StartNotes(CHAR * note)
|
---|
[356] | 481 | {
|
---|
| 482 | if (!hwndNotify) {
|
---|
[1335] | 483 | if (xbeginthread(NoteThread,
|
---|
| 484 | 65536,
|
---|
| 485 | note,
|
---|
| 486 | pszSrcFile,
|
---|
| 487 | __LINE__) != -1)
|
---|
| 488 | {
|
---|
[1002] | 489 | USHORT i;
|
---|
| 490 | for (i = 0; !hwndNotify && i < 10; i++)
|
---|
[1335] | 491 | DosSleep(10);
|
---|
[1002] | 492 | if (!hwndNotify)
|
---|
[1335] | 493 | Runtime_Error(pszSrcFile, __LINE__, "Can not create Notify window");
|
---|
[1002] | 494 | }
|
---|
[2] | 495 | }
|
---|
| 496 | }
|
---|
| 497 |
|
---|
[1002] | 498 | /**
|
---|
| 499 | * Add note to thread notes window or popup status window
|
---|
| 500 | */
|
---|
| 501 |
|
---|
[1394] | 502 | BOOL AddNote(PCSZ note)
|
---|
[356] | 503 | {
|
---|
[1394] | 504 | PSZ s;
|
---|
| 505 | PCSZ p;
|
---|
[551] | 506 | BOOL once = FALSE, ret = FALSE;
|
---|
[2] | 507 |
|
---|
[551] | 508 | if ((fThreadNotes || hwndNotify) && note && *note) {
|
---|
[2] | 509 | p = note;
|
---|
[551] | 510 | while (*p == ' ')
|
---|
[2] | 511 | p++;
|
---|
[551] | 512 | if (*p) {
|
---|
| 513 | if (!hwndNotify) {
|
---|
[1335] | 514 | fThreadNotes = FALSE;
|
---|
| 515 | StartNotes(NULL);
|
---|
[2] | 516 | }
|
---|
[551] | 517 | if (hwndNotify) {
|
---|
[1335] | 518 | s = xmalloc(strlen(p) + 14, pszSrcFile, __LINE__);
|
---|
| 519 | if (s) {
|
---|
| 520 | sprintf(s, "%08lx %s", _threadid, p);
|
---|
| 521 | while (!once) {
|
---|
| 522 | if ((SHORT) WinSendDlgItemMsg(hwndNotify,
|
---|
| 523 | NOTE_LISTBOX,
|
---|
| 524 | LM_INSERTITEM,
|
---|
| 525 | MPFROM2SHORT(LIT_END, 0),
|
---|
| 526 | MPFROMP(s)) >= 0) {
|
---|
| 527 | ret = TRUE;
|
---|
| 528 | PostMsg(hwndNotify, UM_NOTIFY, MPVOID, MPVOID);
|
---|
| 529 | break;
|
---|
| 530 | }
|
---|
| 531 | PostMsg(hwndNotify, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
| 532 | once = TRUE;
|
---|
| 533 | }
|
---|
| 534 | free(s);
|
---|
| 535 | }
|
---|
[2] | 536 | }
|
---|
| 537 | }
|
---|
| 538 | }
|
---|
| 539 | return ret;
|
---|
| 540 | }
|
---|
| 541 |
|
---|
[1002] | 542 | /**
|
---|
| 543 | * Close thread notes window
|
---|
| 544 | */
|
---|
| 545 |
|
---|
[551] | 546 | VOID EndNote(VOID)
|
---|
[356] | 547 | {
|
---|
[551] | 548 | if (hwndNotify)
|
---|
| 549 | if (!PostMsg(hwndNotify, WM_CLOSE, MPVOID, MPVOID))
|
---|
| 550 | WinSendMsg(hwndNotify, WM_CLOSE, MPVOID, MPVOID);
|
---|
[2] | 551 | }
|
---|
| 552 |
|
---|
[1002] | 553 | /**
|
---|
| 554 | * Pop up thread notes window
|
---|
| 555 | */
|
---|
| 556 |
|
---|
[551] | 557 | VOID ShowNote(VOID)
|
---|
[356] | 558 | {
|
---|
[551] | 559 | if (!hwndNotify)
|
---|
[2] | 560 | StartNotes(NULL);
|
---|
[551] | 561 | if (hwndNotify)
|
---|
| 562 | PostMsg(hwndNotify, UM_SHOWME, MPVOID, MPVOID);
|
---|
[2] | 563 | }
|
---|
| 564 |
|
---|
[1002] | 565 | /**
|
---|
| 566 | * Hide thread notes window
|
---|
| 567 | */
|
---|
| 568 |
|
---|
[551] | 569 | VOID HideNote(VOID)
|
---|
[356] | 570 | {
|
---|
[551] | 571 | if (hwndNotify)
|
---|
[2] | 572 | WinSetWindowPos(hwndNotify,
|
---|
[1335] | 573 | HWND_BOTTOM,
|
---|
| 574 | 0,
|
---|
| 575 | 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER | SWP_FOCUSDEACTIVATE);
|
---|
[2] | 576 | }
|
---|
[793] | 577 |
|
---|
[1038] | 578 | #pragma alloc_text(NOTIFY,Notify,NotifyWndProc,StartNotify,NotifyError)
|
---|
[793] | 579 | #pragma alloc_text(NOTIFY2,AddNote,NoteThread,NoteWndProc)
|
---|
| 580 | #pragma alloc_text(NOTIFY3,StartNotes,EndNote,HideNote,ShowNote)
|
---|