source: trunk/dll/autoview.c@ 2

Last change on this file since 2 was 2, checked in by root, 23 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.5 KB
Line 
1#define INCL_DOS
2#define INCL_WIN
3#define INCL_GPI
4
5#include <os2.h>
6#include <stdlib.h>
7#include <stdio.h>
8#include <string.h>
9#include <ctype.h>
10#include "fm3dll.h"
11#include "fm3dlg.h"
12#include "fm3str.h"
13#include "mle.h"
14
15#pragma data_seg(DATA1)
16#pragma alloc_text(AUTOVIEW,AutoViewProc,CreateHexDump,AutoObjProc)
17#pragma alloc_text(AUTOVIEW2,MakeAutoWin,WriteEA,PutComments)
18
19static HWND hwndAutoObj = (HWND)0;
20static CHAR stopflag;
21static CHAR currfile[CCHMAXPATH];
22extern BOOL loadedarcs;
23
24
25BOOL WriteEA (HWND hwnd,CHAR *filename,CHAR *eaname,USHORT type,CHAR *data) {
26
27 /* save an ea to disk */
28
29 FEA2LIST *pfealist = NULL;
30 EAOP2 eaop;
31 APIRET rc;
32 ULONG ealen;
33 USHORT len,*num,*plen,usCodepage;
34 CHAR *p,*eaval;
35 BOOL ret = FALSE;
36
37 if(!filename || !eaname)
38 return ret;
39 usCodepage = (USHORT)WinQueryCp(WinQueryWindowULong(hwnd,QWL_HMQ));
40 len = (data) ? strlen(data) : 0;
41 ealen = sizeof(FEA2LIST) + 24L + strlen(eaname) + 1L +
42 (ULONG)len + 4L;
43 switch(type) {
44 case EAT_EA:
45 case EAT_ASCII:
46 break;
47 case EAT_MVST:
48 if(data) {
49 ealen += sizeof(USHORT) * 5;
50 p = data;
51 while(*p) {
52 if(*p == '\n' && *(p + 1))
53 ealen += sizeof(USHORT);
54 p++;
55 }
56 }
57 break;
58 case EAT_MVMT:
59 if(data) {
60 ealen += sizeof(USHORT) * 5;
61 p = data;
62 while(*p) {
63 if(*p == '\n' && *(p + 1))
64 ealen += (sizeof(USHORT) * 2);
65 p++;
66 }
67 }
68 break;
69 default:
70 return ret;
71 }
72
73 if(!DosAllocMem((PPVOID)&pfealist,ealen,PAG_COMMIT | PAG_READ |
74 PAG_WRITE | OBJ_TILE) && pfealist) {
75 memset(pfealist,0,ealen);
76 pfealist->list[0].cbName = strlen(eaname);
77 memcpy(pfealist->list[0].szName,eaname,pfealist->list[0].cbName + 1);
78 eaval = pfealist->list[0].szName + pfealist->list[0].cbName + 1;
79 switch(type) {
80 case EAT_EA:
81 case EAT_ASCII:
82 if(data) {
83 *(USHORT *)eaval = (USHORT)type;
84 eaval += sizeof(USHORT);
85 *(USHORT *)eaval = (USHORT)len;
86 eaval += sizeof(USHORT);
87 memcpy(eaval,data,len);
88 eaval += len;
89 }
90 break;
91 case EAT_MVST:
92 if(data) {
93 *(USHORT *)eaval = (USHORT)EAT_MVST;
94 eaval += sizeof(USHORT);
95 *(USHORT *)eaval = usCodepage;
96 eaval += sizeof(USHORT);
97 num = (USHORT *)eaval;
98 *num = 0;
99 eaval += sizeof(USHORT);
100 *(USHORT *)eaval = (USHORT)EAT_ASCII;
101 eaval += sizeof(USHORT);
102 plen = (USHORT *)eaval;
103 *plen = 0;
104 eaval += sizeof(USHORT);
105 p = data;
106 while(*p) {
107 while(*p) {
108 if(*p == '\n') {
109 p++;
110 break;
111 }
112 *eaval++ = *p++;
113 (*plen)++;
114 }
115 if(*p || *plen)
116 (*num)++;
117 if(*p) {
118 plen = (USHORT *)eaval;
119 *plen = 0;
120 eaval += sizeof(USHORT);
121 }
122 }
123 }
124 break;
125 case EAT_MVMT:
126 if(data) {
127 *(USHORT *)eaval = (USHORT)EAT_MVMT;
128 eaval += sizeof(USHORT);
129 *(USHORT *)eaval = usCodepage;
130 eaval += sizeof(USHORT);
131 num = (USHORT *)eaval;
132 *num = 0;
133 eaval += sizeof(USHORT);
134 *(USHORT *)eaval = (USHORT)EAT_ASCII;
135 eaval += sizeof(USHORT);
136 plen = (USHORT *)eaval;
137 *plen = 0;
138 eaval += sizeof(USHORT);
139 p = data;
140 while(*p) {
141 while(*p) {
142 if(*p == '\n') {
143 p++;
144 break;
145 }
146 *eaval++ = *p++;
147 (*plen)++;
148 }
149 if(*p || *plen)
150 (*num)++;
151 if(*p) {
152 *(USHORT *)eaval = (USHORT)EAT_ASCII;
153 eaval += sizeof(USHORT);
154 plen = (USHORT *)eaval;
155 *plen = 0;
156 eaval += sizeof(USHORT);
157 }
158 }
159 }
160 break;
161 }
162 pfealist->list[0].cbValue = (ULONG)(eaval -
163 (pfealist->list[0].szName +
164 pfealist->list[0].cbName + 1));
165 memset(&eaop,0,sizeof(eaop));
166 eaop.fpFEA2List = pfealist;
167 pfealist->cbList = 13L + (ULONG)pfealist->list[0].cbName +
168 (ULONG)pfealist->list[0].cbValue;
169 rc = DosSetPathInfo(filename,FIL_QUERYEASIZE,(PVOID)&eaop,
170 (ULONG)sizeof(EAOP2),DSPI_WRTTHRU);
171 DosFreeMem(pfealist);
172 if(!rc)
173 ret = TRUE;
174 }
175 return ret;
176}
177
178
179BOOL PutComments (HWND hwnd,CHAR *filename,CHAR *comments) {
180
181 register CHAR *p;
182
183 if(comments) { /* check -- is it empty? */
184 p = comments;
185 while(*p && isspace(*p))
186 p++;
187 if(!*p)
188 comments = NULL;
189 }
190 return WriteEA(hwnd,filename,".COMMENTS",EAT_MVMT,comments);
191}
192
193
194ULONG CreateHexDump (CHAR *value,ULONG cbValue,CHAR *ret,ULONG retlen,
195 ULONG startval,BOOL longlead) {
196
197 register CHAR *p,*pp,*a;
198 register ULONG x = 0,y,z;
199
200 if(value && cbValue && ret && retlen) {
201 pp = p = value;
202 a = ret;
203 if(startval)
204 *a++ = '\n';
205 while(x < cbValue && a - ret < retlen) {
206 y = x;
207 if(longlead)
208 sprintf(a,"%08lx ",x + startval);
209 else
210 sprintf(a,"%04lx ",x + startval);
211 a += (6 + (startval != 0L) + ((longlead != 0L) * 4));
212 do {
213 sprintf(a,"%02hx ",*p);
214 a += 3;
215 p++;
216 x++;
217 } while(x < cbValue && (x % 16));
218 if(x % 16) {
219 z = x;
220 while(z % 16) {
221 *a++ = ' ';
222 *a++ = ' ';
223 *a++ = ' ';
224 z++;
225 }
226 }
227 *a++ = ' ';
228 p = pp;
229 do {
230 if(*p && *p != '\n' && *p != '\r' && *p != '\t' && *p != '\x1a')
231 *a++ = *p++;
232 else {
233 *a++ = '.';
234 p++;
235 }
236 y++;
237 } while(y < x);
238 if(x < cbValue)
239 *a++ = '\n';
240 pp = p;
241 }
242 *a = 0;
243 return (ULONG)(a - ret);
244 }
245 return 0L;
246}
247
248
249MRESULT EXPENTRY AutoObjProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
250
251 switch(msg) {
252 case UM_LOADFILE:
253 *currfile = 0;
254 stopflag--;
255 if(fAutoView) {
256 WinSetWindowText((fComments) ? hwndAutoMLE : hwndAutoview,"");
257 MLEsetreadonly(hwndAutoMLE,TRUE);
258 MLEsetchanged(hwndAutoMLE,FALSE);
259 }
260 if(mp1) {
261 if(fAutoView) {
262 strcpy(currfile,(CHAR *)mp1);
263 if(!fComments) {
264 if(IsFile((CHAR *)mp1) == 1) {
265
266 HFILE handle;
267 ULONG action,olen,len,l;
268 CHAR *buff,*buff2,*p,buffer[80];
269 ARC_TYPE *info;
270
271 if(!DosOpen((CHAR *)mp1,
272 &handle,
273 &action,
274 0L,
275 0L,
276 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
277 OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT |
278 OPEN_FLAGS_RANDOMSEQUENTIAL | OPEN_SHARE_DENYNONE |
279 OPEN_ACCESS_READONLY,
280 0L)) {
281 len = (AutoviewHeight < 96) ?
282 512 :
283 3072;
284 buff = malloc(len + 2);
285 if(buff) {
286 buff2 = malloc((AutoviewHeight < 96) ?
287 2049 :
288 9217);
289 if(buff2) {
290 *buff2 = 0;
291 if(!DosRead(handle,
292 buff,
293 len,
294 &len) &&
295 len) {
296 buff[len] = 0;
297 p = buff2;
298 if(IsBinary(buff,len)) {
299 olen = len;
300 if(!loadedarcs)
301 load_archivers();
302 info = arcsighead;
303 while(info) {
304 if(info->signature &&
305 *info->signature) {
306 l = strlen(info->signature);
307 l = min(l,79);
308 if(!DosChgFilePtr(handle,abs(info->file_offset),
309 (info->file_offset >= 0L) ?
310 FILE_BEGIN :
311 FILE_END,
312 &len)) {
313 if(!DosRead(handle,
314 buffer,
315 l,
316 &len) &&
317 len == l) {
318 if(!memcmp(info->signature,
319 buffer,
320 l))
321 break;
322 }
323 }
324 }
325 info = info->next;
326 }
327 if(info) {
328 sprintf(p,"**%s%s%s\n",
329 (info->id) ? info->id : "",
330 (info->id) ? " " : "",
331 GetPString(IDS_ARCHIVETEXT));
332 p += strlen(p);
333 }
334 CreateHexDump(buff,
335 olen,
336 p,
337 ((AutoviewHeight < 96) ? 2048 : 9216) -
338 (p - buff2),
339 0,FALSE);
340 }
341 else {
342
343 register CHAR *src,*dest;
344 CHAR *endsrc;
345
346 src = buff;
347 dest = buff2;
348 endsrc = buff + len;
349 while(src < endsrc) {
350 if(dest == buff2 && (*src == '\t' || *src == ' ' ||
351 *src == '\r' || *src == '\n')) {
352 src++;
353 }
354 else if(*src == '\t' || !*src) {
355 *dest = ' ';
356 dest++;
357 src++;
358 }
359 else if(*src == '\r' || *src == '\n') {
360 *dest = *src;
361 while(*(src + 1) == '\r' || *(src + 1) == '\n' ||
362 *(src + 1) == ' ' || *(src + 1) == '\t')
363 src++;
364 dest++;
365 src++;
366 }
367 else {
368 *dest = *src;
369 src++;
370 dest++;
371 }
372 }
373 *dest = 0;
374 }
375 if(*buff2)
376 WinSetWindowText(hwndAutoview,buff2);
377 }
378 free(buff2);
379 }
380 free(buff);
381 }
382 DosClose(handle);
383 }
384 }
385 else if(!IsFile(currfile)) {
386
387 static FILEFINDBUF4 ffb[130];
388 static char fullname[CCHMAXPATH + 4];
389 HDIR hdir = HDIR_CREATE;
390 ULONG x,nm,ml,mc;
391 PBYTE fb;
392 PFILEFINDBUF4 pffbFile;
393 char *buff,*p;
394 APIRET rc;
395
396 sprintf(fullname,
397 "%s%s*",
398 currfile,
399 (currfile[strlen(currfile) - 1] == '\\') ? "" : "\\");
400 DosError(FERR_DISABLEHARDERR);
401 nm = sizeof(ffb) / sizeof(FILEFINDBUF4);
402 if(AutoviewHeight < 96)
403 nm /= 2;
404 rc = DosFindFirst(fullname,
405 &hdir,
406 FILE_NORMAL | FILE_DIRECTORY |
407 FILE_READONLY | FILE_ARCHIVED |
408 FILE_SYSTEM | FILE_HIDDEN,
409 &ffb,
410 sizeof(ffb),
411 &nm,
412 FIL_QUERYEASIZE);
413 if(!rc && nm) {
414 fb = (PBYTE)&ffb;
415 x = ml = 0;
416 while(x < nm) {
417 pffbFile = (PFILEFINDBUF4)fb;
418 mc = (ULONG)pffbFile->cchName +
419 ((pffbFile->attrFile & FILE_DIRECTORY) != 0);
420 ml = max(ml,mc);
421 if(!pffbFile->oNextEntryOffset)
422 break;
423 fb += pffbFile->oNextEntryOffset;
424 x++;
425 }
426 buff = malloc((CCHMAXPATHCOMP + 42) * nm);
427 if(buff) {
428 p = buff;
429 *p = 0;
430 fb = (PBYTE)&ffb;
431 x = 0;
432 while(x < nm) {
433 pffbFile = (PFILEFINDBUF4)fb;
434 if(!(!*pffbFile->achName ||
435 (((pffbFile->attrFile & FILE_DIRECTORY) &&
436 pffbFile->achName[0] == '.') &&
437 (!pffbFile->achName[1] ||
438 (pffbFile->achName[1] == '.' &&
439 !pffbFile->achName[2]))))) {
440 sprintf(p,
441 "%s%-*.*s %-8lu [%s%s%s%s] %04lu/%02lu/%02lu "
442 "%02lu:%02lu:%02lu\r",
443 ((pffbFile->attrFile & FILE_DIRECTORY) != 0) ?
444 "\\" : " ",
445 ml,
446 ml,
447 pffbFile->achName,
448 pffbFile->cbFile +
449 ((pffbFile->cbList > 4) ?
450 pffbFile->cbList / 2 :
451 0),
452 ((pffbFile->attrFile & FILE_READONLY) != 0) ?
453 "R" : "-",
454 ((pffbFile->attrFile & FILE_ARCHIVED) != 0) ?
455 "A" : "-",
456 ((pffbFile->attrFile & FILE_HIDDEN) != 0) ?
457 "H" : "-",
458 ((pffbFile->attrFile & FILE_SYSTEM) != 0) ?
459 "S" : "-",
460 pffbFile->fdateLastWrite.year + 1980,
461 pffbFile->fdateLastWrite.month,
462 pffbFile->fdateLastWrite.day,
463 pffbFile->ftimeLastWrite.hours,
464 pffbFile->ftimeLastWrite.minutes,
465 pffbFile->ftimeLastWrite.twosecs * 2);
466 p += strlen(p);
467 }
468 if(!pffbFile->oNextEntryOffset)
469 break;
470 fb += pffbFile->oNextEntryOffset;
471 x++;
472 }
473 if(*buff)
474 WinSetWindowText(hwndAutoview,buff);
475 free(buff);
476 }
477 }
478 if(!rc)
479 DosFindClose(hdir);
480 }
481 }
482 else {
483
484 APIRET rc;
485 EAOP2 eaop;
486 PGEA2LIST pgealist;
487 PFEA2LIST pfealist;
488 PGEA2 pgea;
489 PFEA2 pfea;
490 CHAR *value,*buff,*p,*data;
491 USHORT len,type,plen,dlen;
492 BOOL readonly = FALSE;
493
494 pgealist = malloc(sizeof(GEA2LIST) + 64);
495 if(pgealist) {
496 memset(pgealist,0,sizeof(GEA2LIST) + 64);
497 pgea = &pgealist->list[0];
498 strcpy(pgea->szName,".COMMENTS");
499 pgea->cbName = strlen(pgea->szName);
500 pgea->oNextEntryOffset = 0L;
501 pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
502 pfealist = malloc(65536);
503 if(pfealist) {
504 memset(pfealist,0,65536);
505 pfealist->cbList = 65536;
506 eaop.fpGEA2List = pgealist;
507 eaop.fpFEA2List = pfealist;
508 eaop.oError = 0L;
509 rc = DosQueryPathInfo((CHAR *)mp1,FIL_QUERYEASFROMLIST,
510 (PVOID)&eaop,
511 (ULONG)sizeof(EAOP2));
512 free(pgealist);
513 if(!rc) {
514 pfea = &eaop.fpFEA2List->list[0];
515 if(pfea->cbName && pfea->cbValue) {
516 value = pfea->szName + pfea->cbName + 1;
517 value[pfea->cbValue] = 0;
518 if(*(USHORT *)value == EAT_MVMT) {
519 buff = malloc(65536);
520 if(buff) {
521 p = buff;
522 *buff = 0;
523 data = value + (sizeof(USHORT) * 3);
524 type = *(USHORT *)data;
525 data += sizeof(USHORT);
526 len = *(USHORT *)data;
527 data += sizeof(USHORT);
528 while((data - value) - len < pfea->cbValue) {
529 if(type == EAT_ASCII) {
530 dlen = plen = 0;
531 while(dlen < len) {
532 if(data[dlen] == '\r') {
533 dlen++;
534 if(dlen < len && data[dlen] != '\n')
535 p[plen++] = '\n';
536 }
537 else
538 p[plen++] = data[dlen++];
539 }
540 if((!len || !plen || p[plen - 1] != '\n') &&
541 (data - value) + len < pfea->cbValue)
542 p[plen++] = '\n';
543 p += plen;
544 *p = 0;
545 }
546 else
547 readonly = TRUE;
548 data += len;
549 if(data - value >= pfea->cbValue)
550 break;
551 type = *(USHORT *)data;
552 data += sizeof(USHORT);
553 len = *(USHORT *)data;
554 data += sizeof(USHORT);
555 }
556 WinSetWindowText(hwndAutoMLE,buff);
557 free(buff);
558 }
559 }
560 else
561 readonly = TRUE;
562 }
563 /* else EA not present */
564 MLEsetchanged(hwndAutoMLE,FALSE);
565 MLEsetreadonly(hwndAutoMLE,readonly);
566 }
567 else {
568 MLEsetchanged(hwndAutoMLE,FALSE);
569 MLEsetreadonly(hwndAutoMLE,FALSE);
570 }
571 free(pfealist);
572 }
573 }
574 }
575 }
576 free((CHAR *)mp1);
577 }
578 return 0;
579
580 case UM_CLOSE:
581 if(!PostMsg((HWND)0,WM_QUIT,MPVOID,MPVOID))
582 WinSendMsg((HWND)0,WM_QUIT,MPVOID,MPVOID);
583 WinDestroyWindow(hwnd);
584 return 0;
585 }
586 return WinDefWindowProc(hwnd,msg,mp1,mp2);
587}
588
589
590VOID MakeAutoWin (VOID *args) {
591
592 HAB hab2;
593 HMQ hmq2;
594 HWND hwndParent = (HWND)args;
595 QMSG qmsg2;
596
597 hab2 = WinInitialize(0);
598 if(hab2) {
599 hmq2 = WinCreateMsgQueue(hab2,128);
600 if(hmq2) {
601 DosError(FERR_DISABLEHARDERR);
602 WinRegisterClass(hab2,
603 GetPString(IDS_WCOBJECTWINDOW),
604 AutoObjProc,
605 0,
606 sizeof(PVOID));
607 hwndAutoObj = WinCreateWindow(HWND_OBJECT,
608 GetPString(IDS_WCOBJECTWINDOW),
609 (PSZ)NULL,
610 0,
611 0L,
612 0L,
613 0L,
614 0L,
615 0L,
616 HWND_TOP,
617 OBJ_FRAME,
618 NULL,
619 NULL);
620 if(hwndAutoObj) {
621 WinSetWindowULong(hwndAutoObj,0,hwndParent);
622 priority_normal();
623 while(WinGetMsg(hab2,&qmsg2,(HWND)0,0,0))
624 WinDispatchMsg(hab2,&qmsg2);
625 WinDestroyWindow(hwndAutoObj);
626 hwndAutoObj = (HWND)0;
627 }
628 else {
629 if(!PostMsg(hwndParent,UM_CLOSE,MPVOID,MPVOID))
630 WinSendMsg(hwndParent,UM_CLOSE,MPVOID,MPVOID);
631 }
632 WinDestroyMsgQueue(hmq2);
633 }
634 else
635 WinTerminate(hab2);
636 }
637}
638
639
640MRESULT EXPENTRY AutoViewProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
641
642 USHORT id = WinQueryWindowUShort(hwnd,QWS_ID);
643
644 switch(msg) {
645 case WM_CREATE:
646 {
647 MRESULT mr;
648
649 if(!hwndAutoObj &&
650 _beginthread(MakeAutoWin,
651 NULL,
652 65536,
653 (PVOID)hwnd) == -1)
654 PostMsg(hwnd,
655 UM_CLOSE,
656 MPVOID,
657 MPVOID);
658 mr = PFNWPStatic(hwnd,msg,mp1,mp2);
659 SetPresParams(hwnd,
660 &RGBGREY,
661 &RGBBLACK,
662 &RGBGREY,
663 GetPString(IDS_4SYSTEMVIOTEXT));
664 stopflag = 0;
665 return mr;
666 }
667
668 case UM_SETUP:
669 MLEsetlimit(hwnd,32768);
670 MLEsetformat(hwnd,MLFIE_NOTRANS);
671 MLEsetchanged(hwnd,FALSE);
672 return 0;
673
674 case WM_BUTTON1DOWN:
675 {
676 SWP swp;
677
678 WinQueryWindowPos(hwnd,&swp);
679 if(SHORT2FROMMP(mp1) > swp.cy - 4) {
680
681 HPS hps = WinGetPS(WinQueryWindow(hwnd,QW_PARENT));
682 SWP swpC;
683 TRACKINFO track;
684
685 if(hps) {
686 WinQueryWindowPos(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
687 FID_CLIENT),&swpC);
688 track.cxBorder = 4;
689 track.cyBorder = 4;
690 track.cxGrid = 1;
691 track.cyGrid = 8;
692 track.cxKeyboard = 8;
693 track.rclTrack.yBottom = swp.y;
694 track.rclTrack.yTop = swp.y + swp.cy;
695 track.rclTrack.xLeft = swp.x;
696 track.rclTrack.xRight = swp.x + swp.cx;
697 track.rclBoundary = track.rclTrack;
698 track.rclBoundary.yTop = (swpC.cy + swp.y + swp.cy) - 116;
699 track.ptlMinTrackSize.x = swp.x + swp.cx;
700 track.ptlMinTrackSize.y = 36;
701 track.ptlMaxTrackSize.x = swp.x + swp.cx;
702 track.ptlMaxTrackSize.y = (swpC.cy + swp.cy) - 116;
703 track.fs = TF_TOP;
704 if(WinTrackRect(hwnd,hps,&track)) {
705 AutoviewHeight = track.rclTrack.yTop - track.rclTrack.yBottom;
706 PrfWriteProfileData(fmprof,
707 FM3Str,
708 "AutoviewHeight",
709 &AutoviewHeight,
710 sizeof(ULONG));
711 WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),
712 WM_UPDATEFRAME,
713 MPFROMLONG(FCF_SIZEBORDER),
714 MPVOID);
715 }
716 WinReleasePS(hps);
717 }
718 return (MRESULT)TRUE;
719 }
720 else if(id != MAIN_AUTOVIEWMLE)
721 return CommonTextButton(hwnd,msg,mp1,mp2);
722 }
723 break;
724
725 case WM_BUTTON3DOWN:
726 case WM_BUTTON1UP:
727 case WM_BUTTON3UP:
728 if(id != MAIN_AUTOVIEWMLE)
729 return CommonTextButton(hwnd,msg,mp1,mp2);
730 break;
731
732 case WM_MOUSEMOVE:
733 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
734 {
735 SWP swp;
736
737 WinQueryWindowPos(hwnd,&swp);
738 if(SHORT2FROMMP(mp1) > swp.cy - 4) {
739 WinSetPointer(HWND_DESKTOP,hptrNS);
740 return (MRESULT)TRUE;
741 }
742 }
743 break;
744
745 case WM_PAINT:
746 PostMsg(hwnd,
747 UM_PAINT,
748 MPVOID,
749 MPVOID);
750 break;
751
752 case UM_PAINT:
753 PaintRecessedWindow(hwnd,(HPS)0,TRUE,TRUE);
754 return 0;
755
756 case WM_SETFOCUS:
757 switch(id) {
758 case MAIN_AUTOVIEWMLE:
759 if(!mp2 && !AutoMenu) {
760 if(*currfile) {
761 if(MLEgetchanged(hwnd)) {
762
763 CHAR *ea = malloc(32768);
764
765 if(ea) {
766 *ea = 0;
767 WinQueryWindowText(hwnd,32767,ea);
768 PutComments(hwnd,
769 currfile,
770 ea);
771 PostMsg(hwnd,
772 WM_COMMAND,
773 MPFROM2SHORT(IDM_RESCAN,0),
774 MPVOID);
775 free(ea);
776 }
777 }
778 }
779 }
780 break;
781 default:
782 if(mp2)
783 PostMsg(hwnd,
784 UM_FOCUSME,
785 mp1,
786 mp2);
787 break;
788 }
789 break;
790
791 case UM_FOCUSME:
792 if(mp2) {
793
794 PID pid;
795 TID tid;
796
797 if(WinQueryWindowProcess((HWND)mp1,
798 &pid,
799 &tid) &&
800 pid == mypid)
801 WinSetFocus(HWND_DESKTOP,
802 (HWND)mp1);
803 else
804 WinSetFocus(HWND_DESKTOP,
805 hwndTree);
806 }
807 return 0;
808
809 case UM_CLICKED:
810 case UM_CLICKED3:
811 if(id != MAIN_AUTOVIEWMLE) {
812 PostMsg(hwnd,
813 WM_COMMAND,
814 MPFROM2SHORT(((msg == UM_CLICKED3) ?
815 IDM_EAS :
816 IDM_VIEWORARC),
817 0),
818 MPVOID);
819 }
820 return 0;
821
822 case WM_COMMAND:
823 PostMsg(hwnd,
824 UM_COMMAND,
825 mp1,
826 mp2);
827 return 0;
828
829 case UM_COMMAND:
830 switch(SHORT1FROMMP(mp1)) {
831 case IDM_RESCAN:
832 if(*currfile) {
833
834 CHAR *cf = strdup(currfile);
835
836 if(cf) {
837 stopflag++;
838 if(!PostMsg(hwndAutoObj,
839 UM_LOADFILE,
840 MPFROMP(cf),
841 MPVOID))
842 free(cf);
843 }
844 }
845 break;
846
847 case IDM_INFO:
848 DefaultView(hwnd,
849 (HWND)0,
850 hwndMain,
851 NULL,
852 16,
853 currfile);
854 break;
855
856 case IDM_VIEW:
857 DefaultView(hwnd,
858 (HWND)0,
859 hwndMain,
860 NULL,
861 0,
862 currfile);
863 break;
864
865 case IDM_EDIT:
866 DefaultView(hwnd,
867 (HWND)0,
868 hwndMain,
869 NULL,
870 8,
871 currfile);
872 break;
873
874 case IDM_EAS:
875 {
876 char *list[2];
877
878 list[0] = currfile;
879 list[1] = NULL;
880
881 WinDlgBox(HWND_DESKTOP,
882 hwndMain,
883 DisplayEAsProc,
884 FM3ModHandle,
885 EA_FRAME,
886 (PVOID)list);
887 }
888 break;
889
890 default:
891 PostMsg(hwndMain,
892 msg,
893 mp1,
894 mp2);
895 }
896 return 0;
897
898 case WM_MENUEND:
899 if((HWND)mp2 == AutoMenu) {
900 WinDestroyWindow(AutoMenu);
901 AutoMenu = (HWND)0;
902 }
903 break;
904
905 case WM_CONTEXTMENU:
906 CheckMenu(&AutoMenu,(id == MAIN_AUTOVIEWMLE) ?
907 IDM_AUTOVIEWMLE : IDM_AUTOVIEW);
908 WinCheckMenuItem(AutoMenu,
909 IDM_AUTOVIEWFILE,
910 !fComments);
911 WinCheckMenuItem(AutoMenu,
912 IDM_AUTOVIEWCOMMENTS,
913 fComments);
914 WinEnableMenuItem(AutoMenu,
915 IDM_VIEW,
916 (IsFile(currfile) == 1));
917 WinEnableMenuItem(AutoMenu,
918 IDM_EDIT,
919 (IsFile(currfile) == 1));
920 WinEnableMenuItem(AutoMenu,
921 IDM_INFO,
922 (*currfile != 0));
923 PopupMenu(hwnd,
924 hwnd,
925 AutoMenu);
926 break;
927
928 case UM_LOADFILE:
929 stopflag++;
930 if(!PostMsg(hwndAutoObj,
931 msg,
932 mp1,
933 mp2)) {
934 if(mp1)
935 free((CHAR *)mp1);
936 }
937 return 0;
938
939 case UM_CLOSE:
940 if(AutoMenu) {
941 WinDestroyWindow(AutoMenu);
942 AutoMenu = (HWND)0;
943 }
944 WinDestroyWindow(hwnd);
945 return 0;
946
947 case WM_CLOSE:
948 WinSendMsg(hwnd,
949 UM_CLOSE,
950 MPVOID,
951 MPVOID);
952 return 0;
953
954 case WM_DESTROY:
955 if(id != MAIN_AUTOVIEWMLE) {
956 if(hwndAutoObj)
957 if(!PostMsg(hwndAutoObj,
958 WM_CLOSE,
959 MPVOID,
960 MPVOID))
961 WinSendMsg(hwndAutoObj,
962 WM_CLOSE,
963 MPVOID,
964 MPVOID);
965 break;
966 }
967 break;
968 }
969
970 if(id == MAIN_AUTOVIEWMLE)
971 return PFNWPMLE(hwnd,msg,mp1,mp2);
972 return PFNWPStatic(hwnd,msg,mp1,mp2);
973}
974
Note: See TracBrowser for help on using the repository browser.