OSDN Git Service

Fix bugs of automatic detection for Kanji code of filenames.
[ffftp/ffftp.git] / main.c
1 /*=============================================================================\r
2 *\r
3 *                                                                       FFFTP\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 #include "aes.h"\r
45 // 暗号化通信対応\r
46 #include "sha.h"\r
47 \r
48 #include <htmlhelp.h>\r
49 #include "helpid.h"\r
50 \r
51 // UTF-8対応\r
52 #undef __MBSWRAPPER_H__\r
53 #include "mbswrapper.h"\r
54 \r
55 \r
56 #define RESIZE_OFF              0               /* ウインドウの区切り位置変更していない */\r
57 #define RESIZE_ON               1               /* ウインドウの区切り位置変更中 */\r
58 #define RESIZE_PREPARE  2               /* ウインドウの区切り位置変更の準備 */\r
59 \r
60 #define RESIZE_HPOS             0               /* ローカル-ホスト間の区切り位置変更 */\r
61 #define RESIZE_VPOS             1               /* リスト-タスク間の区切り位置の変更 */\r
62 \r
63 \r
64 /*===== プロトタイプ =====*/\r
65 \r
66 static int InitApp(LPSTR lpszCmdLine, int cmdShow);\r
67 static int MakeAllWindows(int cmdShow);\r
68 static void DeleteAllObject(void);\r
69 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
70 static void StartupProc(char *Cmd);\r
71 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max);\r
72 static int CheckIniFileName(char *Str, char *Ini);\r
73 static int CheckMasterPassword(char *Str, char *Ini);\r
74 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 );\r
75 static char *GetToken(char *Str, char *Buf);\r
76 static void ExitProc(HWND hWnd);\r
77 static void ChangeDir(int Win, char *Path);\r
78 static void ResizeWindowProc(void);\r
79 static void CalcWinSize(void);\r
80 // static void AskWindowPos(HWND hWnd);\r
81 static void CheckResizeFrame(WPARAM Keys, int x, int y);\r
82 static void DispDirInfo(void);\r
83 static void DeleteAlltempFile(void);\r
84 static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
85 static int EnterMasterPasswordAndSet( int Res, HWND hWnd );\r
86 \r
87 /*===== ローカルなワーク =====*/\r
88 \r
89 static const char FtpClassStr[] = "FFFTPWin";\r
90 \r
91 static HINSTANCE hInstFtp;\r
92 static HWND hWndFtp = NULL;\r
93 static HWND hWndCurFocus = NULL;\r
94 \r
95 static HACCEL Accel;\r
96 static HBRUSH RootColorBrush = NULL;\r
97 \r
98 static int Resizing = RESIZE_OFF;\r
99 static int ResizePos;\r
100 static HCURSOR hCursor;\r
101 \r
102 int ClientWidth;\r
103 static int ClientHeight;\r
104 int SepaWidth;\r
105 int RemoteWidth;\r
106 int ListHeight;\r
107 \r
108 static TEMPFILELIST *TempFiles = NULL;\r
109 \r
110 static int SaveExit = YES;\r
111 static int AutoExit = NO;\r
112 \r
113 static char HelpPath[FMAX_PATH+1];\r
114 static char IniPath[FMAX_PATH+1];\r
115 static int ForceIni = NO;\r
116 \r
117 TRANSPACKET MainTransPkt;               /* ファイル転送用パケット */\r
118                                                                 /* これを使って転送を行うと、ツールバーの転送 */\r
119                                                                 /* 中止ボタンで中止できる */\r
120 \r
121 char TitleHostName[HOST_ADRS_LEN+1];\r
122 char FilterStr[FILTER_EXT_LEN+1] = { "*" };\r
123 \r
124 int CancelFlg;\r
125 \r
126 static int SuppressRefresh = 0;\r
127 \r
128 static DWORD dwCookie;\r
129 \r
130 \r
131 /*===== グローバルなワーク =====*/\r
132 \r
133 HWND hHelpWin = NULL;\r
134 \r
135 /* 設定値 */\r
136 int WinPosX = CW_USEDEFAULT;\r
137 int WinPosY = 0;\r
138 // 機能が増えたためサイズ変更\r
139 // VGAサイズに収まるようになっていたのをSVGAサイズに引き上げ\r
140 //int WinWidth = 630;\r
141 //int WinHeight = 393;\r
142 //int LocalWidth = 309;\r
143 //int TaskHeight = 50;\r
144 //int LocalTabWidth[4] = { 120, 90, 60, 37 };\r
145 //int RemoteTabWidth[6] = { 120, 90, 60, 37, 60, 60 };\r
146 int WinWidth = 790;\r
147 int WinHeight = 513;\r
148 int LocalWidth = 389;\r
149 int TaskHeight = 100;\r
150 int LocalTabWidth[4] = { 160, 110, 60, 37 };\r
151 int RemoteTabWidth[6] = { 160, 110, 60, 37, 60, 60 };\r
152 char UserMailAdrs[USER_MAIL_LEN+1] = { "who@example.com" };\r
153 char ViewerName[VIEWERS][FMAX_PATH+1] = { { "notepad" }, { "" }, { "" } };\r
154 HFONT ListFont = NULL;\r
155 LOGFONT ListLogFont;\r
156 int LocalFileSort = SORT_NAME;\r
157 int LocalDirSort = SORT_NAME;\r
158 int RemoteFileSort = SORT_NAME;\r
159 int RemoteDirSort = SORT_NAME;\r
160 int TransMode = TYPE_X;\r
161 int ConnectOnStart = YES;\r
162 int DebugConsole = NO;\r
163 int SaveWinPos = NO;\r
164 char AsciiExt[ASCII_EXT_LEN+1] = { "*.txt\0*.html\0*.htm\0*.cgi\0*.pl\0" };\r
165 int RecvMode = TRANS_DLG;\r
166 int SendMode = TRANS_DLG;\r
167 int MoveMode = MOVE_DLG;\r
168 int ListType = LVS_REPORT;\r
169 // LISTのキャッシュを無効にする(リモートのディレクトリの表示が更新されないバグ対策)\r
170 //int CacheEntry = 10;\r
171 int CacheEntry = -10;\r
172 int CacheSave = NO;\r
173 char DefaultLocalPath[FMAX_PATH+1] = { "" };\r
174 int SaveTimeStamp = YES;\r
175 int FindMode = 0;\r
176 int DotFile = YES;\r
177 int DclickOpen = YES;\r
178 int ConnectAndSet = YES;\r
179 SOUNDFILE Sound[SOUND_TYPES] = { { NO, "" }, { NO, "" }, { NO, "" } };\r
180 int FnameCnv = FNAME_NOCNV;\r
181 int TimeOut = 90;\r
182 int RmEOF = NO;\r
183 int RegType = REGTYPE_REG;\r
184 char FwallHost[HOST_ADRS_LEN+1] = { "" };\r
185 char FwallUser[USER_NAME_LEN+1] = { "" };\r
186 char FwallPass[PASSWORD_LEN+1] = { "" };\r
187 int FwallPort = PORT_NOR;\r
188 int FwallType = 1;\r
189 int FwallDefault = NO;\r
190 int FwallSecurity = SECURITY_AUTO;\r
191 int FwallResolv = NO;\r
192 int FwallLower = NO;\r
193 int FwallDelimiter = '@';\r
194 int PasvDefault = NO;\r
195 char MirrorNoTrn[MIRROR_LEN+1] = { "*.bak\0" };\r
196 char MirrorNoDel[MIRROR_LEN+1] = { "" };\r
197 int MirrorFnameCnv = NO;\r
198 int SplitVertical = YES;\r
199 int RasClose = NO;\r
200 int RasCloseNotify = YES;\r
201 int FileHist = 5;\r
202 char DefAttrList[DEFATTRLIST_LEN+1] = { "" };\r
203 SIZE HostDlgSize = { -1, -1 };\r
204 SIZE BmarkDlgSize = { -1, -1 };\r
205 SIZE MirrorDlgSize = { -1, -1 };\r
206 int Sizing = SW_RESTORE;\r
207 int SortSave = NO;\r
208 char TmpPath[FMAX_PATH+1];\r
209 int QuickAnonymous = YES;\r
210 int PassToHist = YES;\r
211 int VaxSemicolon = NO;\r
212 int SendQuit = NO;\r
213 int NoRasControl = NO;\r
214 int SuppressSave = NO;\r
215 int DispIgnoreHide = NO;\r
216 int DispDrives = NO;\r
217 int MirUpDelNotify = YES; \r
218 int MirDownDelNotify = YES; \r
219 int FolderAttr = NO;\r
220 int FolderAttrNum = 777;\r
221 // 暗号化通信対応\r
222 BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20];\r
223 \r
224 \r
225 \r
226 \r
227 /*----- メインルーチン --------------------------------------------------------\r
228 *\r
229 *       Parameter\r
230 *               HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
231 *               HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
232 *               LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
233 *               int cmdShow : 最初に表示するウインドウの形式。\r
234 *\r
235 *       Return Value\r
236 *               int 最後のメッセージのwParam\r
237 *----------------------------------------------------------------------------*/\r
238 \r
239 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)\r
240 {\r
241     MSG Msg;\r
242         int Ret;\r
243         BOOL Sts;\r
244 \r
245         // プロセス保護\r
246 #ifdef ENABLE_PROCESS_PROTECTION\r
247         DWORD ProtectLevel;\r
248         char* pCommand;\r
249         char Option[FMAX_PATH+1];\r
250         ProtectLevel = PROCESS_PROTECTION_NONE;\r
251         pCommand = lpszCmdLine;\r
252         while(pCommand = GetToken(pCommand, Option))\r
253         {\r
254                 if(strcmp(Option, "--protect") == 0)\r
255                 {\r
256                         ProtectLevel = PROCESS_PROTECTION_DEFAULT;\r
257                         break;\r
258                 }\r
259                 else if(strcmp(Option, "--protect-high") == 0)\r
260                 {\r
261                         ProtectLevel = PROCESS_PROTECTION_HIGH;\r
262                         break;\r
263                 }\r
264                 else if(strcmp(Option, "--protect-medium") == 0)\r
265                 {\r
266                         ProtectLevel = PROCESS_PROTECTION_MEDIUM;\r
267                         break;\r
268                 }\r
269                 else if(strcmp(Option, "--protect-low") == 0)\r
270                 {\r
271                         ProtectLevel = PROCESS_PROTECTION_LOW;\r
272                         break;\r
273                 }\r
274         }\r
275         if(ProtectLevel != PROCESS_PROTECTION_NONE)\r
276         {\r
277                 SetProcessProtectionLevel(ProtectLevel);\r
278                 if(!InitializeLoadLibraryHook())\r
279                 {\r
280                         MessageBox(NULL, MSGJPN321, "FFFTP", MB_OK | MB_ICONERROR);\r
281                         return 0;\r
282                 }\r
283 #ifndef _DEBUG\r
284                 if(IsDebuggerPresent())\r
285                 {\r
286                         MessageBox(NULL, MSGJPN322, "FFFTP", MB_OK | MB_ICONERROR);\r
287                         return 0;\r
288                 }\r
289 #endif\r
290                 if(!UnloadUntrustedModule())\r
291                 {\r
292                         MessageBox(NULL, MSGJPN323, "FFFTP", MB_OK | MB_ICONERROR);\r
293                         return 0;\r
294                 }\r
295 #ifndef _DEBUG\r
296                 if(RestartProtectedProcess(" --restart"))\r
297                         return 0;\r
298 #endif\r
299                 if(!EnableLoadLibraryHook(TRUE))\r
300                 {\r
301                         MessageBox(NULL, MSGJPN324, "FFFTP", MB_OK | MB_ICONERROR);\r
302                         return 0;\r
303                 }\r
304         }\r
305         else\r
306                 InitializeLoadLibraryHook();\r
307 #endif\r
308 \r
309 #ifdef DISABLE_MULTI_CPUS\r
310         SetProcessAffinityMask(GetCurrentProcess(), 1);\r
311 #endif\r
312 \r
313         // yutaka\r
314         if(OleInitialize(NULL) != S_OK){\r
315                 MessageBox(NULL, MSGJPN298, "FFFTP", MB_OK | MB_ICONERROR);\r
316                 return 0;\r
317         }\r
318 \r
319         InitCommonControls();\r
320 \r
321         // FTPS対応\r
322 #ifdef USE_OPENSSL\r
323         LoadOpenSSL();\r
324 #endif\r
325 \r
326         Ret = FALSE;\r
327         hWndFtp = NULL;\r
328         hInstFtp = hInstance;\r
329         if(InitApp(lpszCmdLine, cmdShow) == FFFTP_SUCCESS)\r
330         {\r
331                 for(;;)\r
332                 {\r
333                         Sts = GetMessage(&Msg, NULL, 0, 0);\r
334                         if((Sts == 0) || (Sts == -1))\r
335                                 break;\r
336 \r
337                         if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
338                         { \r
339                                 /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
340                                 /* コンボボックス内ではアクセラレータを無効にする */\r
341                                 if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
342                                    (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
343                                    ((hHelpWin != NULL) && (GetAncestor(Msg.hwnd, GA_ROOT) == hHelpWin)) ||\r
344                                    GetHideUI() == YES ||\r
345                                    (TranslateAccelerator(hWndFtp, Accel, &Msg) == 0))\r
346                                 {\r
347                                         TranslateMessage(&Msg);\r
348                                         DispatchMessage(&Msg);\r
349                                 }\r
350                         }\r
351                 }\r
352                 Ret = Msg.wParam;\r
353         }\r
354     UnregisterClass(FtpClassStr, hInstFtp);\r
355         // FTPS対応\r
356 #ifdef USE_OPENSSL\r
357         FreeOpenSSL();\r
358 #endif\r
359         OleUninitialize();\r
360         return(Ret);\r
361 }\r
362 \r
363 \r
364 /*----- アプリケーションの初期設定 --------------------------------------------\r
365 *\r
366 *       Parameter\r
367 *               HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
368 *               HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
369 *               LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
370 *               int cmdShow : 最初に表示するウインドウの形式。\r
371 *\r
372 *       Return Value\r
373 *               int ステータス\r
374 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
375 *----------------------------------------------------------------------------*/\r
376 \r
377 static int InitApp(LPSTR lpszCmdLine, int cmdShow)\r
378 {\r
379         int sts;\r
380         int Err;\r
381         WSADATA WSAData;\r
382         char PwdBuf[FMAX_PATH+1];\r
383         int useDefautPassword = 0; /* 警告文表示用 */\r
384         int masterpass;\r
385 \r
386         sts = FFFTP_FAIL;\r
387 \r
388         aes_init();\r
389         srand(GetTickCount());\r
390         \r
391         HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie);\r
392 \r
393         SaveUpdateBellInfo();\r
394 \r
395         if((Err = WSAStartup((WORD)0x0202, &WSAData)) != 0)\r
396                 MessageBox(NULL, ReturnWSError(Err), "FFFTP - Startup", MB_OK);\r
397         else\r
398         {\r
399                 Accel = LoadAccelerators(hInstFtp, MAKEINTRESOURCE(ffftp_accel));\r
400 \r
401                 GetTempPath(FMAX_PATH, TmpPath);\r
402 \r
403                 GetModuleFileName(NULL, HelpPath, FMAX_PATH);\r
404                 strcpy(GetFileName(HelpPath), "ffftp.chm");\r
405 \r
406                 if(CheckIniFileName(lpszCmdLine, IniPath) == 0)\r
407                 {\r
408                         GetModuleFileName(NULL, IniPath, FMAX_PATH);\r
409                         strcpy(GetFileName(IniPath), "ffftp.ini");\r
410                 }\r
411                 else\r
412                 {\r
413                         ForceIni = YES;\r
414                         RegType = REGTYPE_INI;\r
415                 }\r
416 \r
417 //              AllocConsole();\r
418 \r
419                 /* 2010.02.01 genta マスターパスワードを入力させる\r
420                   -z オプションがあるときは最初だけスキップ\r
421                   -z オプションがないときは,デフォルトパスワードをまず試す\r
422                   LoadRegistory()する\r
423                   パスワードが不一致なら再入力するか尋ねる.\r
424                   (破損していた場合はさせない)\r
425                 */\r
426                 if( CheckMasterPassword(lpszCmdLine, PwdBuf))\r
427                 {\r
428                         SetMasterPassword( PwdBuf );\r
429                         useDefautPassword = 0;\r
430                 }\r
431                 else {\r
432                         /* パスワード指定無し */\r
433                         SetMasterPassword( NULL );\r
434                         /* この場では表示できないのでフラグだけ立てておく*/\r
435                         useDefautPassword = 2;\r
436                 }\r
437 \r
438                 /* パスワードチェックのみ実施 */\r
439                 masterpass = 1;\r
440                 while( ValidateMasterPassword() == YES &&\r
441                                 GetMasterPasswordStatus() == PASSWORD_UNMATCH ){\r
442                         \r
443                         if( useDefautPassword != 2 ){\r
444                                 /* 再トライするか確認 */\r
445                                 if( MessageBox(NULL, MSGJPN304, "FFFTP", MB_YESNO | MB_ICONEXCLAMATION) == IDNO ){\r
446                                         useDefautPassword = 0; /* 不一致なので,もはやデフォルトかどうかは分からない */\r
447                                         break;\r
448                                 }\r
449                         }\r
450                         \r
451                         /* 再入力させる*/\r
452                         masterpass = EnterMasterPasswordAndSet(masterpasswd_dlg, NULL);\r
453                         if( masterpass == 2 ){\r
454                                 useDefautPassword = 1;\r
455                         }\r
456                         else if( masterpass == 0 ){\r
457                                 SaveExit = NO;\r
458                                 break;\r
459                         }\r
460                         else {\r
461                                 useDefautPassword = 0;\r
462                         }\r
463                 }\r
464                 \r
465                 if(masterpass != 0)\r
466                 {\r
467                         LoadRegistory();\r
468 \r
469                         // 暗号化通信対応\r
470                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
471                         SetSSLConfirmCallback(SSLConfirmCallback);\r
472 \r
473                         LoadJre();\r
474                         if(NoRasControl == NO)\r
475                                 LoadRasLib();\r
476                         LoadKernelLib();\r
477 \r
478                         //タイマの精度を改善\r
479                         timeBeginPeriod(1);\r
480 \r
481                         CountPrevFfftpWindows();\r
482 \r
483                         if(MakeAllWindows(cmdShow) == FFFTP_SUCCESS)\r
484                         {\r
485                                 hWndCurFocus = GetLocalHwnd();\r
486 \r
487                                 if(strlen(DefaultLocalPath) > 0)\r
488                                         SetCurrentDirectory(DefaultLocalPath);\r
489 \r
490                                 SetSortTypeImm(LocalFileSort, LocalDirSort, RemoteFileSort, RemoteDirSort);\r
491                                 SetTransferTypeImm(TransMode);\r
492                                 DispTransferType();\r
493                                 SetHostKanaCnvImm(YES);\r
494                                 SetHostKanjiCodeImm(KANJI_NOCNV);\r
495                                 // 本当はローカルのデフォルトをUTF-8にしたいが旧バージョンとの互換性のためShift_JISに設定\r
496 //                              SetLocalKanjiCodeImm(KANJI_UTF8N);\r
497                                 SetLocalKanjiCodeImm(KANJI_SJIS);\r
498                                 DispListType();\r
499                                 DispDotFileMode();\r
500                                 DispSyncMoveMode();\r
501 \r
502                                 MakeCacheBuf(CacheEntry);\r
503                                 if(CacheSave == YES)\r
504                                         LoadCache();\r
505 \r
506                                 if(MakeTransferThread() == FFFTP_SUCCESS)\r
507                                 {\r
508                                         DoPrintf("DEBUG MESSAGE ON ! ##");\r
509 \r
510                                         DispWindowTitle();\r
511                                         // SourceForge.JPによるフォーク\r
512 //                                      SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.");\r
513                                         SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto, IWAMOTO Kouichi, vitamin0x, unarist, Asami, fortran90, tomo1192).");\r
514 \r
515                                         if(ForceIni)\r
516                                                 SetTaskMsg("%s%s", MSGJPN283, IniPath);\r
517 \r
518                                         if(IsFolderExist(TmpPath) == NO)\r
519                                         {\r
520                                                 SetTaskMsg(MSGJPN152, TmpPath);\r
521                                                 GetTempPath(FMAX_PATH, TmpPath);\r
522                                                 SetTaskMsg(MSGJPN153, TmpPath);\r
523                                         }\r
524 \r
525                                         DoPrintf("Tmp =%s", TmpPath);\r
526                                         DoPrintf("Help=%s", HelpPath);\r
527 \r
528                                         DragAcceptFiles(GetRemoteHwnd(), TRUE);\r
529                                         DragAcceptFiles(GetLocalHwnd(), TRUE);\r
530 \r
531                                         SetAllHistoryToMenu();\r
532                                         GetLocalDirForWnd();\r
533                                         MakeButtonsFocus();\r
534                                         DispTransferFiles();\r
535 \r
536                                         StartupProc(lpszCmdLine);\r
537                                         sts = FFFTP_SUCCESS;\r
538 \r
539                                         /* セキュリティ警告文の表示 */\r
540                                         if( useDefautPassword ){\r
541                                                 SetTaskMsg(MSGJPN300);\r
542                                         }\r
543                                         \r
544                                         /* パスワード不一致警告文の表示 */\r
545                                         switch( GetMasterPasswordStatus() ){\r
546                                         case PASSWORD_UNMATCH:\r
547                                                 SetTaskMsg(MSGJPN301);\r
548                                                 break;\r
549                                         case BAD_PASSWORD_HASH:\r
550                                                 SetTaskMsg(MSGJPN302);\r
551                                                 break;\r
552                                         default:\r
553                                                 break;\r
554                                         }\r
555                                 }\r
556                         }\r
557                 }\r
558         }\r
559 \r
560         // 暗号化通信対応\r
561 #ifdef USE_OPENSSL\r
562         if(IsOpenSSLLoaded())\r
563                 SetTaskMsg(MSGJPN318);\r
564         else\r
565                 SetTaskMsg(MSGJPN319);\r
566 #endif\r
567 \r
568         if(sts == FFFTP_FAIL)\r
569                 DeleteAllObject();\r
570 \r
571         return(sts);\r
572 }\r
573 \r
574 \r
575 /*----- ウインドウを作成する --------------------------------------------------\r
576 *\r
577 *       Parameter\r
578 *               int cmdShow : 最初に表示するウインドウの形式。\r
579 *\r
580 *       Return Value\r
581 *               int ステータス\r
582 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
583 *----------------------------------------------------------------------------*/\r
584 \r
585 static int MakeAllWindows(int cmdShow)\r
586 {\r
587         RECT Rect1;\r
588         RECT Rect2;\r
589         WNDCLASSEX wClass;\r
590         int Sts;\r
591         int StsTask;\r
592         int StsSbar;\r
593         int StsTbar;\r
594         int StsList;\r
595         int StsLvtips;\r
596         int StsSocket;\r
597 \r
598         /*===== メインウインドウ =====*/\r
599 \r
600         RootColorBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));\r
601 \r
602         wClass.cbSize = sizeof(WNDCLASSEX);\r
603         wClass.style         = 0;\r
604         wClass.lpfnWndProc   = FtpWndProc;\r
605         wClass.cbClsExtra    = 0;\r
606         wClass.cbWndExtra    = 0;\r
607         wClass.hInstance     = hInstFtp;\r
608         wClass.hIcon         = LoadIcon(hInstFtp, MAKEINTRESOURCE(ffftp));\r
609         wClass.hCursor       = NULL;\r
610         wClass.hbrBackground = RootColorBrush;\r
611         wClass.lpszMenuName  = (LPSTR)MAKEINTRESOURCE(main_menu);\r
612         wClass.lpszClassName = FtpClassStr;\r
613         wClass.hIconSm       = NULL;\r
614         RegisterClassEx(&wClass);\r
615 \r
616         if(SaveWinPos == NO)\r
617         {\r
618                 WinPosX = CW_USEDEFAULT;\r
619                 WinPosY = 0;\r
620         }\r
621         // UTF-8対応\r
622         // ユーザー定義のクラスはデフォルトのWNDPROCがShift_JIS専用のため\r
623 //      hWndFtp = CreateWindow(FtpClassStr, "FFFTP",\r
624 //                              WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,\r
625 //                              WinPosX, WinPosY, WinWidth, WinHeight,\r
626 //                              HWND_DESKTOP, 0, hInstFtp, NULL);\r
627         hWndFtp = CreateWindowA(FtpClassStr, "FFFTP",\r
628                                 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,\r
629                                 WinPosX, WinPosY, WinWidth, WinHeight,\r
630                                 HWND_DESKTOP, 0, hInstFtp, NULL);\r
631 \r
632         if(hWndFtp != NULL)\r
633         {\r
634                 SystemParametersInfo(SPI_GETWORKAREA, 0, &Rect1, 0);\r
635                 GetWindowRect(hWndFtp, &Rect2);\r
636                 if(Rect2.bottom > Rect1.bottom)\r
637                 {\r
638                         Rect2.top = max1(0, Rect2.top - (Rect2.bottom - Rect1.bottom));\r
639                         MoveWindow(hWndFtp, Rect2.left, Rect2.top, WinWidth, WinHeight, FALSE);\r
640                 }\r
641 \r
642                 /*===== ステイタスバー =====*/\r
643 \r
644                 StsSbar = MakeStatusBarWindow(hWndFtp, hInstFtp);\r
645 \r
646                 CalcWinSize();\r
647 \r
648                 /*===== ツールバー =====*/\r
649 \r
650                 StsTbar = MakeToolBarWindow(hWndFtp, hInstFtp);\r
651 \r
652                 /*===== ファイルリストウインドウ =====*/\r
653 \r
654                 StsList = MakeListWin(hWndFtp, hInstFtp);\r
655 \r
656                 /*==== タスクウインドウ ====*/\r
657 \r
658                 StsTask = MakeTaskWindow(hWndFtp, hInstFtp);\r
659 \r
660                 if((cmdShow != SW_MINIMIZE) && (cmdShow != SW_SHOWMINIMIZED) && (cmdShow != SW_SHOWMINNOACTIVE) &&\r
661                    (Sizing == SW_MAXIMIZE))\r
662                         cmdShow = SW_MAXIMIZE;\r
663 \r
664                 ShowWindow(hWndFtp, cmdShow);\r
665 \r
666                 /*==== ソケットウインドウ ====*/\r
667 \r
668                 StsSocket = MakeSocketWin(hWndFtp, hInstFtp);\r
669 \r
670                 StsLvtips = InitListViewTips(hWndFtp, hInstFtp);\r
671         }\r
672 \r
673         Sts = FFFTP_SUCCESS;\r
674         if((hWndFtp == NULL) ||\r
675            (StsTbar == FFFTP_FAIL) ||\r
676            (StsList == FFFTP_FAIL) ||\r
677            (StsSbar == FFFTP_FAIL) ||\r
678            (StsTask == FFFTP_FAIL) ||\r
679            (StsLvtips == FFFTP_FAIL) ||\r
680            (StsSocket == FFFTP_FAIL))\r
681         {\r
682                 Sts = FFFTP_FAIL;\r
683         }\r
684 \r
685         if(Sts == FFFTP_SUCCESS)\r
686                 SetListViewType();\r
687 \r
688         return(Sts);\r
689 }\r
690 \r
691 \r
692 /*----- ウインドウのタイトルを表示する ----------------------------------------\r
693 *\r
694 *       Parameter\r
695 *               なし\r
696 *\r
697 *       Return Value\r
698 *               なし\r
699 *----------------------------------------------------------------------------*/\r
700 \r
701 void DispWindowTitle(void)\r
702 {\r
703         char Tmp[HOST_ADRS_LEN+FILTER_EXT_LEN+20];\r
704 \r
705         if(AskConnecting() == YES)\r
706                 sprintf(Tmp, "%s (%s) - FFFTP", TitleHostName, FilterStr);\r
707         else\r
708                 sprintf(Tmp, "FFFTP (%s)", FilterStr);\r
709 \r
710         SetWindowText(GetMainHwnd(), Tmp);\r
711         return;\r
712 }\r
713 \r
714 \r
715 /*----- 全てのオブジェクトを削除 ----------------------------------------------\r
716 *\r
717 *       Parameter\r
718 *               なし\r
719 *\r
720 *       Return Value\r
721 *               なし\r
722 *----------------------------------------------------------------------------*/\r
723 \r
724 static void DeleteAllObject(void)\r
725 {\r
726         DeleteCacheBuf();\r
727 \r
728 //move to WM_DESTROY\r
729         WSACleanup();\r
730 \r
731 //test システム任せ\r
732 //      if(ListFont != NULL)\r
733 //              DeleteObject(ListFont);\r
734 //      if(RootColorBrush != NULL)\r
735 //              DeleteObject(RootColorBrush);\r
736 \r
737 //test システム任せ\r
738 //      DeleteListViewTips();\r
739 //      DeleteListWin();\r
740 //      DeleteStatusBarWindow();\r
741 //      DeleteTaskWindow();\r
742 //      DeleteToolBarWindow();\r
743 //      DeleteSocketWin();\r
744 \r
745 //move to WM_DESTROY\r
746         if(hWndFtp != NULL)\r
747                 DestroyWindow(hWndFtp);\r
748 \r
749         ReleaseJre();\r
750         ReleaseRasLib();\r
751         ReleaseKernelLib();\r
752 \r
753         return;\r
754 }\r
755 \r
756 \r
757 /*----- メインウインドウのウインドウハンドルを返す ----------------------------\r
758 *\r
759 *       Parameter\r
760 *               なし\r
761 *\r
762 *       Return Value\r
763 *               HWND ウインドウハンドル\r
764 *----------------------------------------------------------------------------*/\r
765 \r
766 HWND GetMainHwnd(void)\r
767 {\r
768         return(hWndFtp);\r
769 }\r
770 \r
771 \r
772 /*----- 現在フォーカスがあるウインドウのウインドウハンドルを返す --------------\r
773 *\r
774 *       Parameter\r
775 *               なし\r
776 *\r
777 *       Return Value\r
778 *               HWND ウインドウハンドル\r
779 *----------------------------------------------------------------------------*/\r
780 \r
781 HWND GetFocusHwnd(void)\r
782 {\r
783         return(hWndCurFocus);\r
784 }\r
785 \r
786 \r
787 /*----- 現在フォーカスがあるウインドウのをセットする --------------------------\r
788 *\r
789 *       Parameter\r
790 *               HWND hWnd : ウインドウハンドル\r
791 *\r
792 *       Return Value\r
793 *               なし\r
794 *----------------------------------------------------------------------------*/\r
795 \r
796 void SetFocusHwnd(HWND hWnd)\r
797 {\r
798         hWndCurFocus = hWnd;\r
799         return;\r
800 }\r
801 \r
802 \r
803 /*----- プログラムのインスタンスを返す ----------------------------------------\r
804 *\r
805 *       Parameter\r
806 *               なし\r
807 *\r
808 *       Return Value\r
809 *               HINSTANCE インスタンス\r
810 *----------------------------------------------------------------------------*/\r
811 \r
812 HINSTANCE GetFtpInst(void)\r
813 {\r
814         return(hInstFtp);\r
815 }\r
816 \r
817 \r
818 /*----- メインウインドウのメッセージ処理 --------------------------------------\r
819 *\r
820 *       Parameter\r
821 *               HWND hWnd : ウインドウハンドル\r
822 *               UINT message  : メッセージ番号\r
823 *               WPARAM wParam : メッセージの WPARAM 引数\r
824 *               LPARAM lParam : メッセージの LPARAM 引数\r
825 *\r
826 *       Return Value\r
827 *               メッセージに対応する戻り値\r
828 *----------------------------------------------------------------------------*/\r
829 \r
830 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
831 {\r
832         PAINTSTRUCT ps;\r
833         LPTOOLTIPTEXT lpttt;\r
834         RECT Rect;\r
835 \r
836         int TmpTransType;\r
837 \r
838         switch (message)\r
839         {\r
840                 case WM_COMMAND :\r
841                         // 同時接続対応\r
842                         // 中断後に受信バッファに応答が残っていると次のコマンドの応答が正しく処理できない\r
843                         if(CancelFlg == YES)\r
844                                 RemoveReceivedData(AskCmdCtrlSkt());\r
845                         switch(LOWORD(wParam))\r
846                         {\r
847                                 case MENU_CONNECT :\r
848                                         ConnectProc(DLG_TYPE_CON, -1);\r
849                                         break;\r
850 \r
851                                 case MENU_CONNECT_NUM :\r
852                                         ConnectProc(DLG_TYPE_CON, (int)lParam);\r
853                                         if(AskConnecting() == YES)\r
854                                         {\r
855                                                 if(HIWORD(wParam) & OPT_MIRROR)\r
856                                                 {\r
857                                                         if(HIWORD(wParam) & OPT_FORCE)\r
858                                                                 MirrorUploadProc(NO);\r
859                                                         else\r
860                                                                 MirrorUploadProc(YES);\r
861                                                 }\r
862                                                 else if(HIWORD(wParam) & OPT_MIRRORDOWN)\r
863                                                 {\r
864                                                         if(HIWORD(wParam) & OPT_FORCE)\r
865                                                                 MirrorDownloadProc(NO);\r
866                                                         else\r
867                                                                 MirrorDownloadProc(YES);\r
868                                                 }\r
869                                         }\r
870                                         break;\r
871 \r
872                                 case MENU_SET_CONNECT :\r
873                                         ConnectProc(DLG_TYPE_SET, -1);\r
874                                         break;\r
875 \r
876                                 case MENU_QUICK :\r
877                                         QuickConnectProc();\r
878                                         break;\r
879 \r
880                                 case MENU_DISCONNECT :\r
881                                         if(AskTryingConnect() == YES)\r
882                                                 CancelFlg = YES;\r
883                                         else if(AskConnecting() == YES)\r
884                                         {\r
885                                                 SaveBookMark();\r
886                                                 SaveCurrentSetToHost();\r
887                                                 DisconnectProc();\r
888                                         }\r
889                                         break;\r
890 \r
891                                 case MENU_HIST_1 :\r
892                                 case MENU_HIST_2 :\r
893                                 case MENU_HIST_3 :\r
894                                 case MENU_HIST_4 :\r
895                                 case MENU_HIST_5 :\r
896                                 case MENU_HIST_6 :\r
897                                 case MENU_HIST_7 :\r
898                                 case MENU_HIST_8 :\r
899                                 case MENU_HIST_9 :\r
900                                 case MENU_HIST_10 :\r
901                                 case MENU_HIST_11 :\r
902                                 case MENU_HIST_12 :\r
903                                 case MENU_HIST_13 :\r
904                                 case MENU_HIST_14 :\r
905                                 case MENU_HIST_15 :\r
906                                 case MENU_HIST_16 :\r
907                                 case MENU_HIST_17 :\r
908                                 case MENU_HIST_18 :\r
909                                 case MENU_HIST_19 :\r
910                                 case MENU_HIST_20 :\r
911                                         HistoryConnectProc(LOWORD(wParam));\r
912                                         break;\r
913 \r
914                                 case MENU_UPDIR :\r
915                                         if(hWndCurFocus == GetLocalHwnd())\r
916                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_LOCAL_UPDIR, 0), 0);\r
917                                         else\r
918                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_REMOTE_UPDIR, 0), 0);\r
919                                         break;\r
920 \r
921                                 case MENU_DCLICK :\r
922                                         if(hWndCurFocus == GetLocalHwnd())\r
923                                                 DoubleClickProc(WIN_LOCAL, YES, -1);\r
924                                         else\r
925                                         {\r
926                                                 SuppressRefresh = 1;\r
927                                                 DoubleClickProc(WIN_REMOTE, YES, -1);\r
928                                                 SuppressRefresh = 0;\r
929                                         }\r
930                                         break;\r
931 \r
932                                 case MENU_OPEN1 :\r
933                                         if(hWndCurFocus == GetLocalHwnd())\r
934                                                 DoubleClickProc(WIN_LOCAL, YES, 0);\r
935                                         else\r
936                                         {\r
937                                                 SuppressRefresh = 1;\r
938                                                 DoubleClickProc(WIN_REMOTE, YES, 0);\r
939                                                 SuppressRefresh = 0;\r
940                                         }\r
941                                         break;\r
942 \r
943                                 case MENU_OPEN2 :\r
944                                         if(hWndCurFocus == GetLocalHwnd())\r
945                                                 DoubleClickProc(WIN_LOCAL, YES, 1);\r
946                                         else\r
947                                         {\r
948                                                 SuppressRefresh = 1;\r
949                                                 DoubleClickProc(WIN_REMOTE, YES, 1);\r
950                                                 SuppressRefresh = 0;\r
951                                         }\r
952                                         break;\r
953 \r
954                                 case MENU_OPEN3 :\r
955                                         if(hWndCurFocus == GetLocalHwnd())\r
956                                                 DoubleClickProc(WIN_LOCAL, YES, 2);\r
957                                         else\r
958                                         {\r
959                                                 SuppressRefresh = 1;\r
960                                                 DoubleClickProc(WIN_REMOTE, YES, 2);\r
961                                                 SuppressRefresh = 0;\r
962                                         }\r
963                                         break;\r
964 \r
965                                 case MENU_REMOTE_UPDIR :\r
966                                         SuppressRefresh = 1;\r
967                                         SetCurrentDirAsDirHist();\r
968                                         ChangeDir(WIN_REMOTE, "..");\r
969                                         SuppressRefresh = 0;\r
970                                         break;\r
971 \r
972                                 case MENU_LOCAL_UPDIR :\r
973                                         SetCurrentDirAsDirHist();\r
974                                         ChangeDir(WIN_LOCAL, "..");\r
975                                         break;\r
976 \r
977                                 case MENU_REMOTE_CHDIR :\r
978                                         SuppressRefresh = 1;\r
979                                         SetCurrentDirAsDirHist();\r
980                                         ChangeDirDirectProc(WIN_REMOTE);\r
981                                         SuppressRefresh = 0;\r
982                                         break;\r
983 \r
984                                 case MENU_LOCAL_CHDIR :\r
985                                         SetCurrentDirAsDirHist();\r
986                                         ChangeDirDirectProc(WIN_LOCAL);\r
987                                         break;\r
988 \r
989                                 case MENU_DOWNLOAD :\r
990                                         SetCurrentDirAsDirHist();\r
991                                         DownLoadProc(NO, NO, NO);\r
992                                         break;\r
993 \r
994                                 case MENU_DOWNLOAD_AS :\r
995                                         SetCurrentDirAsDirHist();\r
996                                         DownLoadProc(YES, NO, NO);\r
997                                         break;\r
998 \r
999                                 case MENU_DOWNLOAD_AS_FILE :\r
1000                                         SetCurrentDirAsDirHist();\r
1001                                         DownLoadProc(NO, YES, NO);\r
1002                                         break;\r
1003 \r
1004                                 case MENU_DOWNLOAD_ALL :\r
1005                                         SetCurrentDirAsDirHist();\r
1006                                         DownLoadProc(NO, NO, YES);\r
1007                                         break;\r
1008 \r
1009                                 case MENU_DOWNLOAD_NAME :\r
1010                                         SetCurrentDirAsDirHist();\r
1011                                         InputDownLoadProc();\r
1012                                         break;\r
1013 \r
1014                                 case MENU_UPLOAD :\r
1015                                         SetCurrentDirAsDirHist();\r
1016                                         UpLoadListProc(NO, NO);\r
1017                                         break;\r
1018 \r
1019                                 case MENU_UPLOAD_AS :\r
1020                                         SetCurrentDirAsDirHist();\r
1021                                         UpLoadListProc(YES, NO);\r
1022                                         break;\r
1023 \r
1024                                 case MENU_UPLOAD_ALL :\r
1025                                         SetCurrentDirAsDirHist();\r
1026                                         UpLoadListProc(NO, YES);\r
1027                                         break;\r
1028 \r
1029                                 case MENU_MIRROR_UPLOAD :\r
1030                                         SetCurrentDirAsDirHist();\r
1031                                         MirrorUploadProc(YES);\r
1032                                         break;\r
1033 \r
1034                                 case MENU_MIRROR_DOWNLOAD :\r
1035                                         SetCurrentDirAsDirHist();\r
1036                                         MirrorDownloadProc(YES);\r
1037                                         break;\r
1038 \r
1039                                 case MENU_FILESIZE :\r
1040                                         SetCurrentDirAsDirHist();\r
1041                                         CalcFileSizeProc();\r
1042                                         break;\r
1043 \r
1044                                 case MENU_DELETE :\r
1045                                         SuppressRefresh = 1;\r
1046                                         SetCurrentDirAsDirHist();\r
1047                                         DeleteProc();\r
1048                                         SuppressRefresh = 0;\r
1049                                         break;\r
1050 \r
1051                                 case MENU_RENAME :\r
1052                                         SuppressRefresh = 1;\r
1053                                         SetCurrentDirAsDirHist();\r
1054                                         RenameProc();\r
1055                                         SuppressRefresh = 0;\r
1056                                         break;\r
1057 \r
1058                                 case MENU_MKDIR :\r
1059                                         SuppressRefresh = 1;\r
1060                                         SetCurrentDirAsDirHist();\r
1061                                         MkdirProc();\r
1062                                         SuppressRefresh = 0;\r
1063                                         break;\r
1064 \r
1065                                 case MENU_CHMOD :\r
1066                                         SuppressRefresh = 1;\r
1067                                         ChmodProc();\r
1068                                         SuppressRefresh = 0;\r
1069                                         break;\r
1070 \r
1071                                 case MENU_SOMECMD :\r
1072                                         SuppressRefresh = 1;\r
1073                                         SomeCmdProc();\r
1074                                         SuppressRefresh = 0;\r
1075                                         break;\r
1076 \r
1077                                 case MENU_OPTION :\r
1078                                         SetOption(0);\r
1079                                         if(ListFont != NULL)\r
1080                                         {\r
1081                                                 SendMessage(GetLocalHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1082                                                 SendMessage(GetRemoteHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1083                                                 SendMessage(GetTaskWnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1084                                         }\r
1085                                         GetLocalDirForWnd();\r
1086                                         DispTransferType();\r
1087                                         CheckHistoryNum(0);\r
1088                                         SetAllHistoryToMenu();\r
1089                                         // 暗号化通信対応\r
1090                                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
1091                                         break;\r
1092 \r
1093                                 case MENU_FILTER :\r
1094                                         // 同時接続対応\r
1095                                         CancelFlg = NO;\r
1096                                         SetFilter(&CancelFlg);\r
1097                                         break;\r
1098 \r
1099                                 case MENU_SORT :\r
1100                                         if(SortSetting() == YES)\r
1101                                         {\r
1102                                                 // 同時接続対応\r
1103                                                 CancelFlg = NO;\r
1104                                                 LocalFileSort = AskSortType(ITEM_LFILE);\r
1105                                                 LocalDirSort = AskSortType(ITEM_LDIR);\r
1106                                                 RemoteFileSort = AskSortType(ITEM_RFILE);\r
1107                                                 RemoteDirSort = AskSortType(ITEM_RDIR);\r
1108                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1109                                                 ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1110                                         }\r
1111                                         break;\r
1112 \r
1113                                 case MENU_EXIT :\r
1114                                         PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1115                                         break;\r
1116 \r
1117                                 case MENU_AUTO_EXIT :\r
1118                                         if(AutoExit == YES)\r
1119                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1120                                         break;\r
1121 \r
1122                                 case MENU_ABOUT :\r
1123                                         DialogBox(hInstFtp, MAKEINTRESOURCE(about_dlg), hWnd, AboutDialogProc);\r
1124                                         break;\r
1125 \r
1126                                 case MENU_TEXT :\r
1127                                 case MENU_BINARY :\r
1128                                 case MENU_AUTO :\r
1129                                         SetTransferType(LOWORD(wParam));\r
1130                                         DispTransferType();\r
1131                                         break;\r
1132 \r
1133                                 case MENU_XFRMODE :\r
1134                                         switch(AskTransferType())\r
1135                                         {\r
1136                                                 case TYPE_A :\r
1137                                                         TmpTransType = MENU_BINARY;\r
1138                                                         break;\r
1139 \r
1140                                                 case TYPE_I :\r
1141                                                         TmpTransType = MENU_AUTO;\r
1142                                                         break;\r
1143 \r
1144                                                 default :\r
1145                                                         TmpTransType = MENU_TEXT;\r
1146                                                         break;\r
1147                                         }\r
1148                                         SetTransferType(TmpTransType);\r
1149                                         DispTransferType();\r
1150                                         break;\r
1151 \r
1152                                 // UTF-8対応\r
1153                                 case MENU_KNJ_SJIS :\r
1154                                 case MENU_KNJ_EUC :\r
1155                                 case MENU_KNJ_JIS :\r
1156                                 case MENU_KNJ_UTF8N :\r
1157                                 case MENU_KNJ_UTF8BOM :\r
1158                                 case MENU_KNJ_NONE :\r
1159                                         SetHostKanjiCode(LOWORD(wParam));\r
1160                                         break;\r
1161 \r
1162                                 case MENU_L_KNJ_SJIS :\r
1163                                 case MENU_L_KNJ_EUC :\r
1164                                 case MENU_L_KNJ_JIS :\r
1165                                 case MENU_L_KNJ_UTF8N :\r
1166                                 case MENU_L_KNJ_UTF8BOM :\r
1167                                         SetLocalKanjiCode(LOWORD(wParam));\r
1168                                         break;\r
1169 \r
1170                                 case MENU_KANACNV :\r
1171                                         SetHostKanaCnv();\r
1172                                         break;\r
1173 \r
1174                                 case MENU_REFRESH :\r
1175                                         // 同時接続対応\r
1176                                         CancelFlg = NO;\r
1177                                         SuppressRefresh = 1;\r
1178                                         GetLocalDirForWnd();\r
1179                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1180                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1181                                         SuppressRefresh = 0;\r
1182                                         break;\r
1183 \r
1184                                 case MENU_LIST :\r
1185                                         ListType = LVS_LIST;\r
1186                                         DispListType();\r
1187                                         SetListViewType();\r
1188                                         break;\r
1189 \r
1190                                 case MENU_REPORT :\r
1191                                         ListType = LVS_REPORT;\r
1192                                         DispListType();\r
1193                                         SetListViewType();\r
1194                                         break;\r
1195 \r
1196                                 case REFRESH_LOCAL :\r
1197                                         GetLocalDirForWnd();\r
1198                                         break;\r
1199 \r
1200                                 case REFRESH_REMOTE :\r
1201                                         // 同時接続対応\r
1202                                         CancelFlg = NO;\r
1203                                         SuppressRefresh = 1;\r
1204                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1205                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1206                                         SuppressRefresh = 0;\r
1207                                         break;\r
1208 \r
1209                                 case COMBO_LOCAL :\r
1210                                 case COMBO_REMOTE :\r
1211                                         SuppressRefresh = 1;\r
1212                                         if(HIWORD(wParam) == CBN_SELCHANGE)\r
1213                                         {\r
1214                                                 SetCurrentDirAsDirHist();\r
1215                                                 ChangeDirComboProc((HWND)lParam);\r
1216                                         }\r
1217                                         else if(HIWORD(wParam) != CBN_CLOSEUP)\r
1218                                         {\r
1219                                                 MakeButtonsFocus();\r
1220                                                 SuppressRefresh = 0;\r
1221                                                 return(0);\r
1222                                         }\r
1223                                         SuppressRefresh = 0;\r
1224                                         break;\r
1225 \r
1226                                 case MENU_HELP :\r
1227                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000001);\r
1228                                         break;\r
1229 \r
1230                                 case MENU_HELP_TROUBLE :\r
1231                                         // 任意のコードが実行されるバグ修正\r
1232 //                                      ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW);\r
1233                                         ShellExecute(NULL, "open", MYWEB_URL, NULL, NULL, SW_SHOW);\r
1234                                         break;\r
1235 \r
1236                                 case MENU_BMARK_ADD :\r
1237                                         AddCurDirToBookMark(WIN_REMOTE);\r
1238                                         break;\r
1239 \r
1240                                 case MENU_BMARK_ADD_LOCAL :\r
1241                                         AddCurDirToBookMark(WIN_LOCAL);\r
1242                                         break;\r
1243 \r
1244                                 case MENU_BMARK_ADD_BOTH :\r
1245                                         AddCurDirToBookMark(WIN_BOTH);\r
1246                                         break;\r
1247 \r
1248                                 case MENU_BMARK_EDIT :\r
1249                                         EditBookMark();\r
1250                                         break;\r
1251 \r
1252                                 case MENU_SELECT_ALL :\r
1253                                         SelectFileInList(hWndCurFocus, SELECT_ALL);\r
1254                                         break;\r
1255 \r
1256                                 case MENU_SELECT :\r
1257                                         SelectFileInList(hWndCurFocus, SELECT_REGEXP);\r
1258                                         break;\r
1259 \r
1260                                 case MENU_FIND :\r
1261                                         FindFileInList(hWndCurFocus, FIND_FIRST);\r
1262                                         break;\r
1263 \r
1264                                 case MENU_FINDNEXT :\r
1265                                         FindFileInList(hWndCurFocus, FIND_NEXT);\r
1266                                         break;\r
1267 \r
1268                                 case MENU_DOTFILE :\r
1269                                         // 同時接続対応\r
1270                                         CancelFlg = NO;\r
1271                                         DotFile ^= 1;\r
1272                                         DispDotFileMode();\r
1273                                         GetLocalDirForWnd();\r
1274                                         GetRemoteDirForWnd(CACHE_LASTREAD, &CancelFlg);\r
1275                                         break;\r
1276 \r
1277                                 case MENU_SYNC :\r
1278                                         ToggleSyncMoveMode();\r
1279                                         break;\r
1280 \r
1281                                 case MENU_IMPORT_WS :\r
1282                                         ImportFromWSFTP();\r
1283                                         break;\r
1284 \r
1285                                 case MENU_REGSAVE :\r
1286                                         GetListTabWidth();\r
1287                                         SaveRegistory();\r
1288                                         SaveSettingsToFile();\r
1289                                         break;\r
1290 \r
1291                                 case MENU_REGLOAD :\r
1292                                         if(LoadSettingsFromFile() == YES)\r
1293                                         {\r
1294                                                 MessageBox(hWnd, MSGJPN292, "FFFTP", MB_OK);\r
1295                                                 SaveExit = NO;\r
1296                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1297                                         }\r
1298                                         break;\r
1299 \r
1300                                 case MENU_REGINIT :\r
1301                                         if(DialogBox(hInstFtp, MAKEINTRESOURCE(reginit_dlg), hWnd, ExeEscDialogProc) == YES)\r
1302                                         {\r
1303                                                 ClearRegistory();\r
1304                                                 SaveExit = NO;\r
1305                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1306                                         }\r
1307                                         break;\r
1308                                 case MENU_CHANGEPASSWD: /* 2010.01.31 genta */\r
1309                                         if( GetMasterPasswordStatus() != PASSWORD_OK )\r
1310                                         {\r
1311                                                 /* 強制的に設定するか確認 */\r
1312                                                 if( DialogBox(hInstFtp, MAKEINTRESOURCE(forcepasschange_dlg), hWnd, ExeEscDialogProc) != YES){\r
1313                                                         break;\r
1314                                                 }\r
1315                                         }\r
1316                                         if( EnterMasterPasswordAndSet( newmasterpasswd_dlg, hWnd ) != 0 ){\r
1317                                                 SetTaskMsg( MSGJPN303 );\r
1318                                         }\r
1319                                         break;\r
1320 \r
1321                                 case MENU_DIRINFO :\r
1322                                         DispDirInfo();\r
1323                                         break;\r
1324 \r
1325                                 case MENU_TASKINFO :\r
1326                                         DispTaskMsg();\r
1327                                         break;\r
1328 \r
1329                                 case MENU_ABORT :\r
1330                                         CancelFlg = YES;\r
1331                                         if(AskTryingConnect() == NO)\r
1332                                                 MainTransPkt.Abort = ABORT_USER;\r
1333                                         break;\r
1334 \r
1335                                 case MENU_OTPCALC :\r
1336                                         OtpCalcTool();\r
1337                                         break;\r
1338 \r
1339                                 case MENU_URL_COPY :\r
1340                                         CopyURLtoClipBoard();\r
1341                                         break;\r
1342 \r
1343                                 case MENU_APPKEY :\r
1344                                         EraseListViewTips();\r
1345                                         if(hWndCurFocus == GetRemoteHwnd())\r
1346                                                 RemoteRbuttonMenu(1);\r
1347                                         else if(hWndCurFocus == GetLocalHwnd())\r
1348                                                 LocalRbuttonMenu(1);\r
1349                                         break;\r
1350 \r
1351                                 default :\r
1352                                         if((LOWORD(wParam) >= MENU_BMARK_TOP) &&\r
1353                                            (LOWORD(wParam) < MENU_BMARK_TOP+100))\r
1354                                         {\r
1355                                                 ChangeDirBmarkProc(LOWORD(wParam));\r
1356                                         }\r
1357                                         break;\r
1358                         }\r
1359 // 常にホストかローカルへフォーカスを移動\r
1360 //                      SetFocus(hWndCurFocus);\r
1361                         MakeButtonsFocus();\r
1362                         break;\r
1363 \r
1364                 case WM_NOTIFY :\r
1365                         switch(((LPNMHDR)lParam)->code)\r
1366                         {\r
1367                                 /* ツールチップコントロールメッセージの処理 */\r
1368                                 case TTN_NEEDTEXT:\r
1369                                         lpttt = (LPTOOLTIPTEXT)lParam;\r
1370                                         lpttt->hinst = hInstFtp;\r
1371                                         switch(lpttt->hdr.idFrom)\r
1372                                         {\r
1373                                                 case MENU_CONNECT :\r
1374                                                         lpttt->lpszText = MSGJPN154;\r
1375                                                         break;\r
1376 \r
1377                                                 case MENU_QUICK :\r
1378                                                         lpttt->lpszText = MSGJPN155;\r
1379                                                         break;\r
1380 \r
1381                                                 case MENU_DISCONNECT :\r
1382                                                         lpttt->lpszText = MSGJPN156;\r
1383                                                         break;\r
1384 \r
1385                                                 case MENU_DOWNLOAD :\r
1386                                                         lpttt->lpszText = MSGJPN157;\r
1387                                                         break;\r
1388 \r
1389                                                 case MENU_UPLOAD :\r
1390                                                         lpttt->lpszText = MSGJPN158;\r
1391                                                         break;\r
1392 \r
1393                                                 case MENU_MIRROR_UPLOAD :\r
1394                                                         lpttt->lpszText = MSGJPN159;\r
1395                                                         break;\r
1396 \r
1397                                                 case MENU_DELETE :\r
1398                                                         lpttt->lpszText = MSGJPN160;\r
1399                                                         break;\r
1400 \r
1401                                                 case MENU_RENAME :\r
1402                                                         lpttt->lpszText = MSGJPN161;\r
1403                                                         break;\r
1404 \r
1405                                                 case MENU_MKDIR :\r
1406                                                         lpttt->lpszText = MSGJPN162;\r
1407                                                         break;\r
1408 \r
1409                                                 case MENU_LOCAL_UPDIR :\r
1410                                                 case MENU_REMOTE_UPDIR :\r
1411                                                         lpttt->lpszText = MSGJPN163;\r
1412                                                         break;\r
1413 \r
1414                                                 case MENU_LOCAL_CHDIR :\r
1415                                                 case MENU_REMOTE_CHDIR :\r
1416                                                         lpttt->lpszText = MSGJPN164;\r
1417                                                         break;\r
1418 \r
1419                                                 case MENU_TEXT :\r
1420                                                         lpttt->lpszText = MSGJPN165;\r
1421                                                         break;\r
1422 \r
1423                                                 case MENU_BINARY :\r
1424                                                         lpttt->lpszText = MSGJPN166;\r
1425                                                         break;\r
1426 \r
1427                                                 case MENU_AUTO :\r
1428                                                         lpttt->lpszText = MSGJPN167;\r
1429                                                         break;\r
1430 \r
1431                                                 case MENU_REFRESH :\r
1432                                                         lpttt->lpszText = MSGJPN168;\r
1433                                                         break;\r
1434 \r
1435                                                 case MENU_LIST :\r
1436                                                         lpttt->lpszText = MSGJPN169;\r
1437                                                         break;\r
1438 \r
1439                                                 case MENU_REPORT :\r
1440                                                         lpttt->lpszText = MSGJPN170;\r
1441                                                         break;\r
1442 \r
1443                                                 case MENU_KNJ_SJIS :\r
1444                                                         lpttt->lpszText = MSGJPN307;\r
1445                                                         break;\r
1446 \r
1447                                                 case MENU_KNJ_EUC :\r
1448                                                         lpttt->lpszText = MSGJPN171;\r
1449                                                         break;\r
1450 \r
1451                                                 case MENU_KNJ_JIS :\r
1452                                                         lpttt->lpszText = MSGJPN172;\r
1453                                                         break;\r
1454 \r
1455                                                 case MENU_KNJ_UTF8N :\r
1456                                                         lpttt->lpszText = MSGJPN308;\r
1457                                                         break;\r
1458 \r
1459                                                 case MENU_KNJ_UTF8BOM :\r
1460                                                         lpttt->lpszText = MSGJPN330;\r
1461                                                         break;\r
1462 \r
1463                                                 case MENU_KNJ_NONE :\r
1464                                                         lpttt->lpszText = MSGJPN173;\r
1465                                                         break;\r
1466 \r
1467                                                 case MENU_L_KNJ_SJIS :\r
1468                                                         lpttt->lpszText = MSGJPN309;\r
1469                                                         break;\r
1470 \r
1471                                                 case MENU_L_KNJ_EUC :\r
1472                                                         lpttt->lpszText = MSGJPN310;\r
1473                                                         break;\r
1474 \r
1475                                                 case MENU_L_KNJ_JIS :\r
1476                                                         lpttt->lpszText = MSGJPN311;\r
1477                                                         break;\r
1478 \r
1479                                                 case MENU_L_KNJ_UTF8N :\r
1480                                                         lpttt->lpszText = MSGJPN312;\r
1481                                                         break;\r
1482 \r
1483                                                 case MENU_L_KNJ_UTF8BOM :\r
1484                                                         lpttt->lpszText = MSGJPN331;\r
1485                                                         break;\r
1486 \r
1487                                                 case MENU_KANACNV :\r
1488                                                         lpttt->lpszText = MSGJPN174;\r
1489                                                         break;\r
1490 \r
1491                                                 case MENU_SYNC :\r
1492                                                         lpttt->lpszText = MSGJPN175;\r
1493                                                         break;\r
1494 \r
1495                                                 case MENU_ABORT :\r
1496                                                         lpttt->lpszText = MSGJPN176;\r
1497                                                         break;\r
1498                                         }\r
1499                                         // UTF-8からShift_JISへ変換\r
1500                                         {\r
1501                                                 static wchar_t StringBufferUTF16[1024];\r
1502                                                 static char StringBufferSJIS[1024];\r
1503                                                 if(lpttt->lpszText)\r
1504                                                 {\r
1505                                                         MtoW(StringBufferUTF16, sizeof(StringBufferUTF16)/ sizeof(wchar_t), lpttt->lpszText, -1);\r
1506                                                         WtoA(StringBufferSJIS, sizeof(StringBufferSJIS)/ sizeof(char), StringBufferUTF16, -1);\r
1507                                                         lpttt->lpszText = StringBufferSJIS;\r
1508                                                 }\r
1509                                         }\r
1510                                         break;\r
1511 \r
1512                                 case LVN_COLUMNCLICK :\r
1513                                         if(((NMHDR *)lParam)->hwndFrom == GetLocalHwnd())\r
1514                                         {\r
1515                                                 // 同時接続対応\r
1516                                                 CancelFlg = NO;\r
1517                                                 SetSortTypeByColumn(WIN_LOCAL, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1518                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1519                                         }\r
1520                                         else if(((NMHDR *)lParam)->hwndFrom == GetRemoteHwnd())\r
1521                                         {\r
1522                                                 if(((NM_LISTVIEW *)lParam)->iSubItem != 4)\r
1523                                                 {\r
1524                                                         // 同時接続対応\r
1525                                                         CancelFlg = NO;\r
1526                                                         SetSortTypeByColumn(WIN_REMOTE, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1527                                                         ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1528                                                 }\r
1529                                         }\r
1530                                         SetFocus(hWndCurFocus);\r
1531                                         break;\r
1532 \r
1533                                 case LVN_ITEMCHANGED :\r
1534                                         DispSelectedSpace();\r
1535                                         MakeButtonsFocus();\r
1536                                         break;\r
1537                         }\r
1538                         break;\r
1539 \r
1540                 case WM_SIZE :\r
1541                         Sizing = SW_RESTORE;\r
1542                         if(wParam == SIZE_RESTORED)\r
1543                         {\r
1544                                 ResizeWindowProc();\r
1545                                 GetWindowRect(hWnd, &Rect);\r
1546                                 WinPosX = Rect.left;\r
1547                                 WinPosY = Rect.top;\r
1548                         }\r
1549                         else if(wParam == SIZE_MAXIMIZED)\r
1550                         {\r
1551                                 Sizing = SW_MAXIMIZE;\r
1552                                 ResizeWindowProc();\r
1553                         }\r
1554                         else\r
1555                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1556                         break;\r
1557 \r
1558                 case WM_MOVING :\r
1559                         WinPosX = ((RECT *)lParam)->left;\r
1560                         WinPosY = ((RECT *)lParam)->top;\r
1561                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1562 \r
1563                 case WM_SETFOCUS :\r
1564                         SetFocus(hWndCurFocus);\r
1565                         break;\r
1566 \r
1567                 case WM_LBUTTONDOWN :\r
1568                 case WM_LBUTTONUP :\r
1569                 case WM_MOUSEMOVE :\r
1570                         CheckResizeFrame(wParam, LOWORD(lParam), HIWORD(lParam));\r
1571                         break;\r
1572 \r
1573                 case WM_CHANGE_COND :\r
1574                         DispTransferFiles();\r
1575                         break;\r
1576 \r
1577                 case WM_REFRESH_LOCAL_FLG :\r
1578                         PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_LOCAL, 0), 0);\r
1579                         break;\r
1580 \r
1581                 case WM_REFRESH_REMOTE_FLG :\r
1582                         if(SuppressRefresh == 0)\r
1583                                 PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_REMOTE, 0), 0);\r
1584                         break;\r
1585 \r
1586                 case WM_PAINT :\r
1587                     BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1588                     EndPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1589                         break;\r
1590 \r
1591                 case WM_DESTROY :\r
1592 //                      WSACleanup();\r
1593 //                      DestroyWindow(hWndFtp);\r
1594                         PostQuitMessage(0);\r
1595                         break;\r
1596 \r
1597                 case WM_QUERYENDSESSION :\r
1598                         ExitProc(hWnd);\r
1599                         return(TRUE);\r
1600 \r
1601                 case WM_CLOSE :\r
1602                         if((AskTransferNow() == NO) ||\r
1603                            (DialogBox(hInstFtp, MAKEINTRESOURCE(exit_dlg), hWnd, ExeEscDialogProc) == YES))\r
1604                         {\r
1605                                 ExitProc(hWnd);\r
1606                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1607                         }\r
1608                         break;\r
1609 \r
1610                 default :\r
1611                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1612         }\r
1613     return(0L);\r
1614 }\r
1615 \r
1616 \r
1617 /*----- プログラム開始時の処理 ------------------------------------------------\r
1618 *\r
1619 *       Parameter\r
1620 *               char *Cmd : コマンドライン文字列\r
1621 *\r
1622 *       Return Value\r
1623 *               なし\r
1624 *----------------------------------------------------------------------------*/\r
1625 \r
1626 static void StartupProc(char *Cmd)\r
1627 {\r
1628         int Sts;\r
1629         int AutoConnect;\r
1630         int CmdOption;\r
1631         int Kanji;\r
1632         int Kana;\r
1633         int FnameKanji;\r
1634         int TrMode;\r
1635         char unc[FMAX_PATH+1];\r
1636 \r
1637         Sts = AnalyzeComLine(Cmd, &AutoConnect, &CmdOption, unc, FMAX_PATH);\r
1638 \r
1639         TrMode = TYPE_DEFAULT;\r
1640         Kanji = KANJI_NOCNV;\r
1641         FnameKanji = KANJI_NOCNV;\r
1642         Kana = YES;\r
1643         if(CmdOption & OPT_ASCII)\r
1644                 TrMode = TYPE_A;\r
1645         if(CmdOption & OPT_BINARY)\r
1646                 TrMode = TYPE_I;\r
1647         if(CmdOption & OPT_EUC)\r
1648                 Kanji = KANJI_EUC;\r
1649         if(CmdOption & OPT_JIS)\r
1650                 Kanji = KANJI_JIS;\r
1651         if(CmdOption & OPT_EUC_NAME)\r
1652                 FnameKanji = KANJI_EUC;\r
1653         if(CmdOption & OPT_JIS_NAME)\r
1654                 FnameKanji = KANJI_JIS;\r
1655         if(CmdOption & OPT_KANA)\r
1656                 Kana = NO;\r
1657 \r
1658         if(CmdOption & OPT_QUIT)\r
1659                 AutoExit = YES;\r
1660 \r
1661         if(CmdOption & OPT_SAVEOFF)\r
1662                 SuppressSave = YES;\r
1663         if(CmdOption & OPT_SAVEON)\r
1664                 SuppressSave = NO;\r
1665 \r
1666         if(Sts == 0)\r
1667         {\r
1668                 if(ConnectOnStart == YES)\r
1669                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT, 0), 0);\r
1670         }\r
1671         else if(Sts == 1)\r
1672         {\r
1673                 DirectConnectProc(unc, Kanji, Kana, FnameKanji, TrMode);\r
1674         }\r
1675         else if(Sts == 2)\r
1676         {\r
1677                 PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT_NUM, CmdOption), (LPARAM)AutoConnect);\r
1678         }\r
1679         return;\r
1680 }\r
1681 \r
1682 \r
1683 /*----- コマンドラインを解析 --------------------------------------------------\r
1684 *\r
1685 *       Parameter\r
1686 *               char *Str : コマンドライン文字列\r
1687 *               int *AutoConnect : 接続ホスト番号を返すワーク\r
1688 *               int *CmdOption : オプションを返すワーク\r
1689 *               char *unc : uncを返すワーク\r
1690 *               int Max : uncの最大長\r
1691 *\r
1692 *       Return Value\r
1693 *               int ステータス\r
1694 *                       0=指定なし、1=URL指定、2=設定名指定、-1=エラー\r
1695 *\r
1696 *       Note\r
1697 *               -m      --mirror\r
1698 *               -d      --mirrordown\r
1699 *               -f      --force\r
1700 *               -q      --quit\r
1701 *               -s      --set\r
1702 *               -h      --help\r
1703 *               -e      --euc\r
1704 *               -j      --jis\r
1705 *               -a      --ascii\r
1706 *               -b      --binary\r
1707 *               -x      --auto\r
1708 *               -k      --kana\r
1709 *               -u      --eucname\r
1710 *               -i      --jisname\r
1711 *               -n  --ini               (CheckIniFileNameで検索)\r
1712 *                       --saveoff\r
1713 *                       --saveon\r
1714 *               -z      --mpasswd       (CheckMasterPasswordで検索)  2010.01.30 genta 追加\r
1715 *----------------------------------------------------------------------------*/\r
1716 \r
1717 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max)\r
1718 {\r
1719         int Ret;\r
1720         char Tmp[FMAX_PATH+1];\r
1721 \r
1722         *AutoConnect = -1;\r
1723         *CmdOption = 0;\r
1724 \r
1725         Ret = 0;\r
1726         memset(unc, NUL, Max+1);\r
1727 \r
1728         while((Ret != -1) && ((Str = GetToken(Str, Tmp)) != NULL))\r
1729         {\r
1730                 if(Tmp[0] == '-')\r
1731                 {\r
1732                         _strlwr(Tmp);\r
1733                         if((strcmp(&Tmp[1], "m") == 0) || (strcmp(&Tmp[1], "-mirror") == 0))\r
1734                                 *CmdOption |= OPT_MIRROR;\r
1735                         else if((strcmp(&Tmp[1], "d") == 0) || (strcmp(&Tmp[1], "-mirrordown") == 0))\r
1736                                 *CmdOption |= OPT_MIRRORDOWN;\r
1737                         else if((strcmp(&Tmp[1], "e") == 0) || (strcmp(&Tmp[1], "-euc") == 0))\r
1738                                 *CmdOption |= OPT_EUC;\r
1739                         else if((strcmp(&Tmp[1], "j") == 0) || (strcmp(&Tmp[1], "-jis") == 0))\r
1740                                 *CmdOption |= OPT_JIS;\r
1741                         else if((strcmp(&Tmp[1], "a") == 0) || (strcmp(&Tmp[1], "-ascii") == 0))\r
1742                                 *CmdOption |= OPT_ASCII;\r
1743                         else if((strcmp(&Tmp[1], "b") == 0) || (strcmp(&Tmp[1], "-binary") == 0))\r
1744                                 *CmdOption |= OPT_BINARY;\r
1745                         else if((strcmp(&Tmp[1], "x") == 0) || (strcmp(&Tmp[1], "-auto") == 0))\r
1746                                 *CmdOption |= OPT_AUTO;\r
1747                         else if((strcmp(&Tmp[1], "f") == 0) || (strcmp(&Tmp[1], "-force") == 0))\r
1748                                 *CmdOption |= OPT_FORCE;\r
1749                         else if((strcmp(&Tmp[1], "q") == 0) || (strcmp(&Tmp[1], "-quit") == 0))\r
1750                                 *CmdOption |= OPT_QUIT;\r
1751                         else if((strcmp(&Tmp[1], "k") == 0) || (strcmp(&Tmp[1], "-kana") == 0))\r
1752                                 *CmdOption |= OPT_KANA;\r
1753                         else if((strcmp(&Tmp[1], "u") == 0) || (strcmp(&Tmp[1], "-eucname") == 0))\r
1754                                 *CmdOption |= OPT_EUC_NAME;\r
1755                         else if((strcmp(&Tmp[1], "i") == 0) || (strcmp(&Tmp[1], "-jisname") == 0))\r
1756                                 *CmdOption |= OPT_JIS_NAME;\r
1757                         else if((strcmp(&Tmp[1], "n") == 0) || (strcmp(&Tmp[1], "-ini") == 0))\r
1758                         {\r
1759                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1760                                 {\r
1761                                         SetTaskMsg(MSGJPN282);\r
1762                                         Ret = -1;\r
1763                                 }\r
1764                         }\r
1765                         else if(strcmp(&Tmp[1], "-saveoff") == 0)\r
1766                                 *CmdOption |= OPT_SAVEOFF;\r
1767                         else if(strcmp(&Tmp[1], "-saveon") == 0)\r
1768                                 *CmdOption |= OPT_SAVEON;\r
1769                         else if((strcmp(&Tmp[1], "z") == 0) || (strcmp(&Tmp[1], "-mpasswd") == 0))\r
1770                         {       /* 2010.01.30 genta : Add master password option */\r
1771                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1772                                 {\r
1773                                         SetTaskMsg(MSGJPN299);\r
1774                                         Ret = -1;\r
1775                                 }\r
1776                         }\r
1777                         else if((strcmp(&Tmp[1], "s") == 0) || (strcmp(&Tmp[1], "-set") == 0))\r
1778                         {\r
1779                                 if(Ret == 0)\r
1780                                 {\r
1781                                         if((Str = GetToken(Str, Tmp)) != NULL)\r
1782                                         {\r
1783                                                 if((*AutoConnect = SearchHostName(Tmp)) != -1)\r
1784                                                         Ret = 2;\r
1785                                                 else\r
1786                                                 {\r
1787                                                         SetTaskMsg(MSGJPN177, Tmp);\r
1788                                                         Ret = -1;\r
1789                                                 }\r
1790                                         }\r
1791                                         else\r
1792                                         {\r
1793                                                 SetTaskMsg(MSGJPN178);\r
1794                                                 Ret = -1;\r
1795                                         }\r
1796                                 }\r
1797                                 else\r
1798                                 {\r
1799                                         SetTaskMsg(MSGJPN179);\r
1800                                         Ret = -1;\r
1801                                 }\r
1802                         }\r
1803                         else if((strcmp(&Tmp[1], "h") == 0) || (strcmp(&Tmp[1], "-help") == 0))\r
1804                         {\r
1805                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000024);\r
1806                         }\r
1807                         // プロセス保護\r
1808 #ifdef ENABLE_PROCESS_PROTECTION\r
1809                         else if(strcmp(Tmp, "--restart") == 0)\r
1810                         {\r
1811                         }\r
1812                         else if(strcmp(Tmp, "--protect") == 0)\r
1813                         {\r
1814                         }\r
1815                         else if(strcmp(Tmp, "--protect-high") == 0)\r
1816                         {\r
1817                         }\r
1818                         else if(strcmp(Tmp, "--protect-medium") == 0)\r
1819                         {\r
1820                         }\r
1821                         else if(strcmp(Tmp, "--protect-low") == 0)\r
1822                         {\r
1823                         }\r
1824 #endif\r
1825                         else\r
1826                         {\r
1827                                 SetTaskMsg(MSGJPN180, Tmp);\r
1828                                 Ret = -1;\r
1829                         }\r
1830                 }\r
1831                 else\r
1832                 {\r
1833                         if(Ret == 0)\r
1834                         {\r
1835                                 strncpy(unc, Tmp, Max);\r
1836                                 Ret = 1;\r
1837                         }\r
1838                         else\r
1839                         {\r
1840                                 SetTaskMsg(MSGJPN181);\r
1841                                 Ret = -1;\r
1842                         }\r
1843                 }\r
1844         }\r
1845         return(Ret);\r
1846 }\r
1847 \r
1848 \r
1849 /*----- INIファイルのパス名の指定をチェック ------------------------------------\r
1850 *\r
1851 *       Parameter\r
1852 *               char *Str : コマンドライン文字列\r
1853 *               char *Ini : iniファイル名を返すワーク\r
1854 *\r
1855 *       Return Value\r
1856 *               int ステータス\r
1857 *                       0=指定なし、1=あり\r
1858 *\r
1859 *       Note\r
1860 *               -n  --ini\r
1861 *----------------------------------------------------------------------------*/\r
1862 \r
1863 static int CheckIniFileName(char *Str, char *Ini)\r
1864 {\r
1865         return GetTokenAfterOption( Str, Ini, "n", "-ini" );\r
1866 }\r
1867 \r
1868 /* マスターパスワードの指定をチェック */\r
1869 static int CheckMasterPassword(char *Str, char *Ini)\r
1870 {\r
1871         return GetTokenAfterOption( Str, Ini, "z", "-mpasswd" );\r
1872 }\r
1873 \r
1874 /*----- オプションの後ろのトークンを取り出す ------------------------------------\r
1875 *\r
1876 *       Parameter\r
1877 *               char *Str : コマンドライン文字列\r
1878 *               char *Result : 取り出した文字列を格納するワーク\r
1879 *               const char* Opt1, *Opt2: オプション文字列(2つ)\r
1880 *\r
1881 *       Return Value\r
1882 *               int ステータス\r
1883 *                       0=指定なし、1=あり\r
1884 *\r
1885 *       Note\r
1886 *               2010.01.30 genta マスターパスワード取り出しのため共通化\r
1887 *----------------------------------------------------------------------------*/\r
1888 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 )\r
1889 {\r
1890         int Ret = 0;\r
1891         char Tmp[FMAX_PATH+1];\r
1892 \r
1893         Result[0] = NUL;\r
1894         while((Str = GetToken(Str, Tmp)) != NULL)\r
1895         {\r
1896                 if(Tmp[0] == '-')\r
1897                 {\r
1898                         _strlwr(Tmp);\r
1899                         if((strcmp(&Tmp[1], Opt1) == 0) || (strcmp(&Tmp[1], Opt2) == 0))\r
1900                         {\r
1901                                 if((Str = GetToken(Str, Result)) != NULL)\r
1902                                         Ret = 1;\r
1903                                 break;\r
1904                         }\r
1905                 }\r
1906         }\r
1907         return(Ret);\r
1908 }\r
1909 \r
1910 /*----- トークンを返す --------------------------------------------------------\r
1911 *\r
1912 *       Parameter\r
1913 *               char *Str : 文字列\r
1914 *               char *Buf : 文字列を返すバッファ\r
1915 *\r
1916 *       Return Value\r
1917 *               char *返したトークンの末尾\r
1918 *                       NULL=終わり\r
1919 *----------------------------------------------------------------------------*/\r
1920 \r
1921 static char *GetToken(char *Str, char *Buf)\r
1922 {\r
1923         int InQuote;\r
1924 \r
1925         while(*Str != NUL)\r
1926         {\r
1927                 if((*Str != ' ') && (*Str != '\t'))\r
1928                         break;\r
1929                 Str++;\r
1930         }\r
1931 \r
1932         if(*Str != NUL)\r
1933         {\r
1934                 InQuote = 0;\r
1935                 while(*Str != NUL)\r
1936                 {\r
1937                         if(*Str == 0x22)\r
1938                                 InQuote = !InQuote;\r
1939                         else\r
1940                         {\r
1941                                 if(((*Str == ' ') || (*Str == '\t')) &&\r
1942                                    (InQuote == 0))\r
1943                                 {\r
1944                                         break;\r
1945                                 }\r
1946                                 *Buf++ = *Str;\r
1947                         }\r
1948                         Str++;\r
1949                 }\r
1950         }\r
1951         else\r
1952                 Str = NULL;\r
1953 \r
1954         *Buf = NUL;\r
1955 \r
1956         return(Str);\r
1957 }\r
1958 \r
1959 \r
1960 /*----- プログラム終了時の処理 ------------------------------------------------\r
1961 *\r
1962 *       Parameter\r
1963 *               HWND hWnd : ウインドウハンドル\r
1964 *\r
1965 *       Return Value\r
1966 *               なし\r
1967 *----------------------------------------------------------------------------*/\r
1968 \r
1969 static void ExitProc(HWND hWnd)\r
1970 {\r
1971         CancelFlg = YES;\r
1972 \r
1973         CloseTransferThread();\r
1974 \r
1975         if(SaveExit == YES)\r
1976         {\r
1977                 SaveBookMark();\r
1978                 SaveCurrentSetToHost();\r
1979         }\r
1980         DeleteAlltempFile();\r
1981 \r
1982 //      WSACancelBlockingCall();\r
1983         DisconnectProc();\r
1984 //      CloseTransferThread();\r
1985 \r
1986         if(SaveExit == YES)\r
1987         {\r
1988                 GetListTabWidth();\r
1989                 SaveRegistory();\r
1990 \r
1991                 if((CacheEntry > 0) && (CacheSave == YES))\r
1992                         SaveCache();\r
1993                 else\r
1994                         DeleteCache();\r
1995         }\r
1996         else\r
1997                 DeleteCache();\r
1998 \r
1999         if(RasClose == YES)\r
2000         {\r
2001                 DisconnectRas(RasCloseNotify);\r
2002         }\r
2003         DeleteAllObject();\r
2004         HtmlHelp(NULL, NULL, HH_UNINITIALIZE, dwCookie); \r
2005         return;\r
2006 }\r
2007 \r
2008 \r
2009 /*----- ファイル名をダブルクリックしたときの処理 ------------------------------\r
2010 *\r
2011 *       Parameter\r
2012 *               int Win : ウインドウ番号 (WIN_xxx)\r
2013 *               int Mode : 常に「開く」動作をするかどうか (YES/NO)\r
2014 *               int App : アプリケーション番号(-1=関連づけ優先)\r
2015 *\r
2016 *       Return Value\r
2017 *               なし\r
2018 *----------------------------------------------------------------------------*/\r
2019 \r
2020 void DoubleClickProc(int Win, int Mode, int App)\r
2021 {\r
2022         int Pos;\r
2023         int Type;\r
2024         char Local[FMAX_PATH+1];\r
2025         char Remote[FMAX_PATH+1];\r
2026         char Tmp[FMAX_PATH+1];\r
2027         int Sts;\r
2028         int UseDiffViewer;\r
2029 \r
2030         if(AskUserOpeDisabled() == NO)\r
2031         {\r
2032                 SetCurrentDirAsDirHist();\r
2033                 if(GetSelectedCount(Win) == 1)\r
2034                 {\r
2035                         if((Pos = GetFirstSelected(Win, NO)) != -1)\r
2036                         {\r
2037                                 GetNodeName(Win, Pos, Tmp, FMAX_PATH);\r
2038                                 Type = GetNodeType(Win, Pos);\r
2039 \r
2040                                 if(Win == WIN_LOCAL)\r
2041                                 {\r
2042                                         if((App != -1) || (Type == NODE_FILE))\r
2043                                         {\r
2044                                                 if((DclickOpen == YES) || (Mode == YES))\r
2045                                                 {\r
2046                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2047                                                         ReplaceAll(Local, '/', '\\');\r
2048                                                         SetYenTail(Local);\r
2049                                                         strcat(Local, Tmp);\r
2050                                                         ExecViewer(Local, App);\r
2051                                                 }\r
2052                                                 else\r
2053                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_UPLOAD, 0), 0);\r
2054                                         }\r
2055                                         else\r
2056                                                 ChangeDir(WIN_LOCAL, Tmp);\r
2057                                 }\r
2058                                 else if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2059                                 {\r
2060                                         if((App != -1) || (Type == NODE_FILE))\r
2061                                         {\r
2062                                                 if((DclickOpen == YES) || (Mode == YES))\r
2063                                                 {\r
2064                                                         // ビューワ2、3のパスが "d " で始まっていたら差分ビューア使用\r
2065                                                         if ((App == 1 || App == 2) && strncmp(ViewerName[App], "d ", 2) == 0)\r
2066                                                                 UseDiffViewer = YES;\r
2067                                                         else\r
2068                                                                 UseDiffViewer = NO;\r
2069 \r
2070                                                         strcpy(Remote, TmpPath);\r
2071                                                         SetYenTail(Remote);\r
2072                                                         if (UseDiffViewer == YES) {\r
2073                                                                 strcat(Remote, "remote.");\r
2074                                                         }\r
2075                                                         strcat(Remote, Tmp);\r
2076 \r
2077                                                         if(AskTransferNow() == YES)\r
2078                                                                 SktShareProh();\r
2079 \r
2080         //                                              MainTransPkt.ctrl_skt = AskCmdCtrlSkt();\r
2081                                                         strcpy(MainTransPkt.Cmd, "RETR ");\r
2082                                                         if(AskHostType() == HTYPE_ACOS)\r
2083                                                         {\r
2084                                                                 strcpy(MainTransPkt.RemoteFile, "'");\r
2085                                                                 strcat(MainTransPkt.RemoteFile, AskHostLsName());\r
2086                                                                 strcat(MainTransPkt.RemoteFile, "(");\r
2087                                                                 strcat(MainTransPkt.RemoteFile, Tmp);\r
2088                                                                 strcat(MainTransPkt.RemoteFile, ")");\r
2089                                                                 strcat(MainTransPkt.RemoteFile, "'");\r
2090                                                         }\r
2091                                                         else if(AskHostType() == HTYPE_ACOS_4)\r
2092                                                         {\r
2093                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2094                                                         }\r
2095                                                         else\r
2096                                                         {\r
2097                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2098                                                         }\r
2099                                                         strcpy(MainTransPkt.LocalFile, Remote);\r
2100                                                         MainTransPkt.Type = AskTransferTypeAssoc(MainTransPkt.RemoteFile, AskTransferType());\r
2101                                                         MainTransPkt.Size = 1;\r
2102                                                         MainTransPkt.KanjiCode = AskHostKanjiCode();\r
2103                                                         MainTransPkt.KanjiCodeDesired = AskLocalKanjiCode();\r
2104                                                         MainTransPkt.KanaCnv = AskHostKanaCnv();\r
2105                                                         MainTransPkt.Mode = EXIST_OVW;\r
2106                                                         MainTransPkt.ExistSize = 0;\r
2107                                                         MainTransPkt.hWndTrans = NULL;\r
2108                                                         MainTransPkt.Next = NULL;\r
2109 \r
2110                                                         DisableUserOpe();\r
2111 \r
2112                                                         /* 不正なパスを検出 */\r
2113                                                         if(CheckPathViolation(&MainTransPkt) == NO)\r
2114                                                         {\r
2115 //                                                              if((Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429)\r
2116 //                                                              {\r
2117 //                                                                      ReConnectCmdSkt();\r
2118                                                                         // 同時接続対応\r
2119                                                                         CancelFlg = NO;\r
2120                                                                         Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg);\r
2121 //                                                              }\r
2122                                                         }\r
2123 \r
2124                                                         EnableUserOpe();\r
2125 \r
2126                                                         AddTempFileList(Remote);\r
2127                                                         if(Sts/100 == FTP_COMPLETE) {\r
2128                                                                 if (UseDiffViewer == YES) {\r
2129                                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2130                                                                         ReplaceAll(Local, '/', '\\');\r
2131                                                                         SetYenTail(Local);\r
2132                                                                         strcat(Local, Tmp);\r
2133                                                                         ExecViewer2(Local, Remote, App);\r
2134                                                                 } else {\r
2135                                                                         ExecViewer(Remote, App);\r
2136                                                                 }\r
2137                                                         }\r
2138                                                 }\r
2139                                                 else\r
2140                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_DOWNLOAD, 0), 0);\r
2141                                         }\r
2142                                         else\r
2143                                                 ChangeDir(WIN_REMOTE, Tmp);\r
2144                                 }\r
2145                         }\r
2146                 }\r
2147                 MakeButtonsFocus();\r
2148         }\r
2149         return;\r
2150 }\r
2151 \r
2152 \r
2153 /*----- フォルダの移動 --------------------------------------------------------\r
2154 *\r
2155 *       Parameter\r
2156 *               int Win : ウインドウ番号 (WIN_xxx)\r
2157 *               char *Path : 移動先のパス名\r
2158 *\r
2159 *       Return Value\r
2160 *               なし\r
2161 *\r
2162 *       Note\r
2163 *               フォルダ同時移動の処理も行う\r
2164 *----------------------------------------------------------------------------*/\r
2165 \r
2166 static void ChangeDir(int Win, char *Path)\r
2167 {\r
2168         int Sync;\r
2169         char Local[FMAX_PATH+1];\r
2170         char Remote[FMAX_PATH+1];\r
2171 \r
2172         // 同時接続対応\r
2173         CancelFlg = NO;\r
2174 \r
2175         // デッドロック対策\r
2176         DisableUserOpe();\r
2177         Sync = AskSyncMoveMode();\r
2178         if(Sync == YES)\r
2179         {\r
2180                 if(strcmp(Path, "..") == 0)\r
2181                 {\r
2182                         AskLocalCurDir(Local, FMAX_PATH);\r
2183                         AskRemoteCurDir(Remote, FMAX_PATH);\r
2184                         if(strcmp(GetFileName(Local), GetFileName(Remote)) != 0)\r
2185                                 Sync = NO;\r
2186                 }\r
2187         }\r
2188 \r
2189         if((Win == WIN_LOCAL) || (Sync == YES))\r
2190         {\r
2191                 if(DoLocalCWD(Path) == FFFTP_SUCCESS)\r
2192                         GetLocalDirForWnd();\r
2193         }\r
2194 \r
2195         if((Win == WIN_REMOTE) || (Sync == YES))\r
2196         {\r
2197                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2198                 {\r
2199 #if defined(HAVE_OPENVMS)\r
2200                         /* OpenVMSの場合、".DIR;?"を取る */\r
2201                         if (AskHostType() == HTYPE_VMS)\r
2202                                 ReformVMSDirName(Path, TRUE);\r
2203 #endif\r
2204                         if(DoCWD(Path, YES, NO, YES) < FTP_RETRY)\r
2205                                 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2206                 }\r
2207         }\r
2208         // デッドロック対策\r
2209         EnableUserOpe();\r
2210         return;\r
2211 }\r
2212 \r
2213 \r
2214 /*----- ウインドウのサイズ変更の処理 ------------------------------------------\r
2215 *\r
2216 *       Parameter\r
2217 *               なし\r
2218 *\r
2219 *       Return Value\r
2220 *               なし\r
2221 *----------------------------------------------------------------------------*/\r
2222 \r
2223 static void ResizeWindowProc(void)\r
2224 {\r
2225 #if 0\r
2226         RECT Rect;\r
2227         int RemotePosX;\r
2228 \r
2229         GetClientRect(hWndFtp, &Rect);\r
2230         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2231 \r
2232         CalcWinSize();\r
2233         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, WinWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2234 \r
2235         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2236         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2237         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2238         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2239 \r
2240         RemotePosX = LocalWidth + SepaWidth;\r
2241         if(SplitVertical == YES)\r
2242                 RemotePosX = 0;\r
2243 \r
2244         SetWindowPos(GetRemoteTbarWnd(), 0, RemotePosX, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2245         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2246         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2247         SetWindowPos(GetRemoteHwnd(), 0, RemotePosX, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2248 \r
2249         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2250 #else\r
2251         RECT Rect;\r
2252 \r
2253         GetClientRect(hWndFtp, &Rect);\r
2254         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2255 \r
2256         CalcWinSize();\r
2257         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, Rect.right, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2258         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2259         SetWindowPos(GetRemoteTbarWnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2260         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2261         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2262         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2263         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2264         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2265         SetWindowPos(GetRemoteHwnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2266         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2267 #endif\r
2268 \r
2269         return;\r
2270 }\r
2271 \r
2272 \r
2273 /*----- ウインドウの各部分のサイズを計算する ----------------------------------\r
2274 *\r
2275 *       Parameter\r
2276 *               なし\r
2277 *\r
2278 *       Return Value\r
2279 *               なし\r
2280 *----------------------------------------------------------------------------*/\r
2281 \r
2282 static void CalcWinSize(void)\r
2283 {\r
2284         RECT Rect;\r
2285 \r
2286         GetWindowRect(hWndFtp, &Rect);\r
2287 \r
2288         if(Sizing != SW_MAXIMIZE)\r
2289         {\r
2290                 WinWidth = Rect.right - Rect.left;\r
2291                 WinHeight = Rect.bottom - Rect.top;\r
2292         }\r
2293 \r
2294         GetClientRect(hWndFtp, &Rect);\r
2295 \r
2296         ClientWidth = Rect.right;\r
2297         ClientHeight = Rect.bottom;\r
2298 \r
2299         SepaWidth = 4;\r
2300         LocalWidth = max1(0, min1(LocalWidth, ClientWidth - SepaWidth));\r
2301         RemoteWidth = max1(0, ClientWidth - LocalWidth - SepaWidth);\r
2302 //      TaskHeight = min1(TaskHeight, max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - SepaWidth));\r
2303 \r
2304         GetClientRect(GetSbarWnd(), &Rect);\r
2305 \r
2306         ListHeight = max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - TaskHeight - SepaWidth - Rect.bottom);\r
2307 \r
2308         return;\r
2309 }\r
2310 \r
2311 \r
2312 #if 0\r
2313 /*----- ウインドウの表示位置を取得する ----------------------------------------\r
2314 *\r
2315 *       Parameter\r
2316 *               HWND hWnd : ウインドウハンドル\r
2317 *\r
2318 *       Return Value\r
2319 *               なし\r
2320 *----------------------------------------------------------------------------*/\r
2321 \r
2322 static void AskWindowPos(HWND hWnd)\r
2323 {\r
2324         WINDOWPLACEMENT WinPlace;\r
2325 \r
2326         WinPlace.length = sizeof(WINDOWPLACEMENT);\r
2327         GetWindowPlacement(hWnd, &WinPlace);\r
2328         WinPosX = WinPlace.rcNormalPosition.left;\r
2329         WinPosY = WinPlace.rcNormalPosition.top;\r
2330 \r
2331         return;\r
2332 }\r
2333 #endif\r
2334 \r
2335 \r
2336 /*----- ディレクトリリストとファイルリストの境界変更処理 ----------------------\r
2337 *\r
2338 *       Parameter\r
2339 *               WPARAM Keys : WM_MOUSEMOVEなどのWPARAMの値\r
2340 *               int x : マウスカーソルのX座標\r
2341 *               int y : マウスカーソルのY座標\r
2342 *\r
2343 *       Return Value\r
2344 *               なし\r
2345 *----------------------------------------------------------------------------*/\r
2346 \r
2347 static void CheckResizeFrame(WPARAM Keys, int x, int y)\r
2348 {\r
2349         RECT Rect;\r
2350         RECT Rect1;\r
2351 \r
2352         if((Resizing == RESIZE_OFF) && (Keys == 0))\r
2353         {\r
2354                 if((x >= LocalWidth) && (x <= LocalWidth + SepaWidth) &&\r
2355                    (y > TOOLWIN_HEIGHT) && (y < (TOOLWIN_HEIGHT * 2 + ListHeight)))\r
2356                 {\r
2357                         /* 境界位置変更用カーソルに変更 */\r
2358                         SetCapture(hWndFtp);\r
2359                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_lr_csr));\r
2360                         SetCursor(hCursor);\r
2361                         Resizing = RESIZE_PREPARE;\r
2362                         ResizePos = RESIZE_HPOS;\r
2363                 }\r
2364                 else if((y >= TOOLWIN_HEIGHT*2+ListHeight) && (y <= TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))\r
2365                 {\r
2366                         /* 境界位置変更用カーソルに変更 */\r
2367                         SetCapture(hWndFtp);\r
2368                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_ud_csr));\r
2369                         SetCursor(hCursor);\r
2370                         Resizing = RESIZE_PREPARE;\r
2371                         ResizePos = RESIZE_VPOS;\r
2372                 }\r
2373         }\r
2374         else if(Resizing == RESIZE_PREPARE)\r
2375         {\r
2376                 if(Keys & MK_LBUTTON)\r
2377                 {\r
2378                         /* 境界位置変更開始 */\r
2379                         Resizing = RESIZE_ON;\r
2380                         GetWindowRect(hWndFtp, &Rect);\r
2381                         GetClientRect(GetSbarWnd(), &Rect1);\r
2382                         Rect.left += GetSystemMetrics(SM_CXFRAME);\r
2383                         Rect.right -= GetSystemMetrics(SM_CXFRAME);\r
2384                         Rect.top += TOOLWIN_HEIGHT*2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);\r
2385                         Rect.bottom -= GetSystemMetrics(SM_CYFRAME) + Rect1.bottom;\r
2386                         ClipCursor(&Rect);\r
2387                 }\r
2388                 else\r
2389                 {\r
2390                         if(((ResizePos == RESIZE_HPOS) &&\r
2391                                 ((x < LocalWidth) || (x > LocalWidth + SepaWidth) ||\r
2392                                  (y <= TOOLWIN_HEIGHT) || (y >= (TOOLWIN_HEIGHT * 2 + ListHeight)))) ||\r
2393                            ((ResizePos == RESIZE_VPOS) &&\r
2394                                 ((y < TOOLWIN_HEIGHT*2+ListHeight) || (y > TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))))\r
2395                         {\r
2396                                 /* 元のカーソルに戻す */\r
2397                                 ReleaseCapture();\r
2398                                 hCursor = LoadCursor(NULL, IDC_ARROW);\r
2399                                 SetCursor(hCursor);\r
2400                                 Resizing = RESIZE_OFF;\r
2401                         }\r
2402                 }\r
2403         }\r
2404         else if(Resizing == RESIZE_ON)\r
2405         {\r
2406                 if(ResizePos == RESIZE_HPOS)\r
2407                         LocalWidth = x;\r
2408                 else\r
2409                 {\r
2410                         GetClientRect(hWndFtp, &Rect);\r
2411                         GetClientRect(GetSbarWnd(), &Rect1);\r
2412                         TaskHeight = max1(0, Rect.bottom - y - Rect1.bottom);\r
2413                 }\r
2414                 ResizeWindowProc();\r
2415 \r
2416                 if((Keys & MK_LBUTTON) == 0)\r
2417                 {\r
2418                         /* 境界位置変更終了 */\r
2419                         ReleaseCapture();\r
2420                         ClipCursor(NULL);\r
2421                         hCursor = LoadCursor(NULL, IDC_ARROW);\r
2422                         SetCursor(hCursor);\r
2423                         Resizing = RESIZE_OFF;\r
2424                 }\r
2425         }\r
2426         return;\r
2427 }\r
2428 \r
2429 \r
2430 /*----- ファイル一覧情報をビューワで表示 --------------------------------------\r
2431 *\r
2432 *       Parameter\r
2433 *               なし\r
2434 *\r
2435 *       Return Value\r
2436 *               なし\r
2437 *----------------------------------------------------------------------------*/\r
2438 \r
2439 static void DispDirInfo(void)\r
2440 {\r
2441         char Buf[FMAX_PATH+1];\r
2442 \r
2443         MakeCacheFileName(AskCurrentFileListNum(), Buf);\r
2444         ExecViewer(Buf, 0);\r
2445         return;\r
2446 }\r
2447 \r
2448 \r
2449 \r
2450 /*----- ビューワを起動 --------------------------------------------------------\r
2451 *\r
2452 *       Parameter\r
2453 *               char Fname : ファイル名\r
2454 *               int App : アプリケーション番号(-1=関連づけ優先)\r
2455 *\r
2456 *       Return Value\r
2457 *               なし\r
2458 *----------------------------------------------------------------------------*/\r
2459 \r
2460 void ExecViewer(char *Fname, int App)\r
2461 {\r
2462         PROCESS_INFORMATION Info;\r
2463         STARTUPINFO Startup;\r
2464         char AssocProg[FMAX_PATH+1];\r
2465         char ComLine[FMAX_PATH*2+3+1];\r
2466         char CurDir[FMAX_PATH+1];\r
2467         // 任意のコードが実行されるバグ修正\r
2468         char SysDir[FMAX_PATH+1];\r
2469 \r
2470         /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
2471         /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
2472         /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
2473 \r
2474         AskLocalCurDir(CurDir, FMAX_PATH);\r
2475 \r
2476         // 任意のコードが実行されるバグ修正\r
2477         // 拡張子が無いと補完されるため\r
2478 //      if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
2479         if((App == -1) && strrchr(Fname, '.') > strrchr(Fname, '\\') && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
2480         {\r
2481                 DoPrintf("ShellExecute - %s", Fname);\r
2482                 ShellExecute(NULL, "open", Fname, NULL, CurDir, SW_SHOW);\r
2483         }\r
2484         else\r
2485         {\r
2486                 App = max1(0, App);\r
2487                 strcpy(AssocProg, ViewerName[App]);\r
2488 \r
2489                 if(strchr(Fname, ' ') == NULL)\r
2490                         sprintf(ComLine, "%s %s", AssocProg, Fname);\r
2491                 else\r
2492                         sprintf(ComLine, "%s \"%s\"", AssocProg, Fname);\r
2493 \r
2494                 DoPrintf("FindExecutable - %s", ComLine);\r
2495 \r
2496                 memset(&Startup, NUL, sizeof(STARTUPINFO));\r
2497                 Startup.cb = sizeof(STARTUPINFO);\r
2498                 Startup.wShowWindow = SW_SHOW;\r
2499                 // 任意のコードが実行されるバグ修正\r
2500 //              if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2501 //              {\r
2502 //                      SetTaskMsg(MSGJPN182, GetLastError());\r
2503 //                      SetTaskMsg(">>%s", ComLine);\r
2504 //              }\r
2505                 if(GetCurrentDirectory(FMAX_PATH, CurDir) > 0)\r
2506                 {\r
2507                         if(GetSystemDirectory(SysDir, FMAX_PATH) > 0)\r
2508                         {\r
2509                                 if(SetCurrentDirectory(SysDir))\r
2510                                 {\r
2511                                         if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2512                                         {\r
2513                                                 SetTaskMsg(MSGJPN182, GetLastError());\r
2514                                                 SetTaskMsg(">>%s", ComLine);\r
2515                                         }\r
2516                                         SetCurrentDirectory(CurDir);\r
2517                                 }\r
2518                         }\r
2519                 }\r
2520         }\r
2521         return;\r
2522 }\r
2523 \r
2524 \r
2525 /*----- 差分表示ビューワを起動 ------------------------------------------------\r
2526 *\r
2527 *       Parameter\r
2528 *               char Fname1 : ファイル名\r
2529 *               char Fname2 : ファイル名2\r
2530 *               int App : アプリケーション番号(2 or 3)\r
2531 *\r
2532 *       Return Value\r
2533 *               なし\r
2534 *----------------------------------------------------------------------------*/\r
2535 \r
2536 void ExecViewer2(char *Fname1, char *Fname2, int App)\r
2537 {\r
2538         PROCESS_INFORMATION Info;\r
2539         STARTUPINFO Startup;\r
2540         char AssocProg[FMAX_PATH+1];\r
2541         char ComLine[FMAX_PATH*2+3+1];\r
2542         char CurDir[FMAX_PATH+1];\r
2543         // 任意のコードが実行されるバグ修正\r
2544         char SysDir[FMAX_PATH+1];\r
2545 \r
2546         /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
2547         /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
2548         /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
2549 \r
2550         AskLocalCurDir(CurDir, FMAX_PATH);\r
2551 \r
2552         strcpy(AssocProg, ViewerName[App] + 2); /* 先頭の "d " は読み飛ばす */\r
2553 \r
2554         if(strchr(Fname1, ' ') == NULL && strchr(Fname2, ' ') == NULL)\r
2555                 sprintf(ComLine, "%s %s %s", AssocProg, Fname1, Fname2);\r
2556         else\r
2557                 sprintf(ComLine, "%s \"%s\" \"%s\"", AssocProg, Fname1, Fname2);\r
2558 \r
2559         DoPrintf("FindExecutable - %s", ComLine);\r
2560 \r
2561         memset(&Startup, NUL, sizeof(STARTUPINFO));\r
2562         Startup.cb = sizeof(STARTUPINFO);\r
2563         Startup.wShowWindow = SW_SHOW;\r
2564         // 任意のコードが実行されるバグ修正\r
2565 //      if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2566 //      {\r
2567 //              SetTaskMsg(MSGJPN182, GetLastError());\r
2568 //              SetTaskMsg(">>%s", ComLine);\r
2569 //      }\r
2570         if(GetCurrentDirectory(FMAX_PATH, CurDir) > 0)\r
2571         {\r
2572                 if(GetSystemDirectory(SysDir, FMAX_PATH) > 0)\r
2573                 {\r
2574                         if(SetCurrentDirectory(SysDir))\r
2575                         {\r
2576                                 if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2577                                 {\r
2578                                         SetTaskMsg(MSGJPN182, GetLastError());\r
2579                                         SetTaskMsg(">>%s", ComLine);\r
2580                                 }\r
2581                                 SetCurrentDirectory(CurDir);\r
2582                         }\r
2583                 }\r
2584         }\r
2585 \r
2586         return;\r
2587 }\r
2588 \r
2589 \r
2590 /*----- テンポラリファイル名をテンポラリファイルリストに追加 ------------------\r
2591 *\r
2592 *       Parameter\r
2593 *               char *Fname : テンポラリファイル名\r
2594 *\r
2595 *       Return Value\r
2596 *               なし\r
2597 *----------------------------------------------------------------------------*/\r
2598 \r
2599 void AddTempFileList(char *Fname)\r
2600 {\r
2601         TEMPFILELIST *New;\r
2602 \r
2603         if((New = malloc(sizeof(TEMPFILELIST))) != NULL)\r
2604         {\r
2605                 if((New->Fname = malloc(strlen(Fname)+1)) != NULL)\r
2606                 {\r
2607                         strcpy(New->Fname, Fname);\r
2608                         if(TempFiles == NULL)\r
2609                                 New->Next = NULL;\r
2610                         else\r
2611                                 New->Next = TempFiles;\r
2612                         TempFiles = New;\r
2613                 }\r
2614                 else\r
2615                         free(New);\r
2616         }\r
2617         return;\r
2618 }\r
2619 \r
2620 \r
2621 /*----- テンポラリファイルリストに登録されているファイルを全て削除 ------------\r
2622 *\r
2623 *       Parameter\r
2624 *               なし\r
2625 *\r
2626 *       Return Value\r
2627 *               なし\r
2628 *----------------------------------------------------------------------------*/\r
2629 \r
2630 static void DeleteAlltempFile(void)\r
2631 {\r
2632         TEMPFILELIST *Pos;\r
2633         TEMPFILELIST *Next;\r
2634 \r
2635         Pos = TempFiles;\r
2636         while(Pos != NULL)\r
2637         {\r
2638                 DeleteFile(Pos->Fname);\r
2639 \r
2640                 Next = Pos->Next;\r
2641                 free(Pos->Fname);\r
2642                 free(Pos);\r
2643                 Pos = Next;\r
2644         }\r
2645 \r
2646         // OLE D&Dのテンポラリを削除する (2007.9.11 yutaka)\r
2647         doDeleteRemoteFile();\r
2648 \r
2649         return;\r
2650 }\r
2651 \r
2652 \r
2653 /*----- Aboutダイアログボックスのコールバック関数 ------------------------\r
2654 *\r
2655 *       Parameter\r
2656 *               HWND hDlg : ウインドウハンドル\r
2657 *               UINT message : メッセージ番号\r
2658 *               WPARAM wParam : メッセージの WPARAM 引数\r
2659 *               LPARAM lParam : メッセージの LPARAM 引数\r
2660 *\r
2661 *       Return Value\r
2662 *               BOOL TRUE/FALSE\r
2663 *----------------------------------------------------------------------------*/\r
2664 \r
2665 static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
2666 {\r
2667         static char Tmp[80];\r
2668         int Ver;\r
2669 \r
2670         switch (message)\r
2671         {\r
2672                 case WM_INITDIALOG :\r
2673                         Ver = GetJreVersion();\r
2674                         if(Ver == -1)\r
2675                                 sprintf(Tmp, MSGJPN183);\r
2676                         else\r
2677                                 sprintf(Tmp, MSGJPN184, Ver / 0x100, Ver % 0x100);\r
2678                         SendDlgItemMessage(hDlg, ABOUT_JRE, WM_SETTEXT, 0, (LPARAM)Tmp);\r
2679                         SendDlgItemMessage(hDlg, ABOUT_URL, EM_LIMITTEXT, 256, 0);\r
2680                         SendDlgItemMessage(hDlg, ABOUT_URL, WM_SETTEXT, 0, (LPARAM)MSGJPN284);\r
2681                         return(TRUE);\r
2682 \r
2683                 case WM_COMMAND :\r
2684                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2685                         {\r
2686                                 case IDOK :\r
2687                                 case IDCANCEL :\r
2688                                         EndDialog(hDlg, YES);\r
2689                                         break;\r
2690                         }\r
2691                         return(TRUE);\r
2692         }\r
2693     return(FALSE);\r
2694 }\r
2695 \r
2696 \r
2697 /*----- サウンドを鳴らす ------------------------------------------------------\r
2698 *\r
2699 *       Parameter\r
2700 *               Int num : サウンドの種類 (SND_xxx)\r
2701 *\r
2702 *       Return Value\r
2703 *               なし\r
2704 *----------------------------------------------------------------------------*/\r
2705 \r
2706 void SoundPlay(int Num)\r
2707 {\r
2708         if(Sound[Num].On == YES)\r
2709                 sndPlaySound(Sound[Num].Fname, SND_ASYNC | SND_NODEFAULT);\r
2710 \r
2711         return;\r
2712 }\r
2713 \r
2714 \r
2715 /*----- ヘルプファイルのパス名を返す ------------------------------------------\r
2716 *\r
2717 *       Parameter\r
2718 *               なし\r
2719 *\r
2720 *       Return Value\r
2721 *               char *パス名\r
2722 *----------------------------------------------------------------------------*/\r
2723 \r
2724 char *AskHelpFilePath(void)\r
2725 {\r
2726         return(HelpPath);\r
2727 }\r
2728 \r
2729 \r
2730 /*----- テンポラリファイルのパス名を返す --------------------------------------\r
2731 *\r
2732 *       Parameter\r
2733 *               なし\r
2734 *\r
2735 *       Return Value\r
2736 *               char *パス名\r
2737 *----------------------------------------------------------------------------*/\r
2738 \r
2739 char *AskTmpFilePath(void)\r
2740 {\r
2741         return(TmpPath);\r
2742 }\r
2743 \r
2744 \r
2745 /*----- INIファイルのパス名を返す ---------------------------------------------\r
2746 *\r
2747 *       Parameter\r
2748 *               なし\r
2749 *\r
2750 *       Return Value\r
2751 *               char *パス名\r
2752 *----------------------------------------------------------------------------*/\r
2753 \r
2754 char *AskIniFilePath(void)\r
2755 {\r
2756         return(IniPath);\r
2757 }\r
2758 \r
2759 /*----- INIファイルのみを使うかどうかを返す -----------------------------------\r
2760 *\r
2761 *       Parameter\r
2762 *               なし\r
2763 *\r
2764 *       Return Value\r
2765 *               int ステータス : YES/NO\r
2766 *----------------------------------------------------------------------------*/\r
2767 \r
2768 int AskForceIni(void)\r
2769 {\r
2770         return(ForceIni);\r
2771 }\r
2772 \r
2773 \r
2774 \r
2775 \r
2776 /*----- メッセージ処理 --------------------------------------------------------\r
2777 *\r
2778 *       Parameter\r
2779 *               なし\r
2780 *\r
2781 *       Return Value\r
2782 *               int 終了フラグ (YES=WM_CLOSEが来た/NO)\r
2783 *----------------------------------------------------------------------------*/\r
2784 \r
2785 int BackgrndMessageProc(void)\r
2786 {\r
2787     MSG Msg;\r
2788         int Ret;\r
2789 \r
2790         Ret = NO;\r
2791         while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))\r
2792         {\r
2793                 if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
2794                 {\r
2795                         /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
2796                         /* コンボボックス内ではアクセラレータを無効にする */\r
2797                         if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
2798                            (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
2799                            ((hHelpWin != NULL) && (Msg.hwnd == hHelpWin)) ||\r
2800                            GetHideUI() == YES ||\r
2801                         &n