source: trunk/dll/notify.c@ 1844

Last change on this file since 1844 was 1669, checked in by Gregg Young, 13 years ago

Add support for changing PresParams in the notify status window. (Ticket 443)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.9 KB
RevLine 
[356]1/***********************************************************************
2
3 $Id: notify.c 1669 2012-08-13 01:21:26Z gyoung $
4
[1444]5 Thread notes window and popup notifications over status line
[356]6
7 Copyright (c) 1993-98 M. Kimes
[1498]8 Copyright (c) 2006, 2010 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
[1444]20 13 Jul 09 SHL Sync with renames
21 16 Jul 09 SHL Stop leaking hptrIcon
[1654]22 17 Jan 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
[1669]23 12 Aug 12 GKY Add support for changing PresParams in the notify status window
[356]24
25***********************************************************************/
26
[2]27#include <stdlib.h>
28#include <string.h>
29#include <ctype.h>
[1455]30#include <stddef.h> // _threadid
[356]31
[907]32#define INCL_DOS
33#define INCL_WIN
34#define INCL_GPI
[1455]35#define INCL_LONGLONG // dircnrs.h
[907]36
[1211]37#include "fm3dll.h"
[1225]38#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
[1211]39#include "collect.h" // Data declaration(s)
40#include "grep.h" // Data declaration(s)
41#include "notebook.h" // Data declaration(s)
42#include "init.h" // Data declaration(s)
[2]43#include "fm3dlg.h"
44#include "fm3str.h"
[1455]45#include "errutil.h" // Dos_Error...
46#include "strutil.h" // GetPString
[1163]47#include "notify.h"
[1188]48#include "presparm.h" // SetPresParams
[1211]49#include "mainwnd.h" // Data declaration(s)
[1188]50#include "wrappers.h" // xmalloc
51#include "misc.h" // PostMsg
[1038]52#include "fortify.h"
[1335]53#include "excputil.h" // xbeginthread
[2]54
55#pragma data_seg(DATA1)
[356]56
[1211]57// Data definitions
[356]58static PSZ pszSrcFile = __FILE__;
[1455]59static volatile HWND hwndNotify; // 16 Apr 08 SHL
[1444]60static volatile PCSZ pszCachedNote; // 16 Jul 09 SHL
[2]61
[1211]62#pragma data_seg(GLOBAL1)
63BOOL fThreadNotes;
64
[1444]65static VOID StartNotes(PCSZ pszNote);
[1163]66
[1002]67/**
[1444]68 * Notification message window procedure
69 * Displays timed message over status line
[1002]70 */
71
[551]72MRESULT EXPENTRY NotifyWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[356]73{
[2]74 static ULONG showing = 0;
75
[551]76 switch (msg) {
77 case WM_CREATE:
78 showing++;
79 {
[1002]80 MRESULT rc = PFNWPStatic(hwnd, msg, mp1, mp2);
[2]81
[1444]82 if (!WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_NOTIFY_TIMER, 5000)) {
[1335]83 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "WinStartTimer");
84 WinDestroyWindow(hwnd);
[551]85 }
86 else {
[1335]87 if (hwndMain) {
88 if (hwndStatus)
89 WinShowWindow(hwndStatus, FALSE);
90 if (hwndStatus2)
91 WinShowWindow(hwndStatus2, FALSE);
92 }
93 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
[2]94 }
[551]95 return rc;
96 }
[2]97
[551]98 case UM_SETUP:
99 WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_SHOW);
100 WinInvalidateRect(hwnd, NULL, FALSE);
101 return 0;
[2]102
[551]103 case WM_SETFOCUS:
104 if (mp2)
105 PostMsg(hwnd, UM_REPLACEFOCUS, mp1, MPVOID);
106 break;
[2]107
[551]108 case UM_REPLACEFOCUS:
109 if (mp1)
110 WinSetFocus(HWND_DESKTOP, (HWND) mp1);
111 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
112 return 0;
[2]113
[551]114 case WM_PAINT:
115 {
116 SWP swp;
117 POINTL ptl;
[2]118
[1002]119 MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2);
120 HPS hps = WinGetPS(hwnd);
[551]121 if (hps) {
[1335]122 if (WinQueryWindowPos(hwnd, &swp)) {
123 ptl.x = 0;
124 ptl.y = 0;
125 GpiMove(hps, &ptl);
126 GpiSetColor(hps, CLR_RED);
127 ptl.x = swp.cx - 1;
128 ptl.y = swp.cy - 1;
129 GpiBox(hps, DRO_OUTLINE, &ptl, 2, 2);
130 }
131 WinReleasePS(hwnd);
[2]132 }
[551]133 return mr;
134 }
[2]135
[551]136 case WM_BUTTON1DOWN:
137 case WM_BUTTON2DOWN:
138 case WM_BUTTON3DOWN:
139 case WM_TIMER:
140 case WM_CLOSE:
[1444]141 WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_NOTIFY_TIMER);
[551]142 WinDestroyWindow(hwnd);
143 return 0;
[2]144
[551]145 case WM_DESTROY:
146 showing--;
147 if (!showing && hwndMain) {
148 if (hwndStatus)
[1335]149 WinShowWindow(hwndStatus, TRUE);
[551]150 if (hwndStatus2)
[1335]151 WinShowWindow(hwndStatus2, TRUE);
[551]152 }
153 break;
[2]154 }
[551]155 return PFNWPStatic(hwnd, msg, mp1, mp2);
[2]156}
157
[1002]158/**
[1444]159 * Process UM_NOTIFY message to display timed message over status line
[1002]160 */
161
[1394]162HWND DoNotify(PCSZ str)
[356]163{
[551]164 char *p;
[1455]165 HWND hwnd = (HWND)0, hwndP;
[551]166 LONG x, y, cx, cy;
167 SWP swp, swpS, swpS2;
[2]168 static USHORT id = NOTE_FRAME;
169
[551]170 if (str && *str) {
[1002]171 // figure out what size the window should be and where it should be
172 hwndP = hwndMain ? WinQueryWindow(hwndMain, QW_PARENT) : HWND_DESKTOP;
[551]173 WinQueryWindowPos(hwndP, &swp);
174 if (hwndStatus)
175 WinQueryWindowPos(hwndStatus, &swpS);
176 if (hwndStatus2)
177 WinQueryWindowPos(hwndStatus2, &swpS2);
[1002]178 x = hwndMain ? (hwndStatus ? swpS.x - 1 :
[1335]179 WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER)) : 0;
[1002]180 y = hwndMain ? (hwndStatus ? swpS.y - 1 :
[1335]181 WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER)) : 0;
[551]182 if (hwndMain && hwndStatus) {
183 if (hwndStatus2)
[1335]184 cx = swpS2.cx + swpS.cx + 8;
[2]185 else
[1335]186 cx = swpS.cx + 6;
[2]187 }
188 else
189 cx = (swp.cx - ((x * 2) + 4));
[1002]190 cy = hwndMain ? (hwndStatus ? swpS.cy + 2 : 28) : 28;
[2]191
[1002]192 // pretty-up the note by putting on a leading space
[551]193 if (*str != ' ') {
194 p = xmalloc(strlen(str) + 2, pszSrcFile, __LINE__);
195 if (!p)
[1394]196 p = (PSZ)str;
[2]197 else {
[1335]198 strcpy(p + 1, str);
199 *p = ' ';
[2]200 }
201 }
202 else
[1394]203 p = (PSZ)str;
[2]204
205 hwnd = WinCreateWindow(hwndP,
[1498]206 (CHAR *) WC_ERRORWND,
[1335]207 p,
208 SS_TEXT | DT_LEFT | DT_VCENTER | WS_VISIBLE,
209 x, y, cx, cy, hwndP, HWND_TOP, id++, NULL, NULL);
[1444]210 if (!hwnd)
[1395]211 Win_Error(hwndP, hwndP, pszSrcFile, __LINE__,
[1455]212 PCSZ_WINCREATEWINDOW);
[377]213
[551]214 if (p != str)
[1039]215 free(p);
[551]216 if (id > NOTE_MAX)
[1444]217 id = NOTE_FRAME; // Wrap
[2]218 }
219
[1444]220 AddNote(str); // Add thread notes window
[2]221
222 return hwnd;
223}
224
[1002]225/**
[1444]226 * Display timed notification window over status line
[1002]227 */
228
[1394]229HWND Notify(PCSZ str)
[356]230{
[1002]231 return (HWND)WinSendMsg(MainObjectHwnd, UM_NOTIFY, MPFROMP(str), MPVOID);
[2]232}
233
[1002]234/**
[1444]235 * Notify on error
236 * Format message and pass to Notify
[1002]237 */
238
[1394]239VOID NotifyError(PCSZ filename, APIRET status)
[356]240{
[2]241 CHAR errortext[512];
242
[551]243 if (!filename)
[2]244 return;
[1444]245
[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 }
[1395]270 if (!fErrorBeepOff) {
271 DosBeep(250, 10);
272 DosBeep(500, 10);
273 DosBeep(250, 10);
274 DosBeep(500, 10);
275 }
[2]276 Notify(errortext);
277}
278
[1002]279/**
[1444]280 * Thread notes window dialog procedure
[1002]281 */
282
[551]283MRESULT EXPENTRY NoteWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[356]284{
[1444]285 static HPOINTER hptrIcon;
[2]286
[551]287 switch (msg) {
288 case WM_INITDLG:
[1002]289 if (hwndNotify != (HWND)0) {
290 // Already have notes dialog - pass message on
[551]291 if (mp2) {
[1444]292 AddNote((PCSZ)mp2); // 16 Jul 09 SHL was direct LM_INSERTITEM
293 xfree((PSZ)mp2, pszSrcFile, __LINE__);
[2]294 }
[551]295 WinDismissDlg(hwnd, 0);
296 break;
297 }
298 hwndNotify = hwnd;
[1669]299 {
300 USHORT ids[] = {NOTE_FRAME, NOTE_LISTBOX, 0};
301 UINT x;
302 CHAR s[24];
303
304 for (x = 0; ids[x]; x++) {
305 sprintf(s, "%s%i", PCSZ_NOTIFYWND,ids[x]);
306 RestorePresParams(WinWindowFromID(hwnd, ids[x]), s);
307 }
308 }
[1444]309 // Remember showing for restart
310 fThreadNotes = TRUE;
[1455]311 PrfWriteProfileData(fmprof,
[1505]312 FM3Str,
[1455]313 "ThreadNotes",
314 &fThreadNotes,
315 sizeof(BOOL));
316 fThreadNotes = FALSE; // Optimize shutdown
[1444]317
318 // 16 Jul 09 SHL Added
319 if (pszCachedNote) {
320 PCSZ p = pszCachedNote;
321 pszCachedNote = NULL;
322 AddNote(p);
323 xfree((PSZ)p, pszSrcFile, __LINE__);
[551]324 }
[1444]325
[551]326 if (mp2) {
[1444]327 AddNote((PCSZ)mp2); // 16 Jul 09 SHL was direct LM_INSERTITEM
328 xfree((PSZ)mp2, pszSrcFile, __LINE__);
[551]329 }
[1002]330
[1444]331 // Grab focus
332 PostMsg(hwnd,
333 UM_FOCUSME,
334 MPFROMLONG(WinQueryActiveWindow(HWND_DESKTOP)),
335 MPVOID);
[1002]336
[551]337 hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, NOTE_FRAME);
338 if (hptrIcon)
339 WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPFROMLONG(0L));
340 break;
[2]341
[551]342 case UM_FOCUSME:
343 {
344 ULONG size = sizeof(SWP),
[1335]345 fl = SWP_ZORDER | SWP_FOCUSDEACTIVATE | SWP_SHOW;
[551]346 SWP swp;
[2]347
[551]348 if (PrfQueryProfileData(fmprof,
[1505]349 FM3Str, "NoteWndSwp", (PVOID) & swp, &size)) {
[1335]350 if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
351 fl |= SWP_MINIMIZE;
352 fl &= (~SWP_SHOW);
353 }
354 else
355 fl |= (SWP_MOVE | SWP_SIZE);
[2]356 }
[551]357 WinSetWindowPos(hwnd, HWND_BOTTOM, swp.x, swp.y, swp.cx, swp.cy, fl);
358 if (fl & SWP_MINIMIZE) {
[1335]359 WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT) swp.x);
360 WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT) swp.cx);
361 WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT) swp.y);
362 WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT) swp.cy);
[551]363 }
364 }
365 if (mp1)
366 WinSetActiveWindow(HWND_DESKTOP, (HWND) mp1);
367 return 0;
[2]368
[551]369 case UM_STRETCH:
370 {
371 SWP swp;
372 LONG titl, szbx, szby;
[2]373
[551]374 WinQueryWindowPos(hwnd, &swp);
375 if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) {
[1335]376 szbx = SysVal(SV_CXSIZEBORDER);
377 szby = SysVal(SV_CYSIZEBORDER);
378 titl = SysVal(SV_CYTITLEBAR);
379 WinSetWindowPos(WinWindowFromID(hwnd, NOTE_LISTBOX),
380 HWND_TOP,
381 szbx,
382 szby,
383 swp.cx - (szbx * 2L),
384 (swp.cy - titl) - (szby * 2L), SWP_MOVE | SWP_SIZE);
[2]385 }
[551]386 if (!(swp.fl & SWP_MAXIMIZE)) {
[1335]387 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
388 swp.x = WinQueryWindowUShort(hwnd, QWS_XRESTORE);
389 swp.y = WinQueryWindowUShort(hwnd, QWS_YRESTORE);
390 swp.cx = WinQueryWindowUShort(hwnd, QWS_CXRESTORE);
391 swp.cy = WinQueryWindowUShort(hwnd, QWS_CYRESTORE);
392 }
393 PrfWriteProfileData(fmprof,
[1505]394 FM3Str, "NoteWndSwp", (PVOID) & swp, sizeof(SWP));
[551]395 }
396 }
397 return 0;
[2]398
[551]399 case WM_ADJUSTWINDOWPOS:
400 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
401 break;
[2]402
[551]403 case UM_CONTAINER_FILLED:
404 {
[1002]405 SHORT y;
406 SHORT x = (SHORT)WinSendDlgItemMsg(hwnd,
[1335]407 NOTE_LISTBOX,
408 LM_QUERYITEMCOUNT, MPVOID, MPVOID);
[551]409 if (x > 60) {
[1335]410 for (y = 0; y < x - 50; y++) {
411 WinSendDlgItemMsg(hwnd,
412 NOTE_LISTBOX,
413 LM_DELETEITEM, MPFROMSHORT(y), MPVOID);
414 }
[2]415 }
[551]416 }
417 return 0;
[2]418
[551]419 case UM_NOTIFY:
420 {
[1002]421 SHORT x = (SHORT) WinSendDlgItemMsg(hwnd,
[1335]422 NOTE_LISTBOX,
423 LM_QUERYITEMCOUNT, MPVOID, MPVOID);
[551]424 if (x > 0)
[1335]425 WinSendDlgItemMsg(hwnd,
426 NOTE_LISTBOX,
427 LM_SETTOPINDEX, MPFROMSHORT(x), MPVOID);
[551]428 }
429 return 0;
[2]430
[551]431 case UM_SHOWME:
432 WinSetWindowPos(hwnd,
[1335]433 HWND_TOP,
434 0,
435 0,
436 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER | SWP_ACTIVATE);
[551]437 return 0;
[2]438
[551]439 case WM_COMMAND:
440 return 0;
[2]441
[551]442 case WM_CLOSE:
[1444]443 if (pszCachedNote)
[1521]444 Runtime_Error(pszSrcFile, __LINE__, "pszCachedNote %p unexpected", pszCachedNote);
[1444]445 else {
446 // Cache last item for next open
447 SHORT ndx = (SHORT)WinSendDlgItemMsg(hwnd, NOTE_LISTBOX,
448 LM_QUERYITEMCOUNT, MPVOID, MPVOID);
449 if (ndx != LIT_NONE) {
450 SHORT len;
451 ndx--;
452 len = (SHORT)WinSendDlgItemMsg(hwnd, NOTE_LISTBOX,
[1455]453 LM_QUERYITEMTEXTLENGTH,
[1444]454 MPFROMSHORT(ndx), MPVOID);
455 if (len != LIT_ERROR) {
456 PSZ p;
457 len++;
458 p = xmalloc(len, pszSrcFile, __LINE__);
459 if (p) {
460 SHORT len2 = (SHORT)WinSendDlgItemMsg(hwnd, NOTE_LISTBOX,
461 LM_QUERYITEMTEXT,
462 MPFROM2SHORT(ndx, len), MPFROMP(p));
463 len--;
464 if (len2 != len) {
465 DbgMsg(pszSrcFile, __LINE__, "len %u unexpected - should be %u", len2, len); // 18 Jul 08 SHL fixme to be Runtime_Error
466 xfree((PSZ)p, pszSrcFile, __LINE__);
467 }
468 else
469 pszCachedNote = p;
470 }
471 }
472 }
473 }
[551]474 WinDismissDlg(hwnd, 0);
475 return 0;
[2]476
[551]477 case WM_DESTROY:
478 if (hwndNotify == hwnd) {
[1669]479 USHORT ids[] = {NOTE_FRAME, NOTE_LISTBOX, 0};
480 UINT x;
481 CHAR s[24];
482
483 for (x = 0; ids[x]; x++) {
484 sprintf(s, "%s%i", PCSZ_NOTIFYWND,ids[x]);
485 SavePresParams(WinWindowFromID(hwnd, ids[x]), s);
486 }
[1455]487 fThreadNotes = FALSE; // Remember not open
[551]488 PrfWriteProfileData(fmprof,
[1505]489 FM3Str, "ThreadNotes", &fThreadNotes, sizeof(BOOL));
[1455]490 hwndNotify = (HWND)0;
[551]491 }
[1444]492 if (hptrIcon) {
[551]493 WinDestroyPointer(hptrIcon);
[1444]494 hptrIcon = (HPOINTER)0; // 16 Jul 09 SHL
495 }
[1455]496 if (!PostMsg((HWND)0, WM_QUIT, MPVOID, MPVOID))
497 WinSendMsg((HWND)0, WM_QUIT, MPVOID, MPVOID);
[551]498 break;
[2]499 }
[551]500 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]501}
502
[1002]503/**
504 * Thread notes dialog window thread
505 */
506
[1455]507static VOID NoteThread(VOID *args)
[356]508{
[1002]509 HAB hab = WinInitialize(0);
[1038]510# ifdef FORTIFY
511 Fortify_EnterScope();
[1063]512# endif
[1002]513 if (hab) {
514 HMQ hmq = WinCreateMsgQueue(hab, 0);
515 if (hmq) {
[551]516 if (!hwndNotify)
[1335]517 WinDlgBox(HWND_DESKTOP,
518 HWND_DESKTOP,
[1444]519 NoteWndProc, FM3ModHandle, NOTE_FRAME, args);
[1002]520 WinDestroyMsgQueue(hmq);
[2]521 }
[1002]522 WinTerminate(hab);
[2]523 }
[1038]524# ifdef FORTIFY
[1063]525 Fortify_LeaveScope();
526# endif
[2]527}
528
[1002]529/**
530 * Start thread notes dialog window thread
531 */
532
[1444]533static VOID StartNotes(PCSZ note)
[356]534{
535 if (!hwndNotify) {
[1335]536 if (xbeginthread(NoteThread,
537 65536,
[1444]538 (VOID*)note,
[1335]539 pszSrcFile,
540 __LINE__) != -1)
541 {
[1002]542 USHORT i;
543 for (i = 0; !hwndNotify && i < 10; i++)
[1335]544 DosSleep(10);
[1002]545 if (!hwndNotify)
[1335]546 Runtime_Error(pszSrcFile, __LINE__, "Can not create Notify window");
[1002]547 }
[2]548 }
549}
550
[1002]551/**
552 * Add note to thread notes window or popup status window
[1444]553 * Open window if was open and first messages after restart
554 * Cache last note until window opened
[1002]555 */
556
[1444]557VOID AddNote(PCSZ note)
[356]558{
[1394]559 PSZ s;
560 PCSZ p;
[1444]561 BOOL once = FALSE;
[2]562
[1444]563 // Cache last note until window opened
564 // 16 Jul 09 SHL fixme to avoid FORTIFY complaints
565 if (!fThreadNotes && !hwndNotify && note) {
566 p = note + strspn(note, " \t"); // Skip leading white
[551]567 if (*p) {
[1444]568 if (pszCachedNote)
569 xfree((PSZ)pszCachedNote, pszSrcFile, __LINE__);
570 pszCachedNote = xstrdup(p, pszSrcFile, __LINE__);
571 }
572 return;
573 }
574
575 if ((fThreadNotes || hwndNotify) && note) {
576 p = note + strspn(note, " \t"); // Skip leading white
577 if (*p) {
578 // If have cached note, output it first
579 if (pszCachedNote) {
580 PCSZ psz = pszCachedNote;
581 pszCachedNote = NULL;
582 AddNote(psz);
583 free((VOID*)psz);
584 }
[551]585 if (!hwndNotify) {
[1444]586 fThreadNotes = FALSE; // 16 Jul 09 SHL fixme to be gone?
[1335]587 StartNotes(NULL);
[2]588 }
[551]589 if (hwndNotify) {
[1335]590 s = xmalloc(strlen(p) + 14, pszSrcFile, __LINE__);
591 if (s) {
592 sprintf(s, "%08lx %s", _threadid, p);
593 while (!once) {
594 if ((SHORT) WinSendDlgItemMsg(hwndNotify,
595 NOTE_LISTBOX,
596 LM_INSERTITEM,
597 MPFROM2SHORT(LIT_END, 0),
598 MPFROMP(s)) >= 0) {
599 PostMsg(hwndNotify, UM_NOTIFY, MPVOID, MPVOID);
600 break;
601 }
602 PostMsg(hwndNotify, UM_CONTAINER_FILLED, MPVOID, MPVOID);
603 once = TRUE;
604 }
605 free(s);
606 }
[2]607 }
608 }
609 }
610}
611
[1002]612/**
613 * Close thread notes window
614 */
615
[551]616VOID EndNote(VOID)
[356]617{
[551]618 if (hwndNotify)
619 if (!PostMsg(hwndNotify, WM_CLOSE, MPVOID, MPVOID))
620 WinSendMsg(hwndNotify, WM_CLOSE, MPVOID, MPVOID);
[2]621}
622
[1002]623/**
624 * Pop up thread notes window
625 */
626
[551]627VOID ShowNote(VOID)
[356]628{
[551]629 if (!hwndNotify)
[2]630 StartNotes(NULL);
[551]631 if (hwndNotify)
632 PostMsg(hwndNotify, UM_SHOWME, MPVOID, MPVOID);
[2]633}
634
[1002]635/**
636 * Hide thread notes window
637 */
638
[551]639VOID HideNote(VOID)
[356]640{
[551]641 if (hwndNotify)
[2]642 WinSetWindowPos(hwndNotify,
[1335]643 HWND_BOTTOM,
644 0,
645 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER | SWP_FOCUSDEACTIVATE);
[2]646}
[793]647
[1038]648#pragma alloc_text(NOTIFY,Notify,NotifyWndProc,StartNotify,NotifyError)
[793]649#pragma alloc_text(NOTIFY2,AddNote,NoteThread,NoteWndProc)
650#pragma alloc_text(NOTIFY3,StartNotes,EndNote,HideNote,ShowNote)
Note: See TracBrowser for help on using the repository browser.