OSDN Git Service

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