Changeset 1002
- Timestamp:
- Apr 18, 2008, 6:39:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/notify.c
r985 r1002 4 4 $Id$ 5 5 6 Notifications6 Thread notes window and popup notification status line 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2006 Steven H.Levine9 Copyright (c) 2006, 2008 Steven H.Levine 10 10 11 11 17 Jul 06 SHL Use Win_Error … … 15 15 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat 16 16 29 Feb 08 GKY Use xfree where appropriate 17 17 16 Apr 08 SHL Comment and clean up logic 18 18 19 19 ***********************************************************************/ … … 40 40 static PSZ pszSrcFile = __FILE__; 41 41 42 static HWND hwndNotify; 42 static volatile HWND hwndNotify; // 16 Apr 08 SHL 43 44 /** 45 * Popup notification message window procedure 46 * Display timed message over status line 47 */ 43 48 44 49 MRESULT EXPENTRY NotifyWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) … … 50 55 showing++; 51 56 { 52 MRESULT rc; 53 54 rc = PFNWPStatic(hwnd, msg, mp1, mp2); 57 MRESULT rc = PFNWPStatic(hwnd, msg, mp1, mp2); 58 55 59 if (!WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_TIMER2, 5000)) { 56 60 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "WinStartTimer"); … … 95 99 case WM_PAINT: 96 100 { 97 MRESULT mr;98 HPS hps;99 101 SWP swp; 100 102 POINTL ptl; 101 103 102 mr = PFNWPStatic(hwnd, msg, mp1, mp2);103 hps = WinGetPS(hwnd);104 MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2); 105 HPS hps = WinGetPS(hwnd); 104 106 if (hps) { 105 107 if (WinQueryWindowPos(hwnd, &swp)) { … … 139 141 } 140 142 143 /** 144 * Display timed notification window over status line 145 */ 146 141 147 HWND DoNotify(char *str) 142 148 { … … 148 154 149 155 if (str && *str) { 150 / * figure out what size the window should be and where it should be */151 hwndP = (hwndMain)? WinQueryWindow(hwndMain, QW_PARENT) : HWND_DESKTOP;156 // figure out what size the window should be and where it should be 157 hwndP = hwndMain ? WinQueryWindow(hwndMain, QW_PARENT) : HWND_DESKTOP; 152 158 WinQueryWindowPos(hwndP, &swp); 153 159 if (hwndStatus) … … 155 161 if (hwndStatus2) 156 162 WinQueryWindowPos(hwndStatus2, &swpS2); 157 x = (hwndMain) ? ((hwndStatus)? swpS.x - 1 :163 x = hwndMain ? (hwndStatus ? swpS.x - 1 : 158 164 WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER)) : 0; 159 y = (hwndMain) ? ((hwndStatus)? swpS.y - 1 :165 y = hwndMain ? (hwndStatus ? swpS.y - 1 : 160 166 WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER)) : 0; 161 167 if (hwndMain && hwndStatus) { … … 167 173 else 168 174 cx = (swp.cx - ((x * 2) + 4)); 169 cy = (hwndMain) ? ((hwndStatus)? swpS.cy + 2 : 28) : 28;170 171 / * pretty-up the note by putting on a leading space */175 cy = hwndMain ? (hwndStatus ? swpS.cy + 2 : 28) : 28; 176 177 // pretty-up the note by putting on a leading space 172 178 if (*str != ' ') { 173 179 p = xmalloc(strlen(str) + 2, pszSrcFile, __LINE__); … … 201 207 } 202 208 209 /** 210 * Add message to thread notes window 211 */ 212 203 213 HWND Notify(char *str) 204 214 { 205 return (HWND) WinSendMsg(MainObjectHwnd, UM_NOTIFY, MPFROMP(str), MPVOID); 206 } 215 return (HWND)WinSendMsg(MainObjectHwnd, UM_NOTIFY, MPFROMP(str), MPVOID); 216 } 217 218 /** 219 * Add error message to thread notes window 220 */ 207 221 208 222 VOID NotifyError(CHAR * filename, APIRET status) … … 243 257 } 244 258 259 /** 260 * Thread notes dialog window dialog procedure 261 */ 262 245 263 MRESULT EXPENTRY NoteWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 246 264 { … … 249 267 switch (msg) { 250 268 case WM_INITDLG: 251 if (hwndNotify != (HWND) 0) { 269 if (hwndNotify != (HWND)0) { 270 // Already have notes dialog - pass message on 252 271 if (mp2) { 253 272 WinSendDlgItemMsg(hwndNotify, … … 262 281 hwndNotify = hwnd; 263 282 fThreadNotes = FALSE; 283 // Remember showing 264 284 { 265 285 BOOL dummy = TRUE; 266 267 286 PrfWriteProfileData(fmprof, 268 287 FM3Str, "ThreadNotes", &dummy, sizeof(BOOL)); … … 274 293 xfree((CHAR *) mp2); 275 294 } 276 { 277 HWND hwndActive;278 279 hwndActive = WinQueryActiveWindow(HWND_DESKTOP);295 296 { 297 // Return focus 298 HWND hwndActive = WinQueryActiveWindow(HWND_DESKTOP); 280 299 PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(hwndActive), MPVOID); 281 300 } 301 282 302 hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, NOTE_FRAME); 283 303 if (hptrIcon) … … 348 368 case UM_CONTAINER_FILLED: 349 369 { 350 SHORT x, y; 351 352 x = (SHORT) WinSendDlgItemMsg(hwnd, 353 NOTE_LISTBOX, 354 LM_QUERYITEMCOUNT, MPVOID, MPVOID); 370 SHORT y; 371 SHORT x = (SHORT)WinSendDlgItemMsg(hwnd, 372 NOTE_LISTBOX, 373 LM_QUERYITEMCOUNT, MPVOID, MPVOID); 355 374 if (x > 60) { 356 for (y = 0; y < x - 50; y++) 375 for (y = 0; y < x - 50; y++) { 357 376 WinSendDlgItemMsg(hwnd, 358 377 NOTE_LISTBOX, 359 378 LM_DELETEITEM, MPFROMSHORT(y), MPVOID); 379 } 360 380 } 361 381 } … … 364 384 case UM_NOTIFY: 365 385 { 366 SHORT x; 367 368 x = (SHORT) WinSendDlgItemMsg(hwnd, 369 NOTE_LISTBOX, 370 LM_QUERYITEMCOUNT, MPVOID, MPVOID); 386 SHORT x = (SHORT) WinSendDlgItemMsg(hwnd, 387 NOTE_LISTBOX, 388 LM_QUERYITEMCOUNT, MPVOID, MPVOID); 371 389 if (x > 0) 372 390 WinSendDlgItemMsg(hwnd, … … 407 425 } 408 426 427 /** 428 * Thread notes dialog window thread 429 */ 430 409 431 static VOID NoteThread(VOID * args) 410 432 { 411 HAB hab2; 412 HMQ hmq2; 413 414 hab2 = WinInitialize(0); 415 if (hab2) { 416 hmq2 = WinCreateMsgQueue(hab2, 0); 417 if (hmq2) { 433 HAB hab = WinInitialize(0); 434 435 if (hab) { 436 HMQ hmq = WinCreateMsgQueue(hab, 0); 437 if (hmq) { 418 438 if (!hwndNotify) 419 439 WinDlgBox(HWND_DESKTOP, 420 440 HWND_DESKTOP, 421 NoteWndProc, FM3ModHandle, NOTE_FRAME, (CHAR *) args); 422 WinDestroyMsgQueue(hmq2); 423 } 424 WinTerminate(hab2); 425 } 426 } 441 NoteWndProc, FM3ModHandle, NOTE_FRAME, (CHAR *)args); 442 WinDestroyMsgQueue(hmq); 443 } 444 WinTerminate(hab); 445 } 446 } 447 448 /** 449 * Start thread notes dialog window thread 450 */ 427 451 428 452 VOID StartNotes(CHAR * note) … … 430 454 if (!hwndNotify) { 431 455 if (_beginthread(NoteThread, NULL, 65536, (PVOID) note) == -1) 432 Runtime_Error(pszSrcFile, __LINE__, 433 GetPString(IDS_COULDNTSTARTTHREADTEXT)); 434 } 435 } 456 Runtime_Error2(pszSrcFile, __LINE__, IDS_COULDNTSTARTTHREADTEXT); 457 else { 458 USHORT i; 459 for (i = 0; !hwndNotify && i < 10; i++) 460 DosSleep(10); 461 if (!hwndNotify) 462 Runtime_Error(pszSrcFile, __LINE__, "Can not create Notify window"); 463 } 464 } 465 } 466 467 /** 468 * Add note to thread notes window or popup status window 469 */ 436 470 437 471 BOOL AddNote(CHAR * note) … … 448 482 fThreadNotes = FALSE; 449 483 StartNotes(NULL); 450 if (!hwndNotify)451 DosSleep(16);//05 Aug 07 GKY 33452 if (!hwndNotify)453 DosSleep(16);//05 Aug 07 GKY 33454 if (!hwndNotify)455 DosSleep(16);//05 Aug 07 GKY 33456 484 } 457 485 if (hwndNotify) { … … 480 508 } 481 509 510 /** 511 * Close thread notes window 512 */ 513 482 514 VOID EndNote(VOID) 483 515 { … … 487 519 } 488 520 521 /** 522 * Pop up thread notes window 523 */ 524 489 525 VOID ShowNote(VOID) 490 526 { 491 527 if (!hwndNotify) 492 528 StartNotes(NULL); 493 if (!hwndNotify)494 DosSleep(16);//05 Aug 07 GKY 33495 if (!hwndNotify)496 DosSleep(16);//05 Aug 07 GKY 33497 if (!hwndNotify)498 DosSleep(16);//05 Aug 07 GKY 33499 529 if (hwndNotify) 500 530 PostMsg(hwndNotify, UM_SHOWME, MPVOID, MPVOID); 501 531 } 532 533 /** 534 * Hide thread notes window 535 */ 502 536 503 537 VOID HideNote(VOID)
Note:
See TracChangeset
for help on using the changeset viewer.