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