home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * ....................................... *
- * . . *
- * . TOOLBOX - INTERPRETER . *
- * . CALLBACK - FUNKTIONEN . *
- * . WINPROCS.C . *
- * . M.Beising & K.Bauer & TOOLBOX . *
- * ....................................... *
- *************************************************************************/
-
- #include <windows.h>
- #include "txl.h"
-
- BOOL FAR PASCAL SetTextBox(HWND, unsigned, WORD, LONG);
- BOOL FAR PASCAL Input(HWND, unsigned, WORD, LONG);
- HANDLE FAR PASCAL OpenDlg(HWND, unsigned, WORD, LONG);
-
- void UpdateListBox(HWND);
- void SeparateFile(HWND, LPSTR, LPSTR, LPSTR);
- void AddExt(PSTR, PSTR);
- void ChangeDefExt(PSTR, PSTR);
- void OemAnsiSymb(HWND hDlg,WORD wParam);
- void lstrncpy(LPSTR,LPSTR,int);
-
- extern int TORIENT,TESCP,TOutP,TCliP,TQual,TFam,oem;
- extern unsigned char Textstr[256];
- extern unsigned char Questr[200];
- extern char FileName[FNAMLEN];
- extern BOOL LoadFile;
-
- char DefPath[128];
- char DefSpec[13] = "*.TXL"; /* default search spec */
- char DefExt[] = ".TXL"; /* default extension */
- char str[255];
-
-
- BOOL FAR PASCAL Input(hDlg, message, wParam, lParam)
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
- switch (message) {
- case WM_INITDIALOG:
- SendDlgItemMessage(hDlg,MN_TEXT,EM_LIMITTEXT,256,0L);
- strcpy(Textstr,"?");
- SetDlgItemText(hDlg,MN_QUESTION,(LPSTR)Questr);
- SetDlgItemText(hDlg,MN_TEXT,(LPSTR)Textstr);
- return (TRUE);
- case WM_COMMAND:
- if (wParam == IDOK) {
- GetDlgItemText(hDlg,MN_TEXT,(LPSTR)Textstr,256);
- EndDialog(hDlg, NULL);
- return (TRUE);
- }
- break;
- }
- return (FALSE); /* Didn't process a message */
- }
-
- BOOL FAR PASCAL About( hDlg, message, wParam, lParam )
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
- if (message == WM_COMMAND) {
- EndDialog( hDlg, TRUE );
- return TRUE;
- }
- else if (message == WM_INITDIALOG)
- return TRUE;
- else return FALSE;
- }
-
- void OemAnsiSymb(HWND hDlg,WORD wParam)
- {
- if(wParam) {
- if(wParam == MW_ANSI)
- oem=0;
- else
- if(wParam == MW_SYMB)
- oem=2;
- else
- if(wParam == MW_OEM)
- oem=255;
- }
- if(oem==0)
- CheckDlgButton(hDlg,MW_ANSI,TRUE);
- else
- CheckDlgButton(hDlg,MW_ANSI,FALSE);
-
- if(oem==2)
- CheckDlgButton(hDlg,MW_SYMB,TRUE);
- else
- CheckDlgButton(hDlg,MW_SYMB,FALSE);
-
- if(oem==255)
- CheckDlgButton(hDlg,MW_OEM,TRUE);
- else
- CheckDlgButton(hDlg,MW_OEM,FALSE);
- }
-
- BOOL FAR PASCAL SetTextBox(hDlg, message, wParam, lParam)
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
- HWND hCtrl;
- int fam;
- switch (message) {
- case WM_INITDIALOG:
- OemAnsiSymb(hDlg,0);
- fam=TOutP+136;
- CheckDlgButton(hDlg,OP_DEF,FALSE);
- CheckDlgButton(hDlg,OP_CHAR,FALSE);
- CheckDlgButton(hDlg,OP_STRING,FALSE);
- CheckDlgButton(hDlg,OP_STROKE,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=TCliP+140;
- CheckDlgButton(hDlg,CL_DEF,FALSE);
- CheckDlgButton(hDlg,CL_CHAR,FALSE);
- CheckDlgButton(hDlg,CL_STROKE,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=TQual+143;
- CheckDlgButton(hDlg,QU_DEF,FALSE);
- CheckDlgButton(hDlg,QU_DRAFT,FALSE);
- CheckDlgButton(hDlg,QU_PROOF,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=TFam/10+145;
- CheckDlgButton(hDlg,FA_DEF,FALSE);
- CheckDlgButton(hDlg,FA_FIX,FALSE);
- CheckDlgButton(hDlg,FA_VAR,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=TFam % 10;
- fam+=149;
- CheckDlgButton(hDlg,FA_SWS,FALSE);
- CheckDlgButton(hDlg,FA_SCR,FALSE);
- CheckDlgButton(hDlg,FA_ROM,FALSE);
- CheckDlgButton(hDlg,FA_MOD,FALSE);
- CheckDlgButton(hDlg,FA_DEC,FALSE);
- CheckDlgButton(hDlg,FA_DNTC,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=0;
-
- return (TRUE);
- break;
- case WM_COMMAND:
- switch(wParam)
- {
- case IDOK:
- EndDialog(hDlg, NULL);
- return (TRUE);
- break;
- case OP_DEF: TOutP=0;
- case OP_CHAR: if(wParam==OP_CHAR) TOutP=1;
- case OP_STRING: if(wParam==OP_STRING) TOutP=2;
- case OP_STROKE: if(wParam==OP_STROKE) TOutP=3;
- fam=TOutP+136;
- CheckDlgButton(hDlg,OP_DEF,FALSE);
- CheckDlgButton(hDlg,OP_CHAR,FALSE);
- CheckDlgButton(hDlg,OP_STRING,FALSE);
- CheckDlgButton(hDlg,OP_STROKE,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=0;
- break;
- case CL_DEF: TCliP=0;
- case CL_CHAR: if(wParam==CL_CHAR) TCliP=1;
- case CL_STROKE: if(wParam==CL_STROKE) TCliP=2;
- fam=TCliP+140;
- CheckDlgButton(hDlg,CL_DEF,FALSE);
- CheckDlgButton(hDlg,CL_CHAR,FALSE);
- CheckDlgButton(hDlg,CL_STROKE,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=0;
- break;
- case QU_DEF: TQual=0;
- case QU_DRAFT: if(wParam==QU_DRAFT) TQual=1;
- case QU_PROOF: if(wParam==QU_PROOF) TQual=2;
- fam=TQual+143;
- CheckDlgButton(hDlg,QU_DEF,FALSE);
- CheckDlgButton(hDlg,QU_DRAFT,FALSE);
- CheckDlgButton(hDlg,QU_PROOF,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=0;
- break;
- case FA_DEF: TFam=10;
- case FA_FIX: if(wParam==FA_FIX) TFam=20;
- case FA_VAR: if(wParam==FA_VAR) TFam=30;
- fam=(TFam/10)+145;
- CheckDlgButton(hDlg,FA_DEF,FALSE);
- CheckDlgButton(hDlg,FA_FIX,FALSE);
- CheckDlgButton(hDlg,FA_VAR,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- case FA_DNTC: fam=0;
- case FA_DEC: if(wParam==FA_DEC) fam=1;
- case FA_MOD: if(wParam==FA_MOD) fam=2;
- case FA_ROM: if(wParam==FA_ROM) fam=3;
- case FA_SCR: if(wParam==FA_SCR) fam=4;
- case FA_SWS: if(wParam==FA_SWS) fam=5;
- TFam /= 10;
- TFam *= 10;
- TFam += fam;
- fam+=149;
- CheckDlgButton(hDlg,FA_SWS,FALSE);
- CheckDlgButton(hDlg,FA_SCR,FALSE);
- CheckDlgButton(hDlg,FA_ROM,FALSE);
- CheckDlgButton(hDlg,FA_MOD,FALSE);
- CheckDlgButton(hDlg,FA_DEC,FALSE);
- CheckDlgButton(hDlg,FA_DNTC,FALSE);
- CheckDlgButton(hDlg,fam,TRUE);
- fam=0;
- break;
- case MW_OEM:
- case MW_SYMB:
- case MW_ANSI: OemAnsiSymb(hDlg,wParam);
- break;
- }
- break;
- }
- return (FALSE);
- }
-
-
- HANDLE FAR PASCAL OpenDlg(hDlg, message, wParam, lParam)
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
- WORD index; /* index to the filenames in the list box */
- PSTR pTptr; /* temporary pointer */
- HANDLE hFile; /* handle to the opened file */
-
- switch (message) {
- case WM_COMMAND:
- switch (wParam) {
-
- case ID_LISTBOX:
- switch (HIWORD(lParam)) {
- case LBN_SELCHANGE:
- if (!DlgDirSelect(hDlg, str, ID_LISTBOX)) {
- SetDlgItemText(hDlg, ID_EDIT, str);
- SendDlgItemMessage(hDlg, ID_EDIT, EM_SETSEL,
- NULL, MAKELONG(0, 0x7fff));
- }
- else {
- strcat(str, DefSpec);
- DlgDirList(hDlg, str, ID_LISTBOX,
- ID_PATH, 0x4010);
- }
- break;
- case LBN_DBLCLK:
- goto openfile;
- } /* Ends ID_LISTBOX case */
- return(TRUE);
-
- case IDOK:
- openfile:
- GetDlgItemText(hDlg, ID_EDIT, FileName, 128);
- if (strchr(FileName, '*') || strchr(FileName, '?')) {
- SeparateFile(hDlg, (LPSTR) str, (LPSTR) DefSpec,
- (LPSTR) FileName);
- if (str[0])
- strcpy(DefPath, str);
- ChangeDefExt(DefExt, DefSpec);
- UpdateListBox(hDlg);
- return(TRUE);
- }
- if (!FileName[0]) {
- PRINTF ("# no Filename #");
- LoadFile = FALSE;
- return(TRUE);
- } else LoadFile = TRUE;
-
- AddExt(FileName, DefExt);
-
- EndDialog(hDlg, NULL);
- return(TRUE);
-
- case IDCANCEL:
- LoadFile = FALSE;
- EndDialog(hDlg, NULL);
- return(TRUE);
- }
- break;
-
- case WM_INITDIALOG: /* Request to initalize */
- UpdateListBox(hDlg);
- SetDlgItemText(hDlg, ID_EDIT, DefSpec);
- SendDlgItemMessage(hDlg, /* dialog handle */
- ID_EDIT, /* where to send message */
- EM_SETSEL, /* select characters */
- NULL, /* additional information */
- MAKELONG(0, 0x7fff)); /* Accept entire contents */
-
- SetFocus(GetDlgItem(hDlg, ID_EDIT));
- return (FALSE); /* Indicates the focus is set to a control */
- }
- return FALSE;
- }
-
- void UpdateListBox(hDlg)
- HWND hDlg;
- {
- strcpy(str, DefPath);
- strcat(str, DefSpec);
- DlgDirList(hDlg, str, ID_LISTBOX, ID_PATH, 0x4010);
- SetDlgItemText(hDlg, ID_EDIT, DefSpec);
- }
-
- void ChangeDefExt(Ext, Name)
- PSTR Ext, Name;
- {
- PSTR pTptr;
-
- pTptr = Name;
- while (*pTptr && *pTptr != '.')
- pTptr++;
- if (*pTptr) /* true if this is an extension */
- if (!strchr(pTptr, '*') && !strchr(pTptr, '?'))
- strcpy(Ext, pTptr); /* Copies the extension */
- }
-
- void SeparateFile(hDlg, lpDestPath, lpDestFileName, lpSrcFileName)
- HWND hDlg;
- LPSTR lpDestPath, lpDestFileName, lpSrcFileName;
- {
- LPSTR lpTmp;
-
- lpTmp = lpSrcFileName + (long) lstrlen(lpSrcFileName);
-
- while (*lpTmp != ':' && *lpTmp != '\\' && lpTmp > lpSrcFileName)
- lpTmp = AnsiPrev(lpSrcFileName, lpTmp);
-
- if (*lpTmp != ':' && *lpTmp != '\\') {
- lstrcpy(lpDestFileName, lpSrcFileName);
- lpDestPath[0] = 0;
- return;
- }
-
- lstrcpy(lpDestFileName, lpTmp + 1L);
- lstrncpy(lpDestPath, lpSrcFileName, (int) (lpTmp - lpSrcFileName) + 1);
- lpDestPath[(lpTmp - lpSrcFileName) + 1] = 0;
- }
-
- void AddExt(Name, Ext)
- PSTR Name, Ext;
- {
- PSTR pTptr;
-
- pTptr = Name;
- while (*pTptr && *pTptr != '.')
- pTptr++;
- if (*pTptr != '.') /* If no extension, add the default */
- strcat(Name, Ext);
- }
-
- void lstrncpy(lpDest, lpSrc, n)
- LPSTR lpDest, lpSrc;
- int n;
- {
- while (n--)
- if (!(*lpDest++ = *lpSrc++))
- return;
- }