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