OSDN Git Service

Fix bugs of automatic detection for Kanji code of filenames.
[ffftp/ffftp.git] / toolmenu.c
1 /*=============================================================================\r
2 *\r
3 *                                                               ツールバーとメニュー\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 #define  STRICT\r
31 #include <windows.h>\r
32 #include <stdio.h>\r
33 #include <stdlib.h>\r
34 #include <string.h>\r
35 #include <mbstring.h>\r
36 #include <malloc.h>\r
37 #include <windowsx.h>\r
38 #include <commctrl.h>\r
39 #include <stdarg.h>\r
40 #include <winsock.h>\r
41 \r
42 #include "common.h"\r
43 #include "resource.h"\r
44 \r
45 \r
46 /*===== プロトタイプ =====*/\r
47 \r
48 static void AddOpenMenu(HMENU hMenu, UINT Flg);\r
49 static LRESULT CALLBACK HistEditBoxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
50 \r
51 /* 2007/09/21 sunasunamix  ここから *********************/\r
52 static LRESULT CALLBACK CountermeasureTbarMainProc(HWND hWnd,UINT uMessage,WPARAM wParam,LPARAM lParam);\r
53 static LRESULT CALLBACK CountermeasureTbarLocalProc(HWND hWnd,UINT uMessage,WPARAM wParam,LPARAM lParam);\r
54 static LRESULT CALLBACK CountermeasureTbarRemoteProc(HWND hWnd,UINT uMessage,WPARAM wParam,LPARAM lParam);\r
55 /********************************************* ここまで */\r
56 \r
57 \r
58 /*===== 外部参照 =====*/\r
59 \r
60 extern int SepaWidth;\r
61 extern int RemoteWidth;\r
62 \r
63 extern int CancelFlg;\r
64 \r
65 /* 設定値 */\r
66 extern int DotFile;\r
67 extern char AsciiExt[ASCII_EXT_LEN+1];\r
68 extern int TransMode;\r
69 extern int ListType;\r
70 extern int LocalWidth;\r
71 extern char ViewerName[VIEWERS][FMAX_PATH+1];\r
72 extern int TransMode;\r
73 extern int SortSave;\r
74 \r
75 /*===== ローカルなワーク =====*/\r
76 \r
77 static HWND hWndTbarMain = NULL;\r
78 static HWND hWndTbarLocal = NULL;\r
79 static HWND hWndTbarRemote = NULL;\r
80 static HWND hWndDirLocal = NULL;\r
81 static HWND hWndDirRemote = NULL;\r
82 static HWND hWndDirLocalEdit = NULL;\r
83 static HWND hWndDirRemoteEdit = NULL;\r
84 \r
85 static WNDPROC HistEditBoxProcPtr;\r
86 \r
87 static HFONT DlgFont = NULL;\r
88 \r
89 static int TmpTransMode;\r
90 static int TmpHostKanjiCode;\r
91 static int TmpHostKanaCnv;\r
92 \r
93 // TODO: ローカルの漢字コードをShift_JIS以外にも対応\r
94 static int TmpLocalKanjiCode;\r
95 \r
96 static int TmpLocalFileSort;\r
97 static int TmpLocalDirSort;\r
98 static int TmpRemoteFileSort;\r
99 static int TmpRemoteDirSort;\r
100 \r
101 static int SyncMove = NO;\r
102 \r
103 static int HideUI = NO;\r
104 \r
105 \r
106 /* 2007/09/21 sunasunamix  ここから *********************/\r
107 static WNDPROC pOldTbarMainProc   = NULL;\r
108 static WNDPROC pOldTbarLocalProc  = NULL;\r
109 static WNDPROC pOldTbarRemoteProc = NULL;\r
110 /********************************************* ここまで */\r
111 \r
112 \r
113 /* 以前、コンボボックスにカレントフォルダを憶えさせていた流れで */\r
114 /* このファイルでカレントフォルダを憶えさせる */\r
115 static char LocalCurDir[FMAX_PATH+1];\r
116 static char RemoteCurDir[FMAX_PATH+1];\r
117 \r
118 \r
119 /* メインのツールバー */\r
120 static TBBUTTON TbarDataMain[] = {\r
121         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
122         { 0,  MENU_CONNECT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
123         { 16, MENU_QUICK, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
124         { 1,  MENU_DISCONNECT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
125         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
126         { 2,  MENU_DOWNLOAD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
127         { 3,  MENU_UPLOAD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
128         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
129         { 24, MENU_MIRROR_UPLOAD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
130         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
131         { 4,  MENU_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
132         { 5,  MENU_RENAME, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
133         { 6,  MENU_MKDIR, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
134         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
135         { 7,  MENU_TEXT, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
136         { 8,  MENU_BINARY, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
137         { 17, MENU_AUTO, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
138         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
139         { 27, MENU_L_KNJ_SJIS, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
140         { 20, MENU_L_KNJ_EUC, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
141         { 21, MENU_L_KNJ_JIS, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
142         { 28, MENU_L_KNJ_UTF8N, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
143         { 29, MENU_L_KNJ_UTF8BOM, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
144         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
145         { 27, MENU_KNJ_SJIS, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
146         { 20, MENU_KNJ_EUC, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
147         { 21, MENU_KNJ_JIS, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
148         { 28, MENU_KNJ_UTF8N, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
149         { 29, MENU_KNJ_UTF8BOM, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
150         { 22, MENU_KNJ_NONE, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
151         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
152         { 23, MENU_KANACNV, TBSTATE_ENABLED, TBSTYLE_CHECK, 0, 0 },\r
153         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
154         { 15, MENU_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
155         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
156         { 18, MENU_LIST, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
157         { 19, MENU_REPORT, TBSTATE_ENABLED, TBSTYLE_CHECKGROUP, 0, 0 },\r
158         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
159         { 25, MENU_SYNC, TBSTATE_ENABLED, TBSTYLE_CHECK, 0, 0 },\r
160         { 0,  0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
161         { 26, MENU_ABORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 }\r
162 };\r
163 \r
164 /* ローカル側のツールバー */\r
165 static TBBUTTON TbarDataLocal[] = {\r
166         { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
167         { 0, MENU_LOCAL_UPDIR, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
168         { 1, MENU_LOCAL_CHDIR, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
169         { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 }\r
170 };\r
171 \r
172 /* ホスト側のツールバー */\r
173 static TBBUTTON TbarDataRemote[] = {\r
174         { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 },\r
175         { 0, MENU_REMOTE_UPDIR, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
176         { 1, MENU_REMOTE_CHDIR, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 },\r
177         { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0 }\r
178 };\r
179 \r
180 /* 全ボタン/メニュー項目 */\r
181 static const int HideMenus[] = {\r
182         MENU_CONNECT,           MENU_QUICK,                     MENU_DISCONNECT,\r
183         MENU_SET_CONNECT,       MENU_IMPORT_WS,         MENU_EXIT,\r
184         MENU_DOWNLOAD,          MENU_UPLOAD,            MENU_DOWNLOAD_AS,       MENU_MIRROR_UPLOAD,\r
185         MENU_UPLOAD_AS,         MENU_DOWNLOAD_NAME,     MENU_MIRROR_UPLOAD,\r
186         MENU_FILESIZE,          MENU_DELETE,            MENU_RENAME,\r
187         MENU_CHMOD,                     MENU_MKDIR,                     MENU_SOMECMD,\r
188         MENU_SYNC,\r
189         MENU_BMARK_ADD,         MENU_BMARK_ADD_LOCAL, MENU_BMARK_ADD_BOTH,\r
190         MENU_BMARK_EDIT,\r
191         MENU_FILTER,            MENU_FIND,                      MENU_FINDNEXT,          MENU_SELECT,\r
192         MENU_SELECT_ALL,        MENU_LIST,                      MENU_REPORT,\r
193         MENU_SORT,                      MENU_DOTFILE,\r
194         MENU_DIRINFO,           MENU_TASKINFO,          MENU_REFRESH,\r
195         MENU_OPTION,\r
196         MENU_OTPCALC,\r
197         MENU_HELP,                      MENU_HELP_TROUBLE,      MENU_ABOUT,\r
198         MENU_REGINIT,\r
199         MENU_TEXT,                      MENU_BINARY,            MENU_AUTO,\r
200         MENU_KNJ_SJIS,          MENU_KNJ_EUC,           MENU_KNJ_JIS,           MENU_KNJ_UTF8N,         MENU_KNJ_UTF8BOM,       MENU_KNJ_NONE,\r
201         MENU_L_KNJ_SJIS,        MENU_L_KNJ_EUC,         MENU_L_KNJ_JIS,         MENU_L_KNJ_UTF8N,       MENU_L_KNJ_UTF8BOM,\r
202         MENU_KANACNV,\r
203         MENU_LOCAL_UPDIR,       MENU_LOCAL_CHDIR,\r
204         MENU_REMOTE_UPDIR,      MENU_REMOTE_CHDIR,\r
205         MENU_HIST_1,            MENU_HIST_2,            MENU_HIST_3,            MENU_HIST_4,\r
206         MENU_HIST_5,            MENU_HIST_6,            MENU_HIST_7,            MENU_HIST_8,\r
207         MENU_HIST_9,            MENU_HIST_10,           MENU_HIST_11,           MENU_HIST_12,\r
208         MENU_HIST_13,           MENU_HIST_14,           MENU_HIST_15,           MENU_HIST_16,\r
209         MENU_HIST_17,           MENU_HIST_18,           MENU_HIST_19,           MENU_HIST_20\r
210 };\r
211 \r
212 \r
213 \r
214 /*----- ツールバーを作成する --------------------------------------------------\r
215 *\r
216 *       Parameter\r
217 *               HWND hWnd : 親ウインドウのウインドウハンドル\r
218 *               HINSTANCE hInst : インスタンスハンドル\r
219 *\r
220 *       Return Value\r
221 *               int ステータス\r
222 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
223 *----------------------------------------------------------------------------*/\r
224 \r
225 int MakeToolBarWindow(HWND hWnd, HINSTANCE hInst)\r
226 {\r
227         int Sts;\r
228         RECT Rect1;\r
229         char Tmp[FMAX_PATH+1];\r
230         char *Pos;\r
231         int Tmp2;\r
232         DWORD NoDrives;\r
233 \r
234         /*===== メインのツールバー =====*/\r
235 \r
236         hWndTbarMain = CreateToolbarEx(\r
237                                 hWnd,\r
238                                 WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | CCS_TOP | TBSTYLE_FLAT,\r
239                                 1,\r
240                                 27,\r
241                                 hInst,\r
242                                 main_toolbar_bmp,\r
243                                 TbarDataMain,\r
244                                 sizeof(TbarDataMain)/sizeof(TBBUTTON),\r
245                                 16,16,\r
246                                 16,16,\r
247                                 sizeof(TBBUTTON));\r
248 \r
249         if(hWndTbarMain != NULL)\r
250         {\r
251                 /* 2007/09/21 sunasunamix  ここから *********************/\r
252                 pOldTbarMainProc = (WNDPROC)SetWindowLong(hWndTbarMain, GWL_WNDPROC, (DWORD)CountermeasureTbarMainProc);\r
253                 /********************************************* ここまで */\r
254 \r
255                 GetClientRect(hWnd, &Rect1);\r
256                 MoveWindow(hWndTbarMain, 0, 0, Rect1.right, TOOLWIN_HEIGHT, FALSE);\r
257         }\r
258 \r
259         /*===== ローカルのツールバー =====*/\r
260 \r
261         hWndTbarLocal = CreateToolbarEx(\r
262                                 hWnd,\r
263                                 WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | CCS_NORESIZE | TBSTYLE_FLAT,\r
264                                 2,\r
265                                 2,\r
266                                 hInst,\r
267                                 remote_toolbar_bmp,\r
268                                 TbarDataLocal,\r
269                                 sizeof(TbarDataLocal)/sizeof(TBBUTTON),\r
270                                 16,16,\r
271                                 16,16,\r
272                                 sizeof(TBBUTTON));\r
273 \r
274         if(hWndTbarLocal != NULL)\r
275         {\r
276                 /* 2007/09/21 sunasunamix  ここから *********************/\r
277                 pOldTbarLocalProc = (WNDPROC)SetWindowLong(hWndTbarLocal, GWL_WNDPROC, (DWORD)CountermeasureTbarLocalProc);\r
278                 /********************************************* ここまで */\r
279 \r
280                 MoveWindow(hWndTbarLocal, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, FALSE);\r
281 \r
282                 /*===== ローカルのディレクトリ名ウインドウ =====*/\r
283 \r
284                 SendMessage(hWndTbarLocal, TB_GETITEMRECT, 3, (LPARAM)&Rect1);\r
285 #ifndef ENGLISH\r
286                 DlgFont = CreateFont(Rect1.bottom-Rect1.top-8, 0, 0, 0, 0, FALSE,FALSE,FALSE,SHIFTJIS_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,MSGJPN254);\r
287 #else\r
288                 DlgFont = CreateFont(Rect1.bottom-Rect1.top-8, 0, 0, 0, 0, FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,MSGJPN254);\r
289 #endif\r
290 \r
291                 hWndDirLocal = CreateWindowEx(WS_EX_CLIENTEDGE,\r
292                                         "COMBOBOX", "",\r
293                                         WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | CBS_DROPDOWN | CBS_SORT | CBS_AUTOHSCROLL,\r
294                                         Rect1.right, Rect1.top, LocalWidth - Rect1.right, 200,\r
295                                         hWndTbarLocal, (HMENU)COMBO_LOCAL, hInst, NULL);\r
296 \r
297                 if(hWndDirLocal != NULL)\r
298                 {\r
299                         /* エディットコントロールを探す */\r
300                         hWndDirLocalEdit = GetWindow(hWndDirLocal, GW_CHILD);\r
301                         if(hWndDirLocalEdit != NULL)\r
302                                 HistEditBoxProcPtr = (WNDPROC)SetWindowLong(hWndDirLocalEdit, GWL_WNDPROC, (LONG)HistEditBoxWndProc);\r
303 \r
304                         SendMessage(hWndDirLocal, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE, 0));\r
305                         SendMessage(hWndDirLocal, CB_LIMITTEXT, FMAX_PATH, 0);\r
306 \r
307                         /* ドライブ名をセットしておく */\r
308                         GetLogicalDriveStrings(FMAX_PATH, Tmp);\r
309                         NoDrives = LoadHideDriveListRegistory();\r
310                         Pos = Tmp;\r
311                         while(*Pos != NUL)\r
312                         {\r
313                                 Tmp2 = toupper(*Pos) - 'A';\r
314                                 if((NoDrives & (0x00000001 << Tmp2)) == 0)\r
315                                         SetLocalDirHist(Pos);\r
316                                 Pos = strchr(Pos, NUL) + 1;\r
317                         }\r
318                         SendMessage(hWndDirLocal, CB_SETCURSEL, 0, 0);\r
319                 }\r
320         }\r
321 \r
322         /*===== ホストのツールバー =====*/\r
323 \r
324         hWndTbarRemote = CreateToolbarEx(\r
325                                 hWnd,\r
326                                 WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | CCS_NORESIZE | TBSTYLE_FLAT,\r
327                                 3,\r
328                                 2,\r
329                                 hInst,\r
330                                 remote_toolbar_bmp,\r
331                                 TbarDataRemote,\r
332                                 sizeof(TbarDataRemote)/sizeof(TBBUTTON),\r
333                                 16,16,\r
334                                 16,16,\r
335                                 sizeof(TBBUTTON));\r
336 \r
337         if(hWndTbarRemote != NULL)\r
338         {\r
339                 /* 2007/09/21 sunasunamix  ここから *********************/\r
340                 pOldTbarRemoteProc = (WNDPROC)SetWindowLong(hWndTbarRemote, GWL_WNDPROC, (DWORD)CountermeasureTbarRemoteProc);\r
341                 /********************************************* ここまで */\r
342 \r
343                 MoveWindow(hWndTbarRemote, LocalWidth + SepaWidth, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, FALSE);\r
344 \r
345                 /*===== ホストのディレクトリ名ウインドウ =====*/\r
346 \r
347                 SendMessage(hWndTbarRemote, TB_GETITEMRECT, 3, (LPARAM)&Rect1);\r
348                 hWndDirRemote = CreateWindowEx(WS_EX_CLIENTEDGE,\r
349                                         "COMBOBOX", "",\r
350                                         WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL,\r
351                                         Rect1.right, Rect1.top, RemoteWidth - Rect1.right, 200,\r
352                                         hWndTbarRemote, (HMENU)COMBO_REMOTE, hInst, NULL);\r
353 \r
354                 if(hWndDirRemote != NULL)\r
355                 {\r
356                         /* エディットコントロールを探す */\r
357                         hWndDirRemoteEdit = GetWindow(hWndDirRemote, GW_CHILD);\r
358                         if(hWndDirRemoteEdit != NULL)\r
359                                 HistEditBoxProcPtr = (WNDPROC)SetWindowLong(hWndDirRemoteEdit, GWL_WNDPROC, (LONG)HistEditBoxWndProc);\r
360 \r
361                         SendMessage(hWndDirRemote, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE, 0));\r
362                         SendMessage(hWndDirRemote, CB_LIMITTEXT, FMAX_PATH, 0);\r
363                         SendMessage(hWndDirRemote, CB_SETCURSEL, 0, 0);\r
364                 }\r
365         }\r
366 \r
367         Sts = FFFTP_SUCCESS;\r
368         if((hWndTbarMain == NULL) ||\r
369            (hWndTbarLocal == NULL) ||\r
370            (hWndTbarRemote == NULL) ||\r
371            (hWndDirLocal == NULL) ||\r
372            (hWndDirRemote == NULL))\r
373         {\r
374                 Sts = FFFTP_FAIL;\r
375         }\r
376         return(Sts);\r
377 }\r
378 \r
379 \r
380 \r
381 \r
382 \r
383 static LRESULT CALLBACK HistEditBoxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
384 {\r
385         char Tmp[FMAX_PATH+1];\r
386 \r
387         switch (message)\r
388         {\r
389                 case WM_CHAR :\r
390                         if(wParam == 0x0D)              /* リターンキーが押された */\r
391                         {\r
392                                 if(hWnd == hWndDirLocalEdit)\r
393                                 {\r
394                                         SendMessage(hWndDirLocalEdit, WM_GETTEXT, FMAX_PATH+1, (LPARAM)Tmp);\r
395                                         DoLocalCWD(Tmp);\r
396                                         GetLocalDirForWnd();\r
397                                 }\r
398                                 else\r
399                                 {\r
400                                         // 同時接続対応\r
401                                         CancelFlg = NO;\r
402                                         SendMessage(hWndDirRemoteEdit, WM_GETTEXT, FMAX_PATH+1, (LPARAM)Tmp);\r
403                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
404                                         {\r
405                                                 if(DoCWD(Tmp, YES, NO, YES) < FTP_RETRY)\r
406                                                         GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
407                                         }\r
408                                 }\r
409                         }\r
410                         else if(wParam == 0x09)         /* TABキーが押された */\r
411                         {\r
412                                 if(hWnd == hWndDirLocalEdit)\r
413                                 {\r
414                                         SetFocus(GetLocalHwnd());\r
415                                 }\r
416                                 else\r
417                                 {\r
418                                         SetFocus(GetRemoteHwnd());\r
419                                 }\r
420                         }\r
421                         else\r
422                                 return(CallWindowProc(HistEditBoxProcPtr, hWnd, message, wParam, lParam));\r
423                         break;\r
424 \r
425                 default :\r
426                         return(CallWindowProc(HistEditBoxProcPtr, hWnd, message, wParam, lParam));\r
427         }\r
428     return(0L);\r
429 }\r
430 \r
431 \r
432 \r
433 \r
434 /*----- ツールバーを削除 ------------------------------------------------------\r
435 *\r
436 *       Parameter\r
437 *               なし\r
438 *\r
439 *       Return Value\r
440 *               なし\r
441 *----------------------------------------------------------------------------*/\r
442 \r
443 void DeleteToolBarWindow(void)\r
444 {\r
445 //      if(DlgFont != NULL)\r
446 //              DeleteObject(DlgFont);\r
447 \r
448         if(hWndTbarMain != NULL)\r
449                 DestroyWindow(hWndTbarMain);\r
450         if(hWndTbarLocal != NULL)\r
451                 DestroyWindow(hWndTbarLocal);\r
452         if(hWndTbarRemote != NULL)\r
453                 DestroyWindow(hWndTbarRemote);\r
454         if(hWndDirLocal != NULL)\r
455                 DestroyWindow(hWndDirLocal);\r
456         if(hWndDirRemote != NULL)\r
457                 DestroyWindow(hWndDirRemote);\r
458         return;\r
459 }\r
460 \r
461 \r
462 /*----- メインのツールバーのウインドウハンドルを返す --------------------------\r
463 *\r
464 *       Parameter\r
465 *               なし\r
466 *\r
467 *       Return Value\r
468 *               HWND ウインドウハンドル\r
469 *----------------------------------------------------------------------------*/\r
470 \r
471 HWND GetMainTbarWnd(void)\r
472 {\r
473         return(hWndTbarMain);\r
474 }\r
475 \r
476 \r
477 /*----- ローカル側のヒストリウインドウのウインドウハンドルを返す --------------\r
478 *\r
479 *       Parameter\r
480 *               なし\r
481 *\r
482 *       Return Value\r
483 *               HWND ウインドウハンドル\r
484 *----------------------------------------------------------------------------*/\r
485 \r
486 HWND GetLocalHistHwnd(void)\r
487 {\r
488         return(hWndDirLocal);\r
489 }\r
490 \r
491 \r
492 /*----- ホスト側のヒストリウインドウのウインドウハンドルを返す ----------------\r
493 *\r
494 *       Parameter\r
495 *               なし\r
496 *\r
497 *       Return Value\r
498 *               HWND ウインドウハンドル\r
499 *----------------------------------------------------------------------------*/\r
500 \r
501 HWND GetRemoteHistHwnd(void)\r
502 {\r
503         return(hWndDirRemote);\r
504 }\r
505 \r
506 \r
507 /*----- ローカル側のヒストリエディットのウインドウハンドルを返す --------------\r
508 *\r
509 *       Parameter\r
510 *               なし\r
511 *\r
512 *       Return Value\r
513 *               HWND ウインドウハンドル\r
514 *----------------------------------------------------------------------------*/\r
515 \r
516 HWND GetLocalHistEditHwnd(void)\r
517 {\r
518         return(hWndDirLocalEdit);\r
519 }\r
520 \r
521 \r
522 /*----- ホスト側のヒストリエディットのウインドウハンドルを返す ----------------\r
523 *\r
524 *       Parameter\r
525 *               なし\r
526 *\r
527 *       Return Value\r
528 *               HWND ウインドウハンドル\r
529 *----------------------------------------------------------------------------*/\r
530 \r
531 HWND GetRemoteHistEditHwnd(void)\r
532 {\r
533         return(hWndDirRemoteEdit);\r
534 }\r
535 \r
536 \r
537 /*----- ローカル側のツールバーのウインドウハンドルを返す ----------------------\r
538 *\r
539 *       Parameter\r
540 *               なし\r
541 *\r
542 *       Return Value\r
543 *               HWND ウインドウハンドル\r
544 *----------------------------------------------------------------------------*/\r
545 \r
546 HWND GetLocalTbarWnd(void)\r
547 {\r
548         return(hWndTbarLocal);\r
549 }\r
550 \r
551 \r
552 /*----- ホスト側のツールバーのウインドウハンドルを返す ------------------------\r
553 *\r
554 *       Parameter\r
555 *               なし\r
556 *\r
557 *       Return Value\r
558 *               HWND ウインドウハンドル\r
559 *----------------------------------------------------------------------------*/\r
560 \r
561 HWND GetRemoteTbarWnd(void)\r
562 {\r
563         return(hWndTbarRemote);\r
564 }\r
565 \r
566 \r
567 /*----- HideUI の状態を返す ---------------------------------------------------\r
568 *\r
569 *       Parameter\r
570 *               なし\r
571 *\r
572 *       Return Value\r
573 *               int HideUI の状態\r
574 *----------------------------------------------------------------------------*/\r
575 \r
576 int GetHideUI(void)\r
577 {\r
578         return(HideUI);\r
579 }\r
580 \r
581 \r
582 /*----- ツールボタン/メニューのハイド処理 ------------------------------------\r
583 *\r
584 *       Parameter\r
585 *               なし\r
586 *\r
587 *       Return Value\r
588 *               なし\r
589 *----------------------------------------------------------------------------*/\r
590 \r
591 void MakeButtonsFocus(void)\r
592 {\r
593         HWND hWndFocus;\r
594         HWND hWndMain;\r
595         int Count;\r
596         int Win;\r
597 \r
598         if(HideUI == NO)\r
599         {\r
600                 hWndMain = GetMainHwnd();\r
601                 hWndFocus = GetFocus();\r
602                 Win = WIN_LOCAL;\r
603                 if(hWndFocus == GetRemoteHwnd())\r
604                         Win = WIN_REMOTE;\r
605 \r
606                 Count = GetSelectedCount(Win);\r
607 \r
608                 if(AskConnecting() == YES)\r
609                 {\r
610                         EnableMenuItem(GetMenu(hWndMain), MENU_BMARK_ADD, MF_ENABLED);\r
611                         EnableMenuItem(GetMenu(hWndMain), MENU_BMARK_ADD_LOCAL, MF_ENABLED);\r
612                         EnableMenuItem(GetMenu(hWndMain), MENU_BMARK_ADD_BOTH, MF_ENABLED);\r
613                         EnableMenuItem(GetMenu(hWndMain), MENU_BMARK_EDIT, MF_ENABLED);\r
614                         EnableMenuItem(GetMenu(hWndMain), MENU_DIRINFO, MF_ENABLED);\r
615                         EnableMenuItem(GetMenu(hWndMain), MENU_MIRROR_UPLOAD, MF_ENABLED);\r
616                         EnableMenuItem(GetMenu(hWndMain), MENU_MIRROR_DOWNLOAD, MF_ENABLED);\r
617                         EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_NAME, MF_ENABLED);\r
618                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_MIRROR_UPLOAD, MAKELONG(TRUE, 0));\r
619                 }\r
620                 else\r
621                 {\r
622                         EnableMenuItem(GetMenu(hWndMain), MENU_BMARK_ADD, MF_GRAYED);\r
623                         EnableMenuItem(GetMenu(hWndMain), MENU_BMARK_ADD_LOCAL, MF_GRAYED);\r
624                         EnableMenuItem(GetMenu(hWndMain), MENU_BMARK_ADD_BOTH, MF_GRAYED);\r
625                         EnableMenuItem(GetMenu(hWndMain), MENU_BMARK_EDIT, MF_GRAYED);\r
626                         EnableMenuItem(GetMenu(hWndMain), MENU_DIRINFO, MF_GRAYED);\r
627                         EnableMenuItem(GetMenu(hWndMain), MENU_MIRROR_UPLOAD, MF_GRAYED);\r
628                         EnableMenuItem(GetMenu(hWndMain), MENU_MIRROR_DOWNLOAD, MF_GRAYED);\r
629                         EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_NAME, MF_GRAYED);\r
630                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_MIRROR_UPLOAD, MAKELONG(FALSE, 0));\r
631                 }\r
632 \r
633                 if(hWndFocus == GetLocalHwnd())\r
634                 {\r
635                         if((AskConnecting() == YES) && (Count > 0))\r
636                         {\r
637                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_UPLOAD, MAKELONG(TRUE, 0));\r
638                                 EnableMenuItem(GetMenu(hWndMain), MENU_UPLOAD, MF_ENABLED);\r
639                                 EnableMenuItem(GetMenu(hWndMain), MENU_UPLOAD_AS, MF_ENABLED);\r
640                         }\r
641                         else\r
642                         {\r
643                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_UPLOAD, MAKELONG(FALSE, 0));\r
644                                 EnableMenuItem(GetMenu(hWndMain), MENU_UPLOAD, MF_GRAYED);\r
645                                 EnableMenuItem(GetMenu(hWndMain), MENU_UPLOAD_AS, MF_GRAYED);\r
646                         }\r
647                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_DOWNLOAD, MAKELONG(FALSE, 0));\r
648                         EnableMenuItem(GetMenu(hWndMain), MENU_SOMECMD, MF_GRAYED);\r
649                         EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD, MF_GRAYED);\r
650                         EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_AS, MF_GRAYED);\r
651                         EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_AS_FILE, MF_GRAYED);\r
652                 }\r
653 \r
654                 if(hWndFocus == GetRemoteHwnd())\r
655                 {\r
656                         if(AskConnecting() == YES)\r
657                         {\r
658                                 EnableMenuItem(GetMenu(hWndMain), MENU_SOMECMD, MF_ENABLED);\r
659                         }\r
660                         else\r
661                         {\r
662                                 EnableMenuItem(GetMenu(hWndMain), MENU_SOMECMD, MF_GRAYED);\r
663                         }\r
664 \r
665                         if((AskConnecting() == YES) && (Count > 0))\r
666                         {\r
667                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_DOWNLOAD, MAKELONG(TRUE, 0));\r
668                                 EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD, MF_ENABLED);\r
669                                 EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_AS, MF_ENABLED);\r
670                                 EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_AS_FILE, MF_ENABLED);\r
671                         }\r
672                         else\r
673                         {\r
674                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_DOWNLOAD, MAKELONG(FALSE, 0));\r
675                                 EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD, MF_GRAYED);\r
676                                 EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_AS, MF_GRAYED);\r
677                                 EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_AS_FILE, MF_GRAYED);\r
678                         }\r
679                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_UPLOAD, MAKELONG(FALSE, 0));\r
680                         EnableMenuItem(GetMenu(hWndMain), MENU_UPLOAD, MF_GRAYED);\r
681                         EnableMenuItem(GetMenu(hWndMain), MENU_UPLOAD_AS, MF_GRAYED);\r
682                 }\r
683 \r
684                 if((hWndFocus == GetLocalHwnd()) || (hWndFocus == GetRemoteHwnd()))\r
685                 {\r
686                         if(Count > 0)\r
687                         {\r
688                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_DELETE, MAKELONG(TRUE, 0));\r
689                                 EnableMenuItem(GetMenu(hWndMain), MENU_DELETE, MF_ENABLED);\r
690                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_RENAME, MAKELONG(TRUE, 0));\r
691                                 EnableMenuItem(GetMenu(hWndMain), MENU_RENAME, MF_ENABLED);\r
692 \r
693                                 EnableMenuItem(GetMenu(hWndMain), MENU_CHMOD, MF_ENABLED);\r
694 \r
695                         }\r
696                         else\r
697                         {\r
698                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_DELETE, MAKELONG(FALSE, 0));\r
699                                 EnableMenuItem(GetMenu(hWndMain), MENU_DELETE, MF_GRAYED);\r
700                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_RENAME, MAKELONG(FALSE, 0));\r
701                                 EnableMenuItem(GetMenu(hWndMain), MENU_RENAME, MF_GRAYED);\r
702 \r
703                                 EnableMenuItem(GetMenu(hWndMain), MENU_CHMOD, MF_GRAYED);\r
704                         }\r
705 \r
706                         if((hWndFocus == GetLocalHwnd()) || (AskConnecting() == YES))\r
707                         {\r
708                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_MKDIR, MAKELONG(TRUE, 0));\r
709                                 EnableMenuItem(GetMenu(hWndMain), MENU_MKDIR, MF_ENABLED);\r
710                                 EnableMenuItem(GetMenu(hWndMain), MENU_FILESIZE, MF_ENABLED);\r
711                         }\r
712                         else\r
713                         {\r
714                                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_MKDIR, MAKELONG(FALSE, 0));\r
715                                 EnableMenuItem(GetMenu(hWndMain), MENU_MKDIR, MF_GRAYED);\r
716                                 EnableMenuItem(GetMenu(hWndMain), MENU_FILESIZE, MF_GRAYED);\r
717                         }\r
718                 }\r
719                 else\r
720                 {\r
721                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_UPLOAD, MAKELONG(FALSE, 0));\r
722                         EnableMenuItem(GetMenu(hWndMain), MENU_UPLOAD, MF_GRAYED);\r
723                         EnableMenuItem(GetMenu(hWndMain), MENU_UPLOAD_AS, MF_GRAYED);\r
724                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_DOWNLOAD, MAKELONG(FALSE, 0));\r
725                         EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD, MF_GRAYED);\r
726                         EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_AS, MF_GRAYED);\r
727                         EnableMenuItem(GetMenu(hWndMain), MENU_DOWNLOAD_AS_FILE, MF_GRAYED);\r
728                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_DELETE, MAKELONG(FALSE, 0));\r
729                         EnableMenuItem(GetMenu(hWndMain), MENU_DELETE, MF_GRAYED);\r
730                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_RENAME, MAKELONG(FALSE, 0));\r
731                         EnableMenuItem(GetMenu(hWndMain), MENU_RENAME, MF_GRAYED);\r
732                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_MKDIR, MAKELONG(FALSE, 0));\r
733                         EnableMenuItem(GetMenu(hWndMain), MENU_MKDIR, MF_GRAYED);\r
734                         EnableMenuItem(GetMenu(hWndMain), MENU_CHMOD, MF_GRAYED);\r
735                         EnableMenuItem(GetMenu(hWndMain), MENU_FILESIZE, MF_GRAYED);\r
736                         EnableMenuItem(GetMenu(hWndMain), MENU_SOMECMD, MF_GRAYED);\r
737                 }\r
738         }\r
739         return;\r
740 }\r
741 \r
742 \r
743 /*----- ユーザの操作を禁止する ------------------------------------------------\r
744 *\r
745 *       Parameter\r
746 *               なし\r
747 *\r
748 *       Return Value\r
749 *               なし\r
750 *----------------------------------------------------------------------------*/\r
751 \r
752 void DisableUserOpe(void)\r
753 {\r
754         int i;\r
755 \r
756         HideUI = YES;\r
757 \r
758         for(i = 0; i < sizeof(HideMenus) / sizeof(int); i++)\r
759         {\r
760                 EnableMenuItem(GetMenu(GetMainHwnd()), HideMenus[i], MF_GRAYED);\r
761                 SendMessage(hWndTbarMain, TB_ENABLEBUTTON, HideMenus[i], MAKELONG(FALSE, 0));\r
762                 SendMessage(hWndTbarLocal, TB_ENABLEBUTTON, HideMenus[i], MAKELONG(FALSE, 0));\r
763                 SendMessage(hWndTbarRemote, TB_ENABLEBUTTON, HideMenus[i], MAKELONG(FALSE, 0));\r
764         }\r
765 \r
766         EnableWindow(hWndDirLocal, FALSE);\r
767         EnableWindow(hWndDirRemote, FALSE);\r
768 \r
769         return;\r
770 }\r
771 \r
772 \r
773 /*----- ユーザの操作を許可する ------------------------------------------------\r
774 *\r
775 *       Parameter\r
776 *               なし\r
777 *\r
778 *       Return Value\r
779 *               なし\r
780 *----------------------------------------------------------------------------*/\r
781 \r
782 void EnableUserOpe(void)\r
783 {\r
784         int i;\r
785 \r
786         if(HideUI == YES)\r
787         {\r
788                 for(i = 0; i < sizeof(HideMenus) / sizeof(int); i++)\r
789                 {\r
790                         EnableMenuItem(GetMenu(GetMainHwnd()), HideMenus[i], MF_ENABLED);\r
791                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, HideMenus[i], MAKELONG(TRUE, 0));\r
792                         SendMessage(hWndTbarLocal, TB_ENABLEBUTTON, HideMenus[i], MAKELONG(TRUE, 0));\r
793                         SendMessage(hWndTbarRemote, TB_ENABLEBUTTON, HideMenus[i], MAKELONG(TRUE, 0));\r
794                 }\r
795                 EnableWindow(hWndDirLocal, TRUE);\r
796                 EnableWindow(hWndDirRemote, TRUE);\r
797 \r
798                 // 選択不可な漢字コードのボタンが表示されるバグを修正\r
799                 HideHostKanjiButton();\r
800                 HideLocalKanjiButton();\r
801 \r
802                 HideUI = NO;\r
803 \r
804                 MakeButtonsFocus();\r
805         }\r
806         return;\r
807 }\r
808 \r
809 \r
810 /*----- ユーザの操作が禁止されているかどうかを返す ----------------------------\r
811 *\r
812 *       Parameter\r
813 *               なし\r
814 *\r
815 *       Return Value\r
816 *               int ステータス\r
817 *                       YES=禁止されている/NO\r
818 *----------------------------------------------------------------------------*/\r
819 \r
820 int AskUserOpeDisabled(void)\r
821 {\r
822         return(HideUI);\r
823 }\r
824 \r
825 \r
826 /*===================================================\r
827 *                       転送モード\r
828 *===================================================*/\r
829 \r
830 /*----- 転送モードを設定する --------------------------------------------------\r
831 *\r
832 *       Parameter\r
833 *               int Mode : 転送モード (TYPE_xx)\r
834 *\r
835 *       Return Value\r
836 *               なし\r
837 *----------------------------------------------------------------------------*/\r
838 \r
839 void SetTransferTypeImm(int Mode)\r
840 {\r
841         TmpTransMode = Mode;\r
842         HideHostKanjiButton();\r
843         HideLocalKanjiButton();\r
844         return;\r
845 }\r
846 \r
847 \r
848 /*----- メニューにより転送モードを設定する ------------------------------------\r
849 *\r
850 *       Parameter\r
851 *               int Type : 転送モード (MENU_xxxx)\r
852 *\r
853 *       Return Value\r
854 *               なし\r
855 *----------------------------------------------------------------------------*/\r
856 \r
857 void SetTransferType(int Type)\r
858 {\r
859         switch(Type)\r
860         {\r
861                 case MENU_TEXT :\r
862                         TmpTransMode = TYPE_A;\r
863                         break;\r
864 \r
865                 case MENU_BINARY :\r
866                         TmpTransMode = TYPE_I;\r
867                         break;\r
868 \r
869                 default :\r
870                         TmpTransMode = TYPE_X;\r
871                         break;\r
872         }\r
873         HideHostKanjiButton();\r
874         HideLocalKanjiButton();\r
875         return;\r
876 }\r
877 \r
878 \r
879 /*----- 転送モードにしたがってボタンを表示する --------------------------------\r
880 *\r
881 *       Parameter\r
882 *               なし\r
883 *\r
884 *       Return Value\r
885 *               なし\r
886 *----------------------------------------------------------------------------*/\r
887 \r
888 void DispTransferType(void)\r
889 {\r
890         switch(TmpTransMode)\r
891         {\r
892                 case TYPE_A :\r
893                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_TEXT, MAKELONG(TRUE, 0));\r
894                         break;\r
895 \r
896                 case TYPE_I :\r
897                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_BINARY, MAKELONG(TRUE, 0));\r
898                         break;\r
899 \r
900                 default :\r
901                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_AUTO, MAKELONG(TRUE, 0));\r
902                         break;\r
903         }\r
904         return;\r
905 }\r
906 \r
907 \r
908 /*----- 設定上の転送モードを返す ----------------------------------------------\r
909 *\r
910 *       Parameter\r
911 *               なし\r
912 *\r
913 *       Return Value\r
914 *               int 転送モード (TYPE_xx)\r
915 *----------------------------------------------------------------------------*/\r
916 \r
917 int AskTransferType(void)\r
918 {\r
919         return(TmpTransMode);\r
920 }\r
921 \r
922 \r
923 /*----- 実際の転送モードを返す ------------------------------------------------\r
924 *\r
925 *       Parameter\r
926 *               char Fname : ファイル名\r
927 *               int Type : 設定上の転送モード (TYPE_xx)\r
928 *\r
929 *       Return Value\r
930 *               int 転送モード (TYPE_xx)\r
931 *----------------------------------------------------------------------------*/\r
932 \r
933 int AskTransferTypeAssoc(char *Fname, int Type)\r
934 {\r
935         int Ret;\r
936         char *Pos;\r
937         char *Name;\r
938 \r
939         Ret = Type;\r
940         if(Ret == TYPE_X)\r
941         {\r
942                 Ret = TYPE_I;\r
943                 if(StrMultiLen(AsciiExt) > 0)\r
944                 {\r
945                         Name = GetFileName(Fname);\r
946                         Pos = AsciiExt;\r
947                         while(*Pos != NUL)\r
948                         {\r
949                                 if(CheckFname(Name, Pos) == FFFTP_SUCCESS)\r
950                                 {\r
951                                         Ret = TYPE_A;\r
952                                         break;\r
953                                 }\r
954                                 Pos += strlen(Pos) + 1;\r
955                         }\r
956                 }\r
957         }\r
958         return(Ret);\r
959 }\r
960 \r
961 \r
962 /*----- 転送モードを保存する --------------------------------------------------\r
963 *\r
964 *       Parameter\r
965 *               なし\r
966 *\r
967 *       Return Value\r
968 *               なし\r
969 *\r
970 *       Note\r
971 *               現在の転送モードがレジストリに保存される\r
972 *----------------------------------------------------------------------------*/\r
973 \r
974 void SaveTransferType(void)\r
975 {\r
976         TransMode = TmpTransMode;\r
977         return;\r
978 }\r
979 \r
980 \r
981 /*===================================================\r
982 *                       漢字モード\r
983 *===================================================*/\r
984 \r
985 /*----- ホストの漢字モードをセットする ----------------------------------------\r
986 *\r
987 *       Parameter\r
988 *               int Mode : 漢字モード (KANJI_xxxx)\r
989 *\r
990 *       Return Value\r
991 *               なし\r
992 *----------------------------------------------------------------------------*/\r
993 \r
994 void SetHostKanjiCodeImm(int Mode)\r
995 {\r
996         TmpHostKanjiCode = Mode;\r
997         DispHostKanjiCode();\r
998         HideHostKanjiButton();\r
999         return;\r
1000 }\r
1001 \r
1002 \r
1003 /*----- メニューによりホストの漢字モードを設定する -----------------------------\r
1004 *\r
1005 *       Parameter\r
1006 *               int Type : 漢字モード (MENU_xxxx)\r
1007 *\r
1008 *       Return Value\r
1009 *               なし\r
1010 *----------------------------------------------------------------------------*/\r
1011 \r
1012 void SetHostKanjiCode(int Type)\r
1013 {\r
1014         switch(Type)\r
1015         {\r
1016                 // UTF-8対応\r
1017                 case MENU_KNJ_SJIS :\r
1018                         TmpHostKanjiCode = KANJI_SJIS;\r
1019                         break;\r
1020 \r
1021                 case MENU_KNJ_EUC :\r
1022                         TmpHostKanjiCode = KANJI_EUC;\r
1023                         break;\r
1024 \r
1025                 case MENU_KNJ_JIS :\r
1026                         TmpHostKanjiCode = KANJI_JIS;\r
1027                         break;\r
1028 \r
1029                 case MENU_KNJ_UTF8N :\r
1030                         TmpHostKanjiCode = KANJI_UTF8N;\r
1031                         break;\r
1032 \r
1033                 case MENU_KNJ_UTF8BOM :\r
1034                         TmpHostKanjiCode = KANJI_UTF8BOM;\r
1035                         break;\r
1036 \r
1037                 default :\r
1038                         TmpHostKanjiCode = KANJI_NOCNV;\r
1039                         break;\r
1040         }\r
1041         DispHostKanjiCode();\r
1042         HideHostKanjiButton();\r
1043         return;\r
1044 }\r
1045 \r
1046 \r
1047 /*----- ホストの漢字モードにしたがってボタンを表示する ------------------------\r
1048 *\r
1049 *       Parameter\r
1050 *               なし\r
1051 *\r
1052 *       Return Value\r
1053 *               なし\r
1054 *----------------------------------------------------------------------------*/\r
1055 \r
1056 void DispHostKanjiCode(void)\r
1057 {\r
1058         switch(TmpHostKanjiCode)\r
1059         {\r
1060                 // UTF-8対応\r
1061                 case KANJI_SJIS :\r
1062                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_KNJ_SJIS, MAKELONG(TRUE, 0));\r
1063                         break;\r
1064 \r
1065                 case KANJI_EUC :\r
1066                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_KNJ_EUC, MAKELONG(TRUE, 0));\r
1067                         break;\r
1068 \r
1069                 case KANJI_JIS :\r
1070                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_KNJ_JIS, MAKELONG(TRUE, 0));\r
1071                         break;\r
1072 \r
1073                 case KANJI_UTF8N :\r
1074                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_KNJ_UTF8N, MAKELONG(TRUE, 0));\r
1075                         break;\r
1076 \r
1077                 case KANJI_UTF8BOM :\r
1078                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_KNJ_UTF8BOM, MAKELONG(TRUE, 0));\r
1079                         break;\r
1080 \r
1081                 default :\r
1082                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_KNJ_NONE, MAKELONG(TRUE, 0));\r
1083                         break;\r
1084         }\r
1085         return;\r
1086 }\r
1087 \r
1088 \r
1089 /*----- ホストの漢字モードを返す ----------------------------------------------\r
1090 *\r
1091 *       Parameter\r
1092 *               なし\r
1093 *\r
1094 *       Return Value\r
1095 *               int 漢字モード (KANJI_xxxx)\r
1096 *----------------------------------------------------------------------------*/\r
1097 \r
1098 int AskHostKanjiCode(void)\r
1099 {\r
1100         return(TmpHostKanjiCode);\r
1101 }\r
1102 \r
1103 \r
1104 /*----- 漢字モードボタンのハイド処理を行う ------------------------------------\r
1105 *\r
1106 *       Parameter\r
1107 *               なし\r
1108 *\r
1109 *       Return Value\r
1110 *               なし\r
1111 *----------------------------------------------------------------------------*/\r
1112 \r
1113 void HideHostKanjiButton(void)\r
1114 {\r
1115         switch(TmpTransMode)\r
1116         {\r
1117                 // UTF-8対応\r
1118                 case TYPE_I : \r
1119                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_SJIS, MAKELONG(FALSE, 0));\r
1120                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_EUC, MAKELONG(FALSE, 0));\r
1121                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_JIS, MAKELONG(FALSE, 0));\r
1122                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_UTF8N, MAKELONG(FALSE, 0));\r
1123                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_UTF8BOM, MAKELONG(FALSE, 0));\r
1124                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_NONE, MAKELONG(FALSE, 0));\r
1125                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KANACNV, MAKELONG(FALSE, 0));\r
1126                         break;\r
1127 \r
1128                 default :\r
1129                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_SJIS, MAKELONG(TRUE, 0));\r
1130                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_EUC, MAKELONG(TRUE, 0));\r
1131                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_JIS, MAKELONG(TRUE, 0));\r
1132                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_UTF8N, MAKELONG(TRUE, 0));\r
1133                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_UTF8BOM, MAKELONG(TRUE, 0));\r
1134                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KNJ_NONE, MAKELONG(TRUE, 0));\r
1135 //                      if(TmpHostKanjiCode != KANJI_NOCNV)\r
1136 //                              SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KANACNV, MAKELONG(TRUE, 0));\r
1137 //                      else\r
1138 //                              SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KANACNV, MAKELONG(FALSE, 0));\r
1139 //                      break;\r
1140                         // 現在カナ変換はShift_JIS、JIS、EUC間でのみ機能する\r
1141                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KANACNV, MAKELONG(FALSE, 0));\r
1142                         switch(TmpHostKanjiCode)\r
1143                         {\r
1144                         case KANJI_SJIS:\r
1145                         case KANJI_JIS:\r
1146                         case KANJI_EUC:\r
1147                                 switch(TmpLocalKanjiCode)\r
1148                                 {\r
1149                                 case KANJI_SJIS:\r
1150                                 case KANJI_JIS:\r
1151                                 case KANJI_EUC:\r
1152                                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KANACNV, MAKELONG(TRUE, 0));\r
1153                                         break;\r
1154                                 }\r
1155                                 break;\r
1156                         }\r
1157         }\r
1158         return;\r
1159 }\r
1160 \r
1161 \r
1162 // ローカルの漢字コード\r
1163 // テキストモード転送時に使用\r
1164 // ホスト側が無変換の時はローカルも無変換\r
1165 \r
1166 void SetLocalKanjiCodeImm(int Mode)\r
1167 {\r
1168         TmpLocalKanjiCode = Mode;\r
1169         DispLocalKanjiCode();\r
1170         HideLocalKanjiButton();\r
1171         return;\r
1172 }\r
1173 \r
1174 void SetLocalKanjiCode(int Type)\r
1175 {\r
1176         switch(Type)\r
1177         {\r
1178                 // UTF-8対応\r
1179                 case MENU_L_KNJ_SJIS :\r
1180                         TmpLocalKanjiCode = KANJI_SJIS;\r
1181                         break;\r
1182 \r
1183                 case MENU_L_KNJ_EUC :\r
1184                         TmpLocalKanjiCode = KANJI_EUC;\r
1185                         break;\r
1186 \r
1187                 case MENU_L_KNJ_JIS :\r
1188                         TmpLocalKanjiCode = KANJI_JIS;\r
1189                         break;\r
1190 \r
1191                 case MENU_L_KNJ_UTF8N :\r
1192                         TmpLocalKanjiCode = KANJI_UTF8N;\r
1193                         break;\r
1194 \r
1195                 case MENU_L_KNJ_UTF8BOM :\r
1196                         TmpLocalKanjiCode = KANJI_UTF8BOM;\r
1197                         break;\r
1198         }\r
1199         DispLocalKanjiCode();\r
1200         HideLocalKanjiButton();\r
1201         return;\r
1202 }\r
1203 \r
1204 void DispLocalKanjiCode(void)\r
1205 {\r
1206         switch(TmpLocalKanjiCode)\r
1207         {\r
1208                 // UTF-8対応\r
1209                 case KANJI_SJIS :\r
1210                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_L_KNJ_SJIS, MAKELONG(TRUE, 0));\r
1211                         break;\r
1212 \r
1213                 case KANJI_EUC :\r
1214                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_L_KNJ_EUC, MAKELONG(TRUE, 0));\r
1215                         break;\r
1216 \r
1217                 case KANJI_JIS :\r
1218                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_L_KNJ_JIS, MAKELONG(TRUE, 0));\r
1219                         break;\r
1220 \r
1221                 case KANJI_UTF8N :\r
1222                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_L_KNJ_UTF8N, MAKELONG(TRUE, 0));\r
1223                         break;\r
1224 \r
1225                 case KANJI_UTF8BOM :\r
1226                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_L_KNJ_UTF8BOM, MAKELONG(TRUE, 0));\r
1227                         break;\r
1228         }\r
1229         return;\r
1230 }\r
1231 \r
1232 int AskLocalKanjiCode(void)\r
1233 {\r
1234         return(TmpLocalKanjiCode);\r
1235 }\r
1236 \r
1237 void HideLocalKanjiButton(void)\r
1238 {\r
1239         switch(TmpTransMode)\r
1240         {\r
1241                 // UTF-8対応\r
1242                 case TYPE_I : \r
1243                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_SJIS, MAKELONG(FALSE, 0));\r
1244                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_EUC, MAKELONG(FALSE, 0));\r
1245                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_JIS, MAKELONG(FALSE, 0));\r
1246                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_UTF8N, MAKELONG(FALSE, 0));\r
1247                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_UTF8BOM, MAKELONG(FALSE, 0));\r
1248                         break;\r
1249 \r
1250                 default :\r
1251                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_SJIS, MAKELONG(TRUE, 0));\r
1252                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_EUC, MAKELONG(TRUE, 0));\r
1253                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_JIS, MAKELONG(TRUE, 0));\r
1254                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_UTF8N, MAKELONG(TRUE, 0));\r
1255                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_L_KNJ_UTF8BOM, MAKELONG(TRUE, 0));\r
1256                         // 現在カナ変換はShift_JIS、JIS、EUC間でのみ機能する\r
1257                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KANACNV, MAKELONG(FALSE, 0));\r
1258                         switch(TmpHostKanjiCode)\r
1259                         {\r
1260                         case KANJI_SJIS:\r
1261                         case KANJI_JIS:\r
1262                         case KANJI_EUC:\r
1263                                 switch(TmpLocalKanjiCode)\r
1264                                 {\r
1265                                 case KANJI_SJIS:\r
1266                                 case KANJI_JIS:\r
1267                                 case KANJI_EUC:\r
1268                                         SendMessage(hWndTbarMain, TB_ENABLEBUTTON, MENU_KANACNV, MAKELONG(TRUE, 0));\r
1269                                         break;\r
1270                                 }\r
1271                                 break;\r
1272                         }\r
1273                         break;\r
1274         }\r
1275         return;\r
1276 }\r
1277 \r
1278 \r
1279 /*===================================================\r
1280 *                       半角変換モード\r
1281 *===================================================*/\r
1282 \r
1283 /*----- ホストの半角変換モードを設定する --------------------------------------\r
1284 *\r
1285 *       Parameter\r
1286 *               int Mode : 半角変換モード(YES/NO)\r
1287 *\r
1288 *       Return Value\r
1289 *               なし\r
1290 *----------------------------------------------------------------------------*/\r
1291 \r
1292 void SetHostKanaCnvImm(int Mode)\r
1293 {\r
1294         TmpHostKanaCnv = Mode;\r
1295         DispHostKanaCnv();\r
1296         return;\r
1297 }\r
1298 \r
1299 \r
1300 /*----- ホストの半角変換モードを反転する --------------------------------------\r
1301 *\r
1302 *       Parameter\r
1303 *               なし\r
1304 *\r
1305 *       Return Value\r
1306 *               なし\r
1307 *----------------------------------------------------------------------------*/\r
1308 \r
1309 void SetHostKanaCnv(void)\r
1310 {\r
1311         TmpHostKanaCnv ^= 1;\r
1312         DispHostKanaCnv();\r
1313         return;\r
1314 }\r
1315 \r
1316 \r
1317 /*----- ホストの半角変換モードにしたがってボタンを表示する --------------------\r
1318 *\r
1319 *       Parameter\r
1320 *               なし\r
1321 *\r
1322 *       Return Value\r
1323 *               なし\r
1324 *----------------------------------------------------------------------------*/\r
1325 \r
1326 void DispHostKanaCnv(void)\r
1327 {\r
1328         if(TmpHostKanaCnv != 0)\r
1329                 SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_KANACNV, MAKELONG(TRUE, 0));\r
1330         else\r
1331                 SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_KANACNV, MAKELONG(FALSE, 0));\r
1332         return;\r
1333 }\r
1334 \r
1335 \r
1336 /*----- ホストの半角変換モードを返す ------------------------------------------\r
1337 *\r
1338 *       Parameter\r
1339 *               なし\r
1340 *\r
1341 *       Return Value\r
1342 *               int 半角変換モード\r
1343 *----------------------------------------------------------------------------*/\r
1344 \r
1345 int AskHostKanaCnv(void)\r
1346 {\r
1347         return(TmpHostKanaCnv);\r
1348 }\r
1349 \r
1350 \r
1351 /*===================================================\r
1352 *                       ソート方法\r
1353 *===================================================*/\r
1354 \r
1355 /*----- ソート方法をセットする ------------------------------------------------\r
1356 *\r
1357 *       Parameter\r
1358 *               int LFsort : ローカル側のファイルのソート方法 (SORT_xxx)\r
1359 *               int LDsort : ローカル側のディレクトリのソート方法 (SORT_xxx)\r
1360 *               int RFsort : ホスト側のファイルのソート方法 (SORT_xxx)\r
1361 *               int RDsort : ホスト側のディレクトリのソート方法 (SORT_xxx)\r
1362 *\r
1363 *       Return Value\r
1364 *               なし\r
1365 *----------------------------------------------------------------------------*/\r
1366 \r
1367 void SetSortTypeImm(int LFsort, int LDsort, int RFsort, int RDsort)\r
1368 {\r
1369         TmpLocalFileSort = LFsort;\r
1370         TmpLocalDirSort = LDsort;\r
1371         TmpRemoteFileSort = RFsort;\r
1372         TmpRemoteDirSort = RDsort;\r
1373         return;\r
1374 }\r
1375 \r
1376 \r
1377 /*----- リストビューのタブクリックによるソート方法のセット --------------------\r
1378 *\r
1379 *       Parameter\r
1380 *               int Win : ウインドウ番号\r
1381 *               int Tab : カラム番号\r
1382 *\r
1383 *       Return Value\r
1384 *               int ソート方法 (SORT_xxx)\r
1385 *----------------------------------------------------------------------------*/\r
1386 \r
1387 void SetSortTypeByColumn(int Win, int Tab)\r
1388 {\r
1389         if(Win == WIN_LOCAL)\r
1390         {\r
1391                 if((TmpLocalFileSort & SORT_MASK_ORD) == Tab)\r
1392                         TmpLocalFileSort ^= SORT_GET_ORD;\r
1393                 else\r
1394                         TmpLocalFileSort = Tab;\r
1395 \r
1396                 if((Tab == SORT_NAME) || (Tab == SORT_DATE))\r
1397                         TmpLocalDirSort = TmpLocalFileSort;\r
1398                 else\r
1399                         TmpLocalDirSort = SORT_NAME;\r
1400         }\r
1401         else\r
1402         {\r
1403                 if(Tab != 4)\r
1404                 {\r
1405                         if((TmpRemoteFileSort & SORT_MASK_ORD) == Tab)\r
1406                                 TmpRemoteFileSort ^= SORT_GET_ORD;\r
1407                         else\r
1408                                 TmpRemoteFileSort = Tab;\r
1409 \r
1410                         if((Tab == SORT_NAME) || (Tab == SORT_DATE))\r
1411                                 TmpRemoteDirSort = TmpRemoteFileSort;\r
1412                         else\r
1413                                 TmpRemoteDirSort = SORT_NAME;\r
1414                 }\r
1415         }\r
1416         return;\r
1417 }\r
1418 \r
1419 \r
1420 /*----- ソート方法を返す ------------------------------------------------------\r
1421 *\r
1422 *       Parameter\r
1423 *               int Name : どの部分か (ITEM_xxx)\r
1424 *\r
1425 *       Return Value\r
1426 *               int ソート方法 (SORT_xxx)\r
1427 *----------------------------------------------------------------------------*/\r
1428 \r
1429 int AskSortType(int Name)\r
1430 {\r
1431         int Ret;\r
1432 \r
1433         switch(Name)\r
1434         {\r
1435                 case ITEM_LFILE :\r
1436                         Ret = TmpLocalFileSort;\r
1437                         break;\r
1438 \r
1439                 case ITEM_LDIR :\r
1440                         Ret = TmpLocalDirSort;\r
1441                         break;\r
1442 \r
1443                 case ITEM_RFILE :\r
1444                         Ret = TmpRemoteFileSort;\r
1445                         break;\r
1446 \r
1447                 case ITEM_RDIR :\r
1448                         Ret = TmpRemoteDirSort;\r
1449                         break;\r
1450         }\r
1451         return(Ret);\r
1452 }\r
1453 \r
1454 \r
1455 /*----- ホストごとにソートを保存するかどうかをセットする-----------------------\r
1456 *\r
1457 *       Parameter\r
1458 *               int Sw : スイッチ (YES/NO)\r
1459 *\r
1460 *       Return Value\r
1461 *               なし\r
1462 *----------------------------------------------------------------------------*/\r
1463 \r
1464 void SetSaveSortToHost(int Sw)\r
1465 {\r
1466         SortSave = Sw;\r
1467         return;\r
1468 }\r
1469 \r
1470 \r
1471 /*----- ホストごとにソートを保存するかどうかを返す ----------------------------\r
1472 *\r
1473 *       Parameter\r
1474 *               なし\r
1475 *\r
1476 *       Return Value\r
1477 *               int スイッチ (YES/NO)\r
1478 *----------------------------------------------------------------------------*/\r
1479 \r
1480 int AskSaveSortToHost(void)\r
1481 {\r
1482         return(SortSave);\r
1483 }\r
1484 \r
1485 \r
1486 \r
1487 /*===================================================\r
1488 *                       リストモード\r
1489 *===================================================*/\r
1490 \r
1491 /*----- リストモードにしたがってボタンを表示する ------------------------------\r
1492 *\r
1493 *       Parameter\r
1494 *               なし\r
1495 *\r
1496 *       Return Value\r
1497 *               なし\r
1498 *----------------------------------------------------------------------------*/\r
1499 \r
1500 void DispListType(void)\r
1501 {\r
1502         HWND hWndMain;\r
1503 \r
1504         hWndMain = GetMainHwnd();\r
1505         switch(ListType)\r
1506         {\r
1507                 case LVS_LIST :\r
1508                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_LIST, MAKELONG(TRUE, 0));\r
1509                         CheckMenuItem(GetMenu(hWndMain), MENU_LIST, MF_CHECKED);\r
1510                         CheckMenuItem(GetMenu(hWndMain), MENU_REPORT, MF_UNCHECKED);\r
1511                         break;\r
1512 \r
1513                 default :\r
1514                         SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_REPORT, MAKELONG(TRUE, 0));\r
1515                         CheckMenuItem(GetMenu(hWndMain), MENU_REPORT, MF_CHECKED);\r
1516                         CheckMenuItem(GetMenu(hWndMain), MENU_LIST, MF_UNCHECKED);\r
1517                         break;\r
1518         }\r
1519         return;\r
1520 }\r
1521 \r
1522 \r
1523 /*===================================================\r
1524 *                       フォルダ同時移動モード\r
1525 *===================================================*/\r
1526 \r
1527 /*----- 転送モードを設定する --------------------------------------------------\r
1528 *\r
1529 *       Parameter\r
1530 *               int Mode : 転送モード (TYPE_xx)\r
1531 *\r
1532 *       Return Value\r
1533 *               なし\r
1534 *----------------------------------------------------------------------------*/\r
1535 \r
1536 void SetSyncMoveMode(int Mode)\r
1537 {\r
1538         SyncMove = Mode;\r
1539         DispSyncMoveMode();\r
1540         return;\r
1541 }\r
1542 \r
1543 \r
1544 /*----- フォルダ同時移動モードを切り替える ------------------------------------\r
1545 *\r
1546 *       Parameter\r
1547 *               なし\r
1548 *\r
1549 *       Return Value\r
1550 *               なし\r
1551 *----------------------------------------------------------------------------*/\r
1552 \r
1553 void ToggleSyncMoveMode(void)\r
1554 {\r
1555         SyncMove ^= 1;\r
1556         DispSyncMoveMode();\r
1557         return;\r
1558 }\r
1559 \r
1560 \r
1561 /*----- フォルダ同時移動を行うかどうかをによってメニュー/ボタンを表示 --------\r
1562 *\r
1563 *       Parameter\r
1564 *               なし\r
1565 *\r
1566 *       Return Value\r
1567 *               なし\r
1568 *----------------------------------------------------------------------------*/\r
1569 \r
1570 void DispSyncMoveMode(void)\r
1571 {\r
1572         if(SyncMove != 0)\r
1573         {\r
1574                 SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_SYNC, MAKELONG(TRUE, 0));\r
1575                 CheckMenuItem(GetMenu(GetMainHwnd()), MENU_SYNC, MF_CHECKED);\r
1576         }\r
1577         else\r
1578         {\r
1579                 SendMessage(hWndTbarMain, TB_CHECKBUTTON, MENU_SYNC, MAKELONG(FALSE, 0));\r
1580                 CheckMenuItem(GetMenu(GetMainHwnd()), MENU_SYNC, MF_UNCHECKED);\r
1581         }\r
1582         return;\r
1583 }\r
1584 \r
1585 \r
1586 /*----- フォルダ同時移動モードを返す ------------------------------------------\r
1587 *\r
1588 *       Parameter\r
1589 *               なし\r
1590 *\r
1591 *       Return Value\r
1592 *               int 半角変換モード\r
1593 *----------------------------------------------------------------------------*/\r
1594 \r
1595 int AskSyncMoveMode(void)\r
1596 {\r
1597         return(SyncMove);\r
1598 }\r
1599 \r
1600 \r
1601 /*===================================================\r
1602 *                       ディレクトリヒストリ\r
1603 *===================================================*/\r
1604 \r
1605 /*----- ホスト側のヒストリ一覧ウインドウに登録 --------------------------------\r
1606 *\r
1607 *       Parameter\r
1608 *               char *Path : パス\r
1609 *\r
1610 *       Return Value\r
1611 *               なし\r
1612 *----------------------------------------------------------------------------*/\r
1613 \r
1614 void SetRemoteDirHist(char *Path)\r
1615 {\r
1616         int i;\r
1617 \r
1618         if((i = SendMessage(hWndDirRemote, CB_FINDSTRINGEXACT, 0, (LPARAM)Path)) != CB_ERR)\r
1619                 SendMessage(hWndDirRemote, CB_DELETESTRING, i, 0);\r
1620 \r
1621         SendMessage(hWndDirRemote, CB_ADDSTRING, 0, (LPARAM)Path);\r
1622         i = SendMessage(hWndDirRemote, CB_GETCOUNT, 0, 0);\r
1623         SendMessage(hWndDirRemote, CB_SETCURSEL, i-1, 0);\r
1624 \r
1625         strcpy(RemoteCurDir, Path);\r
1626         return;\r
1627 }\r
1628 \r
1629 \r
1630 /*----- ローカル側のヒストリ一覧ウインドウに登録 -------------------------------\r
1631 *\r
1632 *       Parameter\r
1633 *               char *Path : パス\r
1634 *\r
1635 *       Return Value\r
1636 *               なし\r
1637 *----------------------------------------------------------------------------*/\r
1638 \r
1639 void SetLocalDirHist(char *Path)\r
1640 {\r
1641         int i;\r
1642 \r
1643         if((i = SendMessage(hWndDirLocal, CB_FINDSTRINGEXACT, 0, (LPARAM)Path)) == CB_ERR)\r
1644                 SendMessage(hWndDirLocal, CB_ADDSTRING, 0, (LPARAM)Path);\r
1645         i = SendMessage(hWndDirLocal, CB_FINDSTRINGEXACT, 0, (LPARAM)Path);\r
1646         SendMessage(hWndDirLocal, CB_SETCURSEL, i, 0);\r
1647 \r
1648         strcpy(LocalCurDir, Path);\r
1649         return;\r
1650 }\r
1651 \r
1652 \r
1653 /*----- ローカルのカレントディレクトリを返す ----------------------------------\r
1654 *\r
1655 *       Parameter\r
1656 *               char *Buf : カレントディレクトリ名を返すバッファ\r
1657 *               int Max : バッファのサイズ\r
1658 *\r
1659 *       Return Value\r
1660 *               なし\r
1661 *----------------------------------------------------------------------------*/\r
1662 \r
1663 void AskLocalCurDir(char *Buf, int Max)\r
1664 {\r
1665         memset(Buf, 0, Max);\r
1666         strncpy(Buf, LocalCurDir, Max-1);\r
1667         return;\r
1668 }\r
1669 \r
1670 \r
1671 /*----- ホストのカレントディレクトリを返す ------------------------------------\r
1672 *\r
1673 *       Parameter\r
1674 *               char *Buf : カレントディレクトリ名を返すバッファ\r
1675 *               int Max : バッファのサイズ\r
1676 *\r
1677 *       Return Value\r
1678 *               なし\r
1679 *----------------------------------------------------------------------------*/\r
1680 \r
1681 void AskRemoteCurDir(char *Buf, int Max)\r
1682 {\r
1683         memset(Buf, 0, Max);\r
1684         strncpy(Buf, RemoteCurDir, Max-1);\r
1685         return;\r
1686 }\r
1687 \r
1688 \r
1689 /*----- カレントディレクトリを設定する ----------------------------------------\r
1690 *\r
1691 *       Parameter\r
1692 *               なし\r
1693 *\r
1694 *       Return Value\r
1695 *               なし\r
1696 *----------------------------------------------------------------------------*/\r
1697 \r
1698 void SetCurrentDirAsDirHist(void)\r
1699 {\r
1700         SetCurrentDirectory(LocalCurDir);\r
1701         return;\r
1702 }\r
1703 \r
1704 \r
1705 /*===================================================\r
1706 *                       メニュー\r
1707 *===================================================*/\r
1708 \r
1709 /*----- ドットファイルを表示するかどうかをメニューに表示する ------------------\r
1710 *\r
1711 *       Parameter\r
1712 *               なし\r
1713 *\r
1714 *       Return Value\r
1715 *               なし\r
1716 *----------------------------------------------------------------------------*/\r
1717 \r
1718 void DispDotFileMode(void)\r
1719 {\r
1720         CheckMenuItem(GetMenu(GetMainHwnd()), MENU_DOTFILE, MF_UNCHECKED);\r
1721         if(DotFile == YES)\r
1722                 CheckMenuItem(GetMenu(GetMainHwnd()), MENU_DOTFILE, MF_CHECKED);\r
1723         return;\r
1724 }\r
1725 \r
1726 \r
1727 /*----- ローカル側の右ボタンメニューを表示 ------------------------------------------------\r
1728 *\r
1729 *       Parameter\r
1730 *               int Pos : メニューの位置\r
1731 *                                       0=マウスカーソルの位置\r
1732 *                                       1=ウインドウの左上\r
1733 *\r
1734 *       Return Value\r
1735 *               なし\r
1736 *----------------------------------------------------------------------------*/\r
1737 \r
1738 void LocalRbuttonMenu(int Pos)\r
1739 {\r
1740         HMENU hMenu;\r
1741         POINT point;\r
1742         RECT Rect;\r
1743         UINT Flg1;\r
1744         UINT Flg2;\r
1745         UINT Flg3;\r
1746         int Count;\r
1747 \r
1748         if(HideUI == NO)\r
1749         {\r
1750                 Flg1 = 0;\r
1751                 if(AskConnecting() == NO)\r
1752                         Flg1 = MF_GRAYED;\r
1753 \r
1754                 Count = GetSelectedCount(WIN_LOCAL);\r
1755                 Flg2 = 0;\r
1756                 if(Count == 0)\r
1757                         Flg2 = MF_GRAYED;\r
1758 \r
1759                 Flg3 = 0;\r
1760                 if(Count != 1)\r
1761                         Flg3 = MF_GRAYED;\r
1762 \r
1763                 hMenu = CreatePopupMenu();\r
1764                 AddOpenMenu(hMenu, Flg3);\r
1765                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_UPLOAD, MSGJPN255);\r
1766                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_UPLOAD_AS, MSGJPN256);\r
1767                 AppendMenu(hMenu, MF_STRING | Flg1, MENU_UPLOAD_ALL, MSGJPN257);\r
1768                 AppendMenu(hMenu, MF_STRING | Flg2, MENU_DELETE, MSGJPN258);\r
1769                 AppendMenu(hMenu, MF_STRING | Flg2, MENU_RENAME, MSGJPN259);\r
1770                 AppendMenu(hMenu, MF_STRING , MENU_MKDIR, MSGJPN260);\r
1771                 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);\r
1772                 AppendMenu(hMenu, MF_STRING , MENU_FILESIZE, MSGJPN261);\r
1773                 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);\r
1774                 AppendMenu(hMenu, MF_STRING, REFRESH_LOCAL, MSGJPN262);\r
1775 \r
1776                 if(Pos == 0)\r
1777                         GetCursorPos(&point);\r
1778                 else\r
1779                 {\r
1780                         GetWindowRect(GetLocalHwnd(), &Rect);\r
1781                         point.x = Rect.left + 20;\r
1782                         point.y = Rect.top + 20;\r
1783                 }\r
1784                 TrackPopupMenu(hMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON, point.x, point.y, 0, GetMainHwnd(), NULL);\r
1785 \r
1786                 DestroyMenu(hMenu);\r
1787         }\r
1788         return;\r
1789 }\r
1790 \r
1791 \r
1792 /*----- ホスト側の右ボタンメニューを表示 --------------------------------------\r
1793 *\r
1794 *       Parameter\r
1795 *               int Pos : メニューの位置\r
1796 *                                       0=マウスカーソルの位置\r
1797 *                                       1=ウインドウの左上\r
1798 *\r
1799 *       Return Value\r
1800 *               なし\r
1801 *----------------------------------------------------------------------------*/\r
1802 \r
1803 void RemoteRbuttonMenu(int Pos)\r
1804 {\r
1805         HMENU hMenu;\r
1806         POINT point;\r
1807         RECT Rect;\r
1808         UINT Flg1;\r
1809         UINT Flg2;\r
1810         UINT Flg3;\r
1811         int Count;\r
1812 \r
1813         if(HideUI == NO)\r
1814         {\r
1815                 Flg1 = 0;\r
1816                 if(AskConnecting() == NO)\r
1817                         Flg1 = MF_GRAYED;\r
1818 \r
1819                 Count = GetSelectedCount(WIN_REMOTE);\r
1820                 Flg2 = 0;\r
1821                 if(Count == 0)\r
1822                         Flg2 = MF_GRAYED;\r
1823 \r
1824                 Flg3 = 0;\r
1825                 if(Count != 1)\r
1826                         Flg3 = MF_GRAYED;\r
1827 \r
1828                 hMenu = CreatePopupMenu();\r
1829                 AddOpenMenu(hMenu, Flg1 | Flg3);\r
1830                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_DOWNLOAD, MSGJPN263);\r
1831                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_DOWNLOAD_AS, MSGJPN264);\r
1832                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_DOWNLOAD_AS_FILE, MSGJPN265);\r
1833                 AppendMenu(hMenu, MF_STRING | Flg1, MENU_DOWNLOAD_ALL, MSGJPN266);\r
1834                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_DELETE, MSGJPN267);\r
1835                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_RENAME, MSGJPN268);\r
1836                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_CHMOD, MSGJPN269);\r
1837                 AppendMenu(hMenu, MF_STRING | Flg1, MENU_MKDIR, MSGJPN270);\r
1838                 AppendMenu(hMenu, MF_STRING | Flg1 | Flg2, MENU_URL_COPY, MSGJPN271);\r
1839                 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);\r
1840                 AppendMenu(hMenu, MF_STRING | Flg1, MENU_FILESIZE, MSGJPN272);\r
1841                 AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);\r
1842                 AppendMenu(hMenu, MF_STRING | Flg1, REFRESH_REMOTE, MSGJPN273);\r
1843 \r
1844                 if(Pos == 0)\r
1845                         GetCursorPos(&point);\r
1846                 else\r
1847                 {\r
1848                         GetWindowRect(GetRemoteHwnd(), &Rect);\r
1849                         point.x = Rect.left + 20;\r
1850                         point.y = Rect.top + 20;\r
1851                 }\r
1852                 if(TrackPopupMenu(hMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON, point.x, point.y, 0, GetMainHwnd(), NULL) == 0)\r
1853                         Count = GetLastError();\r
1854 \r
1855                 DestroyMenu(hMenu);\r
1856         }\r
1857         return;\r
1858 }\r
1859 \r
1860 \r
1861 /*----- 右ボタンメニューに「開く」を追加  -------------------------------------\r
1862 *\r
1863 *       Parameter\r
1864 *               HMENU hMenu : メニューハンドル\r
1865 *               UINT Flg : フラグ\r
1866 *\r
1867 *       Return Value\r
1868 *               なし\r
1869 *----------------------------------------------------------------------------*/\r
1870 \r
1871 static void AddOpenMenu(HMENU hMenu, UINT Flg)\r
1872 {\r
1873         static const UINT MenuID[VIEWERS] = { MENU_OPEN1, MENU_OPEN2, MENU_OPEN3 };\r
1874         char Tmp[FMAX_PATH+1];\r
1875         int i;\r
1876 \r
1877         AppendMenu(hMenu, MF_STRING | Flg, MENU_DCLICK, MSGJPN274);\r
1878         for(i = 0; i < VIEWERS; i++)\r
1879         {\r
1880                 if(strlen(ViewerName[i]) != 0)\r
1881                 {\r
1882                         sprintf(Tmp, MSGJPN275, GetToolName(ViewerName[i]), i+1);\r
1883                         AppendMenu(hMenu, MF_STRING | Flg, MenuID[i], Tmp);\r
1884                 }\r
1885         }\r
1886         AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);\r
1887         return;\r
1888 }\r
1889 \r
1890 /* 2007/09/21 sunasunamix  ここから *********************/\r
1891 \r
1892 /*----- CreateToolbarEx のマウスクリック関連を無視する(TbarMain用) -----------\r
1893 *       (サブクラス化を行うためのウインドウプロシージャ)\r
1894 *----------------------------------------------------------------------------*/\r
1895 static LRESULT CALLBACK CountermeasureTbarMainProc(HWND hWnd,UINT uMessage,WPARAM wParam,LPARAM lParam)\r
1896 {\r
1897         switch (uMessage) {\r
1898         case WM_DESTROY :\r
1899                 SetWindowLong(hWnd,GWL_WNDPROC,(DWORD)pOldTbarMainProc);\r
1900                 break;\r
1901         case WM_RBUTTONDBLCLK :\r
1902         case WM_RBUTTONDOWN :\r
1903         case WM_RBUTTONUP :\r
1904                 return TRUE;\r
1905         }\r
1906         return CallWindowProc(pOldTbarMainProc, hWnd, uMessage, wParam, lParam);\r
1907 }\r
1908 \r
1909 /*----- CreateToolbarEx のマウスクリック関連を無視する(TbarLocal用) ----------\r
1910 *       (サブクラス化を行うためのウインドウプロシージャ)\r
1911 *----------------------------------------------------------------------------*/\r
1912 static LRESULT CALLBACK CountermeasureTbarLocalProc(HWND hWnd,UINT uMessage,WPARAM wParam,LPARAM lParam)\r
1913 {\r
1914         switch (uMessage) {\r
1915         case WM_DESTROY :\r
1916                 SetWindowLong(hWnd,GWL_WNDPROC,(DWORD)pOldTbarLocalProc);\r
1917                 break;\r
1918         case WM_RBUTTONDBLCLK :\r
1919         case WM_RBUTTONDOWN :\r
1920         case WM_RBUTTONUP :\r
1921                 return TRUE;\r
1922         }\r
1923         return CallWindowProc(pOldTbarLocalProc, hWnd, uMessage, wParam, lParam);\r
1924 }\r
1925 \r
1926 /*----- CreateToolbarEx のマウスクリック関連を無視する(TbarRemote用) ---------\r
1927 *       (サブクラス化を行うためのウインドウプロシージャ)\r
1928 *----------------------------------------------------------------------------*/\r
1929 static LRESULT CALLBACK CountermeasureTbarRemoteProc(HWND hWnd,UINT uMessage,WPARAM wParam,LPARAM lParam)\r
1930 {\r
1931         switch (uMessage) {\r
1932         case WM_DESTROY :\r
1933                 SetWindowLong(hWnd,GWL_WNDPROC,(DWORD)pOldTbarRemoteProc);\r
1934                 break;\r
1935         case WM_RBUTTONDBLCLK :\r
1936         case WM_RBUTTONDOWN :\r
1937         case WM_RBUTTONUP :\r
1938                 return TRUE;\r
1939         }\r
1940         return CallWindowProc(pOldTbarRemoteProc, hWnd, uMessage, wParam, lParam);\r
1941 }\r
1942 /********************************************* ここまで */\r