OSDN Git Service

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