1 | #define INCL_DOS
|
---|
2 | #define INCL_WIN
|
---|
3 |
|
---|
4 | #include <os2.h>
|
---|
5 | #include <stdlib.h>
|
---|
6 | #include <stdio.h>
|
---|
7 | #include <string.h>
|
---|
8 | #include <ctype.h>
|
---|
9 | #include "fm3dll.h"
|
---|
10 | #include "fm3dlg.h"
|
---|
11 | #include "fm3str.h"
|
---|
12 | #include "mle.h"
|
---|
13 |
|
---|
14 | #pragma data_seg(DATA1)
|
---|
15 | #pragma alloc_text(INSTANT,InstantDlgProc)
|
---|
16 |
|
---|
17 | #define hwndMLE WinWindowFromID(hwnd,BAT_MLE)
|
---|
18 |
|
---|
19 | static INT batches = 0;
|
---|
20 |
|
---|
21 |
|
---|
22 | MRESULT EXPENTRY InstantDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
|
---|
23 |
|
---|
24 | CHAR *path;
|
---|
25 | APIRET temp;
|
---|
26 | static CHAR *bat = NULL;
|
---|
27 | static HWND myhwnd = (HWND)0;
|
---|
28 |
|
---|
29 | switch(msg) {
|
---|
30 | case WM_INITDLG:
|
---|
31 | if(myhwnd) {
|
---|
32 | DosBeep(250,100);
|
---|
33 | WinSendMsg(myhwnd,WM_SYSCOMMAND,MPFROM2SHORT(SC_RESTORE,0),MPVOID);
|
---|
34 | WinSetActiveWindow(HWND_DESKTOP,myhwnd);
|
---|
35 | WinDismissDlg(hwnd,0);
|
---|
36 | break;
|
---|
37 | }
|
---|
38 | if(!mp2) {
|
---|
39 | DosBeep(50,100);
|
---|
40 | WinDismissDlg(hwnd,0);
|
---|
41 | break;
|
---|
42 | }
|
---|
43 | WinSetWindowPtr(hwnd,0,mp2);
|
---|
44 | path = (CHAR *)mp2;
|
---|
45 | {
|
---|
46 | CHAR s[CCHMAXPATH + 81];
|
---|
47 |
|
---|
48 | sprintf(s,
|
---|
49 | GetPString(IDS_INSTANTTITLETEXT),
|
---|
50 | path);
|
---|
51 | WinSetWindowText(hwnd,s);
|
---|
52 | }
|
---|
53 | WinSendMsg(hwndMLE,
|
---|
54 | MLM_SETTEXTLIMIT,
|
---|
55 | MPFROMLONG((LONG)(10240L)),
|
---|
56 | MPVOID);
|
---|
57 | WinSendMsg(hwndMLE,
|
---|
58 | MLM_FORMAT,
|
---|
59 | MPFROM2SHORT(MLFIE_NOTRANS,0),
|
---|
60 | MPVOID);
|
---|
61 | if(bat) {
|
---|
62 |
|
---|
63 | ULONG tlen = strlen(bat);
|
---|
64 | IPT iptOffset = 0L;
|
---|
65 |
|
---|
66 | WinSendMsg(hwndMLE,MLM_SETIMPORTEXPORT,
|
---|
67 | MPFROMP(bat),
|
---|
68 | MPFROMLONG(12287L));
|
---|
69 | WinSendMsg(hwndMLE,MLM_IMPORT,MPFROMP(&iptOffset),MPFROMP(tlen));
|
---|
70 | DosFreeMem(bat);
|
---|
71 | bat = NULL;
|
---|
72 | }
|
---|
73 | break;
|
---|
74 |
|
---|
75 | case WM_COMMAND:
|
---|
76 | switch(SHORT1FROMMP(mp1)) {
|
---|
77 | case DID_OK:
|
---|
78 | path = (CHAR *)WinQueryWindowPtr(hwnd,0);
|
---|
79 | {
|
---|
80 | CHAR s[CCHMAXPATH + 1];
|
---|
81 | FILE *fp;
|
---|
82 | IPT iptOffset = 0L;
|
---|
83 | LONG len,tlen,mem;
|
---|
84 | CHAR *rexx = "";
|
---|
85 |
|
---|
86 | mem = MLEgetlen(hwndMLE);
|
---|
87 | if(mem) {
|
---|
88 | if(DosAllocMem((PVOID)&bat,mem,
|
---|
89 | PAG_COMMIT | PAG_READ | PAG_WRITE) ||
|
---|
90 | !bat) {
|
---|
91 | DosBeep(50,100);
|
---|
92 | WinDismissDlg(hwnd,0);
|
---|
93 | break;
|
---|
94 | }
|
---|
95 | tlen = (LONG)WinSendMsg(hwndMLE,MLM_QUERYTEXTLENGTH,MPVOID,MPVOID);
|
---|
96 | if(tlen) {
|
---|
97 | WinSendMsg(hwndMLE,MLM_SETIMPORTEXPORT,
|
---|
98 | MPFROMP(bat),
|
---|
99 | MPFROMLONG(mem));
|
---|
100 | len = (LONG)WinSendMsg(hwndMLE,MLM_EXPORT,
|
---|
101 | MPFROMP(&iptOffset),
|
---|
102 | MPFROMP(&tlen));
|
---|
103 | bat[len] = 0;
|
---|
104 | lstrip(bat);
|
---|
105 | while(strlen(bat) && bat[strlen(bat) - 1] == '\n' ||
|
---|
106 | bat[strlen(bat) - 1] == ' ') {
|
---|
107 | stripcr(bat);
|
---|
108 | rstrip(bat);
|
---|
109 | stripcr(bat);
|
---|
110 | rstrip(bat);
|
---|
111 | }
|
---|
112 | if(*bat) {
|
---|
113 | sprintf(s,"%s%sFMTMP%d.CMD",path,
|
---|
114 | (path[strlen(path) - 1] == '\\') ? "" : "\\",
|
---|
115 | batches++);
|
---|
116 | fp = fopen(s,"w");
|
---|
117 | if(fp) {
|
---|
118 | if(!strncmp(bat,"/*",2)) {
|
---|
119 | rexx = "'";
|
---|
120 | fprintf(fp,
|
---|
121 | "%s\n",
|
---|
122 | GetPString(IDS_REXXCOMMENT));
|
---|
123 | }
|
---|
124 | fprintf(fp,"%s%c:%s\n",rexx,toupper(*path),rexx);
|
---|
125 | fprintf(fp,"%sCD \"%s%s\"%s\n",rexx,path,
|
---|
126 | (strlen(path) < 3) ? "\\" : "",rexx);
|
---|
127 | fprintf(fp,"%s",bat);
|
---|
128 | fprintf(fp,"\n%sDEL \"%s\"%s\n",rexx,s,rexx);
|
---|
129 | fclose(fp);
|
---|
130 | runemf2(WINDOWED | SEPARATE,
|
---|
131 | hwnd,
|
---|
132 | path,
|
---|
133 | NULL,
|
---|
134 | "%s /C \"%s\"",
|
---|
135 | GetCmdSpec(FALSE),
|
---|
136 | s);
|
---|
137 | }
|
---|
138 | else
|
---|
139 | DosBeep(500,100);
|
---|
140 | }
|
---|
141 | else
|
---|
142 | DosBeep(50,100);
|
---|
143 | }
|
---|
144 | else
|
---|
145 | DosBeep(50,100);
|
---|
146 | }
|
---|
147 | }
|
---|
148 | WinDismissDlg(hwnd,0);
|
---|
149 | break;
|
---|
150 |
|
---|
151 | case DID_CANCEL:
|
---|
152 | WinDismissDlg(hwnd,0);
|
---|
153 | break;
|
---|
154 |
|
---|
155 | case IDM_HELP:
|
---|
156 | path = WinQueryWindowPtr(hwnd,0);
|
---|
157 | temp = saymsg(MB_YESNOCANCEL,
|
---|
158 | hwnd,
|
---|
159 | GetPString(IDS_INSTANTHELPTITLETEXT),
|
---|
160 | GetPString(IDS_INSTANTHELPTEXT),
|
---|
161 | path,(strlen(path) < 3) ? "\\" : "",path,
|
---|
162 | (path[strlen(path) - 1] == '\\') ? "" : "\\",
|
---|
163 | batches);
|
---|
164 | if(temp == MBID_YES)
|
---|
165 | runemf2(WINDOWED | INVISIBLE | BACKGROUND,
|
---|
166 | hwnd,
|
---|
167 | NULL,
|
---|
168 | NULL,
|
---|
169 | "%s /C HELP BATCH",
|
---|
170 | GetCmdSpec(FALSE));
|
---|
171 | else if(temp == MBID_CANCEL)
|
---|
172 | WinDismissDlg(hwnd,0);
|
---|
173 | break;
|
---|
174 | }
|
---|
175 | return 0;
|
---|
176 |
|
---|
177 | case WM_CLOSE:
|
---|
178 | case WM_DESTROY:
|
---|
179 | myhwnd = (HWND)0;
|
---|
180 | break;
|
---|
181 | }
|
---|
182 | return WinDefDlgProc(hwnd,msg,mp1,mp2);
|
---|
183 | }
|
---|
184 |
|
---|