Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/ttpmacro/ttmdlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10617 - (hide annotations) (download) (as text)
Fri Mar 3 15:15:04 2023 UTC (13 months, 1 week ago) by zmatsuo
File MIME type: text/x-c++src
File size: 8127 byte(s)
lngファイル名変数を ANSI版から Unicode 版へ切り替え

- get_lang_msgW() -> GetI18nStrWW()
- SetDlgTexts() -> SetDlgTextsW()
- SetWinMenu() を SetWinMenuW() に置き換え
  - ttpcmn/ttcmn.c, def
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3 nmaya 9048 * (C) 2006- TeraTerm Project
4 doda 6806 * All rights reserved.
5     *
6 doda 6841 * Redistribution and use in source and binary forms, with or without
7     * modification, are permitted provided that the following conditions
8     * are met:
9 doda 6806 *
10 doda 6841 * 1. Redistributions of source code must retain the above copyright
11     * notice, this list of conditions and the following disclaimer.
12     * 2. Redistributions in binary form must reproduce the above copyright
13     * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the distribution.
15     * 3. The name of the author may not be used to endorse or promote products
16     * derived from this software without specific prior written permission.
17 doda 6806 *
18 doda 6841 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 doda 6806 */
29 maya 3227
30     /* TTMACRO.EXE, dialog boxes */
31    
32 zmatsuo 7537 #include <windows.h>
33     #include <direct.h>
34     #include <commdlg.h>
35 zmatsuo 8391 #if !defined(_CRTDBG_MAP_ALLOC)
36     #define _CRTDBG_MAP_ALLOC
37     #endif
38     #include <stdlib.h>
39 zmatsuo 7537 #include <crtdbg.h>
40     #include <assert.h>
41    
42 maya 3227 #include "teraterm.h"
43     #include "ttm_res.h"
44     #include "tttypes.h"
45     #include "ttlib.h"
46 doda 6430 #include "ttmdef.h"
47 maya 3227 #include "errdlg.h"
48     #include "inpdlg.h"
49     #include "msgdlg.h"
50     #include "statdlg.h"
51 yutakapon 5144 #include "ListDlg.h"
52 maya 3227 #include "ttmlib.h"
53 zmatsuo 8682 #include "ttmdlg.h"
54 zmatsuo 7546 #include "ttmacro.h"
55    
56 zmatsuo 7537 #include "ttmdlg.h"
57 maya 3227
58 zmatsuo 9306 wchar_t *HomeDirW;
59 zmatsuo 9435 wchar_t FileName[MAX_PATH];
60     wchar_t TopicName[11];
61     wchar_t ShortName[MAX_PATH];
62     wchar_t **Params = NULL;
63 doda 6434 int ParamCnt;
64     int ParamsSize;
65 maya 3227 BOOL SleepFlag;
66    
67 zmatsuo 8354 // (x,y) = (CW_USEDEFAULT, CW_USEDEFAULT)�������Z���^�[���\��
68     static int DlgPosX = CW_USEDEFAULT;
69     static int DlgPosY = CW_USEDEFAULT;
70 maya 3227
71 zmatsuo 7537 static CStatDlg *StatDlg = NULL;
72 maya 3227
73     void ParseParam(PBOOL IOption, PBOOL VOption)
74     {
75 zmatsuo 9435 wchar_t *Param, **ptmp;
76     wchar_t Temp[MaxStrLen];
77     wchar_t *start, *cur, *next;
78 maya 3227
79 zmatsuo 7674 // go home directory
80 zmatsuo 10151 SetCurrentDirectoryW(HomeDirW);
81 maya 3227
82     // Get command line parameters
83     FileName[0] = 0;
84     TopicName[0] = 0;
85     SleepFlag = FALSE;
86     *IOption = FALSE;
87     *VOption = FALSE;
88 zmatsuo 9435 Param = GetCommandLineW();
89 doda 6140
90 doda 6434 ParamsSize = 50;
91 zmatsuo 9435 Params = (wchar_t **)malloc(sizeof(wchar_t *) * ParamsSize);
92 doda 6434 if (Params) {
93 zmatsuo 9435 Params[0] = _wcsdup(Param);
94 doda 6434 Params[1] = NULL;
95     }
96    
97 maya 3227 // the first term shuld be executable filename of TTMACRO
98 zmatsuo 9435 start = GetParam(Temp, _countof(Temp), Param);
99 doda 6423 ParamCnt = 0;
100 maya 3227
101 doda 6423 for (cur = start; next = GetParam(Temp, sizeof(Temp), cur); cur = next) {
102 zmatsuo 9435 DequoteParam(Temp, _countof(Temp), Temp);
103 doda 6423 if (ParamCnt == 0) {
104 zmatsuo 9435 if (_wcsnicmp(Temp,L"/D=",3)==0) { // DDE option
105     wcsncpy_s(TopicName, _countof(TopicName), &Temp[3], _TRUNCATE);
106 doda 6423 continue;
107     }
108 zmatsuo 9435 else if (_wcsicmp(Temp, L"/I")==0) {
109 doda 6423 *IOption = TRUE;
110     continue;
111     }
112 zmatsuo 9435 else if (_wcsicmp(Temp, L"/S")==0) {
113 doda 6423 SleepFlag = TRUE;
114     continue;
115     }
116 zmatsuo 9435 else if (_wcsicmp(Temp, L"/V")==0) {
117 doda 6423 *VOption = TRUE;
118     continue;
119     }
120 maya 3227 }
121 doda 6423
122 doda 6434 if (++ParamCnt == 1) {
123 zmatsuo 9435 wcsncpy_s(FileName, _countof(FileName), Temp, _TRUNCATE);
124 doda 6434 if (Params == NULL) {
125     break;
126     }
127 maya 3227 }
128 doda 6434 else {
129     if (ParamsSize <= ParamCnt) {
130     ParamsSize += 10;
131 zmatsuo 9435 ptmp = (wchar_t **)realloc(Params, sizeof(wchar_t*) * ParamsSize);
132 doda 6434 if (ptmp == NULL) {
133     ParamCnt--;
134     break;
135     }
136     Params = ptmp;
137     }
138 zmatsuo 9435 Params[ParamCnt] = _wcsdup(Temp);
139 doda 6434 }
140 maya 3227 }
141    
142     if (FileName[0]=='*') {
143     FileName[0] = 0;
144     }
145     else if (FileName[0]!=0) {
146 zmatsuo 9435 size_t dirlen, fnpos;
147     if (GetFileNamePosW(FileName, &dirlen, &fnpos)) {
148     FitFileNameW(&FileName[fnpos], _countof(FileName) - fnpos, L".TTL");
149     wcsncpy_s(ShortName, _countof(ShortName), &FileName[fnpos], _TRUNCATE);
150 doda 6424 if (dirlen==0) {
151 zmatsuo 9435 wcsncpy_s(FileName, _countof(FileName), HomeDirW, _TRUNCATE);
152     AppendSlashW(FileName, _countof(FileName));
153     wcsncat_s(FileName, _countof(FileName), ShortName, _TRUNCATE);
154 maya 3227 }
155 doda 6434
156     if (Params) {
157 zmatsuo 9435 Params[1] = _wcsdup(ShortName);
158 doda 6434 }
159 maya 3227 }
160     else {
161     FileName[0] = 0;
162     }
163     }
164     }
165    
166     BOOL GetFileName(HWND HWin)
167     {
168 zmatsuo 10617 wchar_t *FNFilter;
169     wchar_t *title;
170 zmatsuo 9435 OPENFILENAMEW FNameRec;
171 maya 3227
172     if (FileName[0]!=0) {
173     return FALSE;
174     }
175    
176     memset(&FNameRec, 0, sizeof(OPENFILENAME));
177 zmatsuo 10617 GetI18nStrWW("Tera Term", "FILEDLG_OPEN_MACRO_FILTER", L"Macro files (*.ttl)\\0*.ttl\\0\\0", UILanguageFileW, &FNFilter);
178     GetI18nStrWW("Tera Term", "FILEDLG_OPEN_MACRO_TITLE", L"MACRO: Open macro", UILanguageFileW, &title);
179 maya 3227
180     // sizeof(OPENFILENAME) ���� Windows98/NT ���I���������������� (2006.8.14 maya)
181 zmatsuo 9435 FNameRec.lStructSize = get_OPENFILENAME_SIZEW();
182 maya 7775 FNameRec.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
183     FNameRec.hwndOwner = HWin;
184     FNameRec.lpstrFilter = FNFilter;
185     FNameRec.nFilterIndex = 1;
186     FNameRec.lpstrFile = FileName;
187     FNameRec.nMaxFile = sizeof(FileName);
188 maya 3227 // ���O���������� .ttl �t�@�C�����p�X���L���������������A�����f�B���N�g�����������������B
189     // (2008.4.7 yutaka)
190     #if 0
191 zmatsuo 10151 FNameRec.lpstrInitialDir = HomeDirW;
192 maya 3227 #endif
193     FNameRec.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
194 zmatsuo 9435 FNameRec.lpstrDefExt = L"TTL";
195 zmatsuo 10617 FNameRec.lpstrTitle = title;
196 zmatsuo 9435 if (GetOpenFileNameW(&FNameRec)) {
197     wcsncpy_s(ShortName, _countof(ShortName), &(FileName[FNameRec.nFileOffset]), _TRUNCATE);
198 maya 3227 }
199     else {
200     FileName[0] = 0;
201     }
202 zmatsuo 10617 free(FNFilter);
203     free(title);
204 maya 3227
205     if (FileName[0]==0) {
206     ShortName[0] = 0;
207     return FALSE;
208     }
209     else {
210     return TRUE;
211     }
212     }
213    
214     void SetDlgPos(int x, int y)
215     {
216     DlgPosX = x;
217     DlgPosY = y;
218     if (StatDlg!=NULL) { // update status box position
219 maya 4032 StatDlg->Update(NULL,NULL,DlgPosX,DlgPosY);
220 maya 3227 }
221     }
222    
223 zmatsuo 8687 void OpenInpDlg(wchar_t *Buff, const wchar_t *Text, const wchar_t *Caption,
224     const wchar_t *Default, BOOL Paswd)
225 maya 3227 {
226 zmatsuo 8352 HINSTANCE hInst = GetInstance();
227     HWND hWndParent = GetHWND();
228 maya 4032 CInpDlg InpDlg(Buff,Text,Caption,Default,Paswd,DlgPosX,DlgPosY);
229 zmatsuo 8352 InpDlg.DoModal(hInst, hWndParent);
230 maya 3227 }
231    
232 zmatsuo 8682 int OpenErrDlg(const char *Msg, const char *Line, int lineno, int start, int end, const char *FileName)
233 maya 3227 {
234 zmatsuo 8352 HINSTANCE hInst = GetInstance();
235     HWND hWndParent = GetHWND();
236 yutakapon 5387 CErrDlg ErrDlg(Msg,Line,DlgPosX,DlgPosY, lineno, start, end, FileName);
237 zmatsuo 8352 return ErrDlg.DoModal(hInst, hWndParent);
238 maya 3227 }
239    
240 zmatsuo 8686 int OpenMsgDlg(const wchar_t *Text, const wchar_t *Caption, BOOL YesNo)
241 maya 3227 {
242 zmatsuo 8352 HINSTANCE hInst = GetInstance();
243     HWND hWndParent = GetHWND();
244 maya 4032 CMsgDlg MsgDlg(Text,Caption,YesNo,DlgPosX,DlgPosY);
245 zmatsuo 8352 return MsgDlg.DoModal(hInst, hWndParent);
246 maya 3227 }
247    
248 zmatsuo 8692 void OpenStatDlg(const wchar_t *Text, const wchar_t *Caption)
249 maya 3227 {
250     if (StatDlg==NULL) {
251 zmatsuo 8352 HINSTANCE hInst = GetInstance();
252 maya 3227 StatDlg = new CStatDlg();
253 zmatsuo 8352 StatDlg->Create(hInst,Text,Caption,DlgPosX,DlgPosY);
254 maya 3227 }
255     else {// if status box already exists,
256     // update text and caption only.
257 maya 4032 StatDlg->Update(Text,Caption,32767,0);
258 maya 3227 }
259     }
260    
261     void CloseStatDlg()
262     {
263     if (StatDlg==NULL) {
264     return;
265     }
266 zmatsuo 7537 assert(_CrtCheckMemory());
267 maya 3227 StatDlg->DestroyWindow();
268 zmatsuo 7537 assert(_CrtCheckMemory());
269 maya 3227 StatDlg = NULL;
270     }
271 yutakapon 5144
272 maya 5212 void BringupStatDlg()
273     {
274     if (StatDlg==NULL) {
275     return;
276     }
277     StatDlg->Bringup();
278     }
279    
280 zmatsuo 7537 /**
281     * @retval 0���� �I������
282     * @retval -1 cancel�{�^��
283     * @retval -2 close�{�^��
284     */
285 zmatsuo 8686 int OpenListDlg(const wchar_t *Text, const wchar_t *Caption, wchar_t **Lists, int Selected)
286 yutakapon 5144 {
287 zmatsuo 8352 HINSTANCE hInst = GetInstance();
288     HWND hWndParent = GetHWND();
289 doda 6074 CListDlg ListDlg(Text, Caption, Lists, Selected, DlgPosX, DlgPosY);
290 zmatsuo 8352 INT_PTR r = ListDlg.DoModal(hInst, hWndParent);
291 zmatsuo 7537 if (r == IDOK) {
292     return ListDlg.m_SelectItem;
293 yutakapon 5144 }
294 zmatsuo 7537 return r == IDCANCEL ? -1 : -2;
295 yutakapon 5144 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26