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