Changeset 356
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
trunk/dll/menu.c
r123 r356 7 7 8 8 Copyright (c) 1996-98 M. Kimes 9 Copyright (c) 2004 Steven H.Levine9 Copyright (c) 2004, 2006 Steven H.Levine 10 10 11 Revisions 01 Aug 04 SHL - Rework lstrip/rstrip usage 11 01 Aug 04 SHL Rework lstrip/rstrip usage 12 22 Jul 06 SHL Check more run time errors 12 13 13 14 ***********************************************************************/ … … 15 16 #define INCL_DOS 16 17 #define INCL_WIN 18 #include <os2.h> 17 19 18 #include <os2.h>19 20 #include <stdio.h> 20 21 #include <stdlib.h> 21 22 #include <string.h> 22 23 #include <share.h> 24 23 25 #include "fm3dll.h" 24 26 #include "menu.h" 25 27 26 28 #pragma data_seg(DATA2) 29 30 static PSZ pszSrcFile = __FILE__; 31 27 32 #pragma alloc_text(MENU,tokenize,FreeMenuList,AddToMenu) 28 33 29 34 MENU *menuhead = NULL; 30 35 31 32 INT tokenize (CHAR *str,INT max,CHAR **tokens) { 33 36 INT tokenize (CHAR *str,INT max,CHAR **tokens) 37 { 34 38 INT x = 0; 35 39 CHAR *p; … … 49 53 *p = 0; 50 54 p++; 51 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"\"%s\"\r\r%d",tokens[x - 1],x);55 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"\"%s\"\r\r%d",tokens[x - 1],x); 52 56 if(!*p) 53 57 break; … … 58 62 59 63 60 VOID FreeMenuList (MENU *head) {61 64 VOID FreeMenuList (MENU *head) 65 { 62 66 MENU *info,*next; 63 67 … … 73 77 74 78 75 BOOL AddToMenu (CHAR *filename,HWND hwndMenu) {76 79 BOOL AddToMenu (CHAR *filename,HWND hwndMenu) 80 { 77 81 FILE *fp; 78 82 CHAR s[256]; … … 82 86 BOOL ret = FALSE; 83 87 84 if(!hwndMenu) 88 // fixme to complain? 89 if (!hwndMenu) { 90 Runtime_Error(pszSrcFile, __LINE__, "no data"); 85 91 return ret; 86 if(!filename) 92 } 93 if (!filename) 87 94 filename = "FM3MENU.DAT"; 88 95 fp = _fsopen(filename,"r",SH_DENYWR); 89 if(fp) { 90 while(!feof(fp)) { 91 if(!fgets(s,256,fp)) 96 if (!fp) { 97 // else saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Couldn't open %s",filename); 98 } 99 else { 100 while (!feof(fp)) { 101 if (!fgets(s,256,fp)) 92 102 break; 93 103 lines++; … … 95 105 if(!*s || *s == ';') 96 106 continue; 97 if(tokenize(s,3,tokens) == 3 && (USHORT)atoi(tokens[1])) { 98 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%s\r\r%s\r\r%s",tokens[0],tokens[1],tokens[2]); 99 info = malloc(sizeof(MENU)); 100 if(info) { 101 memset(info,0,sizeof(MENU)); 107 if (tokenize(s,3,tokens) == 3 && (USHORT)atoi(tokens[1])) { 108 info = xmallocz(sizeof(MENU),pszSrcFile,__LINE__); 109 if (info) { 102 110 info->size = sizeof(MENU); 103 info->text = strdup(tokens[2]); 104 if(info->text) { 105 if(!stricmp(tokens[0],"MENUITEM")) 111 info->text = xstrdup(tokens[2],pszSrcFile,__LINE__); 112 if (!info->text) 113 free(info); 114 else { 115 if (!stricmp(tokens[0],"MENUITEM")) 106 116 info->cmd = atoi(tokens[1]); 107 else if (!stricmp(tokens[0],"SEPARATOR"))117 else if (!stricmp(tokens[0],"SEPARATOR")) 108 118 info->type = SEPARATOR; 109 else { /* error! */ 119 else { 120 /* error! */ 110 121 free(info->text); 111 122 free(info); 112 123 info = NULL; 113 124 } 114 if (info) {125 if (info) { 115 126 if(!menuhead) 116 127 menuhead = info; … … 121 132 } 122 133 } 123 else124 free(info);125 134 } 126 135 } 127 else { /* error! */ 128 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tokenization failed"); 136 else { 137 // fixme to complain? 138 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tokenization failed"); 129 139 } 130 140 } 131 141 fclose(fp); 132 if(menuhead) {133 142 143 if (menuhead) { 134 144 MENUITEM mi; 135 145 … … 137 147 info = menuhead; 138 148 WinEnableWindow(hwndMenu,FALSE); 139 while (info) {149 while (info) { 140 150 mi.iPosition = MIT_END; 141 151 mi.id = info->cmd; 142 152 mi.afStyle = (info->type == SEPARATOR) ? MIS_BREAKSEPARATOR : MIS_TEXT; 143 if (WinSendMsg(hwndMenu, MM_INSERTITEM, MPFROMP(&mi),144 MPFROMP(info->text)))153 if (WinSendMsg(hwndMenu, MM_INSERTITEM, MPFROMP(&mi), 154 MPFROMP(info->text))) 145 155 ret = TRUE; 146 156 info = info->next; … … 151 161 } 152 162 } 153 // else saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Couldn't open %s",filename);154 163 return ret; 155 164 }  - 
      
trunk/dll/notify.c
r2 r356 1 2 /*********************************************************************** 3 4 $Id$ 5 6 Notifications 7 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2006 Steven H.Levine 10 11 17 Jul 06 SHL Use Win_Error 12 22 Jul 06 SHL Check more run time errors 13 14 ***********************************************************************/ 15 1 16 #define INCL_DOS 2 17 #define INCL_WIN 3 18 #define INCL_GPI 4 5 19 #include <os2.h> 20 6 21 #include <stdarg.h> 7 22 #include <stdio.h> … … 11 26 #include <time.h> 12 27 #include <stddef.h> 28 13 29 #include "fm3dll.h" 14 30 #include "fm3dlg.h" … … 16 32 17 33 #pragma data_seg(DATA1) 34 35 static PSZ pszSrcFile = __FILE__; 36 18 37 #pragma alloc_text(NOTIFY,Notify,NotifyWndProc,StartNotify) 19 38 #pragma alloc_text(NOTIFY,NotifyThread,NotifyError) … … 23 42 static HWND hwndNotify; 24 43 25 26 MRESULT EXPENTRY NotifyWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { 27 44 MRESULT EXPENTRY NotifyWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 45 { 28 46 static ULONG showing = 0; 29 47 … … 39 57 ID_TIMER2, 40 58 5000)) { 41 DosBeep(50,100);59 Win_Error(hwnd,hwnd,pszSrcFile,__LINE__,"WinStartTimer"); 42 60 WinDestroyWindow(hwnd); 43 61 } … … 125 143 126 144 127 HWND DoNotify (char *str) {128 145 HWND DoNotify (char *str) 146 { 129 147 char *p; 130 148 HWND hwnd = (HWND)0,hwndP; … … 157 175 /* pretty-up the note by putting on a leading space */ 158 176 if(*str != ' ') { 159 p = malloc(strlen(str) + 2);177 p = xmalloc(strlen(str) + 2,pszSrcFile,__LINE__); 160 178 if(!p) 161 179 p = str; … … 193 211 194 212 195 HWND Notify (char *str) {196 213 HWND Notify (char *str) 214 { 197 215 return (HWND)WinSendMsg(MainObjectHwnd,UM_NOTIFY,MPFROMP(str),MPVOID); 198 216 } 199 217 200 218 201 VOID NotifyError (CHAR *filename,APIRET status) {202 219 VOID NotifyError (CHAR *filename,APIRET status) 220 { 203 221 CHAR errortext[512]; 204 222 … … 241 259 242 260 243 MRESULT EXPENTRY NoteWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {244 261 MRESULT EXPENTRY NoteWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) 262 { 245 263 static HPOINTER hptrIcon = (HPOINTER)0; 246 264 … … 459 477 460 478 461 VOID NoteThread (VOID *args) {462 479 VOID NoteThread (VOID *args) 480 { 463 481 HAB hab2; 464 482 HMQ hmq2; … … 482 500 483 501 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 502 VOID StartNotes (CHAR *note) 503 { 504 if (!hwndNotify) { 505 if (_beginthread(NoteThread,NULL,65536,(PVOID)note) == -1) 506 Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT)); 507 } 508 } 509 510 511 BOOL AddNote (CHAR *note) 512 { 501 513 CHAR *s,*p; 502 514 BOOL once = FALSE,ret = FALSE; … … 549 561 550 562 551 VOID EndNote (VOID) {552 563 VOID EndNote (VOID) 564 { 553 565 if(hwndNotify) 554 566 if(!PostMsg(hwndNotify, … … 563 575 564 576 565 VOID ShowNote (VOID) {566 577 VOID ShowNote (VOID) 578 { 567 579 if(!hwndNotify) 568 580 StartNotes(NULL); … … 581 593 582 594 583 VOID HideNote (VOID) {584 595 VOID HideNote (VOID) 596 { 585 597 if(hwndNotify) 586 598 WinSetWindowPos(hwndNotify,  - 
      
trunk/dll/presparm.c
r2 r356 1 2 /*********************************************************************** 3 4 $Id$ 5 6 Edit presentation parameters 7 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2006 Steven H.Levine 10 11 22 Jul 06 SHL Check more run time errors 12 13 ***********************************************************************/ 14 1 15 #define INCL_DOS 2 16 #define INCL_WIN 3 17 #define INCL_GPI 4 5 18 #include <os2.h> 19 6 20 #include <stdarg.h> 7 21 #include <stdio.h> … … 9 23 #include <string.h> 10 24 #include <ctype.h> 25 11 26 #include "fm3dll.h" 27 28 static PSZ pszSrcFile = __FILE__; 12 29 13 30 #pragma alloc_text(PRESPARAM,CopyPresParams,SetPresParams,IfNoParam) 14 31 #pragma alloc_text(PRESPARAM,PresParamChanged,RestorePresParams) 15 32 #pragma alloc_text(PRESPARAM,StoreWndPresParams) 16 17 33 18 34 #ifdef NEVER … … 22 38 * pPresParams ie. WinCreateWindow(,,,,,,,,,,,, PVOID pPresParams) 23 39 */ 24 VOID StoreWndPresParams (HWND hwnd,CHAR *tagname,HINI prof) {25 40 VOID StoreWndPresParams (HWND hwnd,CHAR *tagname,HINI prof) 41 { 26 42 PARAM *pparam; 27 43 PRESPARAMS *ppresparams; … … 30 46 return; 31 47 /* setup memory access */ 32 ppresparams = (PRESPARAMS *) malloc(PP_MAXBUF);48 ppresparams = (PRESPARAMS *)xmalloc(PP_MAXBUF,pszSrcFile,__LINE__); 33 49 if(!ppresparams) 34 50 return; … … 322 338 } 323 339 324 #endif 325 326 327 VOID CopyPresParams (HWND target,HWND source) {328 340 #endif // NEVER 341 342 343 VOID CopyPresParams (HWND target,HWND source) 344 { 329 345 /* 330 346 * Copy presentation parameters of interest to us from one window … … 355 371 356 372 357 VOID SetPresParams (HWND hwnd,RGB2 *back,RGB2 *fore,RGB2 *border,CHAR *font) {358 373 VOID SetPresParams (HWND hwnd,RGB2 *back,RGB2 *fore,RGB2 *border,CHAR *font) 374 { 359 375 if(font) 360 376 WinSetPresParam(hwnd, … … 380 396 381 397 382 VOID IfNoParam(HWND hwnd,CHAR *keyroot,ULONG size,PVOID attrvalue) {383 398 VOID IfNoParam(HWND hwnd,CHAR *keyroot,ULONG size,PVOID attrvalue) 399 { 384 400 ULONG fsize = 0L; 385 401 CHAR s[81]; … … 400 416 401 417 402 VOID PresParamChanged (HWND hwnd,CHAR *keyroot,MPARAM mp1,MPARAM mp2) {403 404 ULONG AttrFound,AttrValue[64],cbRetLen;418 VOID PresParamChanged (HWND hwnd,CHAR *keyroot,MPARAM mp1,MPARAM mp2) 419 { 420 ULONG AttrFound,AttrValue[64],cbRetLen; 405 421 406 422 cbRetLen = WinQueryPresParam(hwnd,(ULONG)mp1,0,&AttrFound, … … 440 456 441 457 442 VOID RestorePresParams (HWND hwnd,CHAR *keyroot) {443 444 CHAR s[81];458 VOID RestorePresParams (HWND hwnd,CHAR *keyroot) 459 { 460 CHAR s[81]; 445 461 ULONG AttrValue[64],size; 446 462  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  