OSDN Git Service

Change the character code of windows into UTF-16 completely.
[ffftp/ffftp.git] / bookmark.c
1 /*=============================================================================\r
2 *\r
3 *                                                               ブックマーク\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 // UTF-8対応\r
31 //#define WINVER 0x400\r
32 \r
33 #define STRICT\r
34 // IPv6対応\r
35 #include <winsock2.h>\r
36 #include <windows.h>\r
37 #include <stdio.h>\r
38 #include <stdlib.h>\r
39 #include <string.h>\r
40 #include <mbstring.h>\r
41 #include <malloc.h>\r
42 #include <windowsx.h>\r
43 #include <commctrl.h>\r
44 \r
45 #include "common.h"\r
46 #include "resource.h"\r
47 \r
48 #include <htmlhelp.h>\r
49 #include "helpid.h"\r
50 \r
51 // UTF-8対応\r
52 #undef __MBSWRAPPER_H__\r
53 #include "mbswrapper.h"\r
54 \r
55 \r
56 /*===== プロトタイプ =====*/\r
57 \r
58 static int AddBookMark(char *Path);\r
59 static int GetBothPath(char *Str, char **Path1, char **Path2);\r
60 static BOOL CALLBACK EditBookMarkProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
61 static BOOL CALLBACK BookMarkEditCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
62 \r
63 /*===== 外部参照 =====*/\r
64 \r
65 extern HWND hHelpWin;\r
66 \r
67 /* 設定値 */\r
68 extern HFONT ListFont;          /* リストボックスのフォント */\r
69 extern SIZE BmarkDlgSize;\r
70 \r
71 \r
72 \r
73 /*----- ブックマークをクリアする ----------------------------------------------\r
74 *\r
75 *       Parameter\r
76 *               なし\r
77 *\r
78 *       Return Value\r
79 *               なし\r
80 *----------------------------------------------------------------------------*/\r
81 \r
82 void ClearBookMark(void)\r
83 {\r
84         HMENU hMenu;\r
85 \r
86         hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
87         while(GetMenuItemCount(hMenu) > DEFAULT_BMARK_ITEM)\r
88                 DeleteMenu(hMenu, DEFAULT_BMARK_ITEM, MF_BYPOSITION);\r
89         return;\r
90 }\r
91 \r
92 \r
93 /*----- カレントディレクトリをブックマークに追加 ------------------------------\r
94 *\r
95 *       Parameter\r
96 *               int Win : ウインドウ番号 (WIN_xxx)\r
97 *\r
98 *       Return Value\r
99 *               なし\r
100 *----------------------------------------------------------------------------*/\r
101 \r
102 void AddCurDirToBookMark(int Win)\r
103 {\r
104         char Buf[BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN + 1];\r
105 \r
106         if(Win == WIN_LOCAL)\r
107         {\r
108                 strcpy(Buf, BMARK_MARK_LOCAL);\r
109                 AskLocalCurDir(Buf + BMARK_MARK_LEN, FMAX_PATH);\r
110         }\r
111         else if(Win == WIN_REMOTE)\r
112         {\r
113                 strcpy(Buf, BMARK_MARK_REMOTE);\r
114                 AskRemoteCurDir(Buf + BMARK_MARK_LEN, FMAX_PATH);\r
115         }\r
116         else\r
117         {\r
118                 strcpy(Buf, BMARK_MARK_BOTH);\r
119                 AskLocalCurDir(Buf + BMARK_MARK_LEN, FMAX_PATH);\r
120                 strcat(Buf, BMARK_SEP);\r
121                 AskRemoteCurDir(Buf + strlen(Buf), FMAX_PATH);\r
122         }\r
123         AddBookMark(Buf);\r
124         return;\r
125 }\r
126 \r
127 \r
128 /*----- ブックマークにパスを登録する ------------------------------------------\r
129 *\r
130 *       Parameter\r
131 *               char *Path : パス名\r
132 *\r
133 *       Return Value\r
134 *               int ステータス\r
135 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
136 *----------------------------------------------------------------------------*/\r
137 \r
138 static int AddBookMark(char *Path)\r
139 {\r
140         HMENU hMenu;\r
141         int MarkID;\r
142         int Sts;\r
143 \r
144         Sts = FFFTP_FAIL;\r
145         hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
146         MarkID = (GetMenuItemCount(hMenu) - DEFAULT_BMARK_ITEM) + MENU_BMARK_TOP;\r
147         if(AppendMenu(hMenu, MF_STRING, MarkID, Path) == TRUE)\r
148                 Sts = FFFTP_SUCCESS;\r
149         return(Sts);\r
150 }\r
151 \r
152 \r
153 /*----- 指定のIDを持つブックマークのパスを返す --------------------------------\r
154 *\r
155 *       Parameter\r
156 *               int MarkID : ID\r
157 *               char *Local : ローカル側のパスを返すバッファ\r
158 *               char *Remote : リモート側のパスを返すバッファ\r
159 *               int Max : バッファのサイズ\r
160 *\r
161 *       Return Value\r
162 *               int ステータス (BMARK_TYPE_xxx)\r
163 *----------------------------------------------------------------------------*/\r
164 \r
165 int AskBookMarkText(int MarkID, char *Local, char *Remote, int Max)\r
166 {\r
167         HMENU hMenu;\r
168         MENUITEMINFO mInfo;\r
169         int Sts;\r
170         char Tmp[BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN + 1];\r
171         char *Path1;\r
172         char *Path2;\r
173         int Num;\r
174 \r
175         memset(Local, NUL, Max);\r
176         memset(Remote, NUL, Max);\r
177 \r
178         Sts = BMARK_TYPE_NONE;\r
179         hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
180 \r
181         mInfo.cbSize = sizeof(MENUITEMINFO);\r
182         mInfo.fMask = MIIM_TYPE;\r
183         mInfo.dwTypeData = Tmp;\r
184         mInfo.cch = BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN;\r
185         if(GetMenuItemInfo(hMenu, MarkID, FALSE, &mInfo) == TRUE)\r
186         {\r
187                 Num = GetBothPath(Tmp, &Path1, &Path2);\r
188                 if(strncmp(Tmp, BMARK_MARK_LOCAL, BMARK_MARK_LEN) == 0)\r
189                 {\r
190                         Sts = BMARK_TYPE_LOCAL;\r
191                         strncpy(Local, Path1, Max-1);\r
192                 }\r
193                 else if(strncmp(Tmp, BMARK_MARK_REMOTE, BMARK_MARK_LEN) == 0)\r
194                 {\r
195                         Sts = BMARK_TYPE_REMOTE;\r
196                         strncpy(Remote, Path1, Max-1);\r
197                 }\r
198                 else if(strncmp(Tmp, BMARK_MARK_BOTH, BMARK_MARK_LEN) == 0)\r
199                 {\r
200                         if(Num == 2)\r
201                         {\r
202                                 strncpy(Local, Path1, Max-1);\r
203                                 strncpy(Remote, Path2, Max-1);\r
204                                 Sts = BMARK_TYPE_BOTH;\r
205                         }\r
206                 }\r
207         }\r
208         return(Sts);\r
209 }\r
210 \r
211 \r
212 /*----- ブックマークの文字列から2つのパスを取り出す --------------------------\r
213 *\r
214 *       Parameter\r
215 *               char *Str : 文字列\r
216 *               char **Local : ローカル側のパスの先頭を返すワーク\r
217 *               char **Remote : リモート側のパスの先頭を返すワーク\r
218 *\r
219 *       Return Value\r
220 *               int パスの個数 (1 or 2)\r
221 *\r
222 *       Note\r
223 *               Strの内容を書き換える\r
224 *----------------------------------------------------------------------------*/\r
225 \r
226 static int GetBothPath(char *Str, char **Path1, char **Path2)\r
227 {\r
228         char *Pos;\r
229         int Ret;\r
230 \r
231         Ret = 1;\r
232         *Path1 = Str + BMARK_MARK_LEN;\r
233 \r
234         Pos = _mbsstr(Str, BMARK_SEP);\r
235         if(Pos != NULL)\r
236         {\r
237                 Ret = 2;\r
238                 *Pos = NUL;\r
239                 *Path2 = Pos + BMARK_SEP_LEN;\r
240         }\r
241         return(Ret);\r
242 }\r
243 \r
244 \r
245 /*----- ブックマークを接続中のホストリストに保存する --------------------------\r
246 *\r
247 *       Parameter\r
248 *               なし\r
249 *\r
250 *       Return Value\r
251 *               なし\r
252 *----------------------------------------------------------------------------*/\r
253 \r
254 void SaveBookMark(void)\r
255 {\r
256         HMENU hMenu;\r
257         MENUITEMINFO mInfo;\r
258         int i;\r
259         int Cnt;\r
260         char *Buf;\r
261         char *Pos;\r
262         int Len;\r
263         char Tmp[BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN + 1];\r
264         int CurHost;\r
265 \r
266         if(AskConnecting() == YES)\r
267         {\r
268                 if((CurHost = AskCurrentHost()) != HOSTNUM_NOENTRY)\r
269                 {\r
270                         if((Buf = malloc(BOOKMARK_SIZE)) != NULL)\r
271                         {\r
272                                 hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
273 \r
274                                 Pos = Buf;\r
275                                 Len = 0;\r
276                                 Cnt = GetMenuItemCount(hMenu);\r
277                                 for(i = DEFAULT_BMARK_ITEM; i < Cnt; i++)\r
278                                 {\r
279                                         mInfo.cbSize = sizeof(MENUITEMINFO);\r
280                                         mInfo.fMask = MIIM_TYPE;\r
281                                         mInfo.dwTypeData = Tmp;\r
282                                         mInfo.cch = FMAX_PATH;\r
283                                         if(GetMenuItemInfo(hMenu, i, TRUE, &mInfo) == TRUE)\r
284                                         {\r
285                                                 if(Len + strlen(Tmp) + 2 <= BOOKMARK_SIZE)\r
286                                                 {\r
287                                                         strcpy(Pos, Tmp);\r
288                                                         Pos += strlen(Tmp) + 1;\r
289                                                         Len += strlen(Tmp) + 1;\r
290                                                 }\r
291                                         }\r
292                                 }\r
293 \r
294                                 if(Pos == Buf)\r
295                                 {\r
296                                         memset(Buf, NUL, 2);\r
297                                         Len = 2;\r
298                                 }\r
299                                 else\r
300                                 {\r
301                                         *Pos = NUL;\r
302                                         Len++;\r
303                                 }\r
304 \r
305                                 SetHostBookMark(CurHost, Buf, Len);\r
306 \r
307                                 free(Buf);\r
308                         }\r
309                 }\r
310         }\r
311         return;\r
312 }\r
313 \r
314 \r
315 /*----- ホストリストからブックマークを読み込む --------------------------------\r
316 *\r
317 *       Parameter\r
318 *               なし\r
319 *\r
320 *       Return Value\r
321 *               なし\r
322 *----------------------------------------------------------------------------*/\r
323 \r
324 void LoadBookMark(void)\r
325 {\r
326         char *Buf;\r
327         char *Pos;\r
328         int CurHost;\r
329         char Tmp[FMAX_PATH + BMARK_MARK_LEN + 1];\r
330 \r
331         if(AskConnecting() == YES)\r
332         {\r
333                 if((CurHost = AskCurrentHost()) != HOSTNUM_NOENTRY)\r
334                 {\r
335                         if((Buf = AskHostBookMark(CurHost)) != NULL)\r
336                         {\r
337                                 ClearBookMark();\r
338                                 Pos = Buf;\r
339                                 while(*Pos != NUL)\r
340                                 {\r
341                                         /* 旧フォーマットのための処理 */\r
342                                         /* (パスに"L"や"H"がついてない物) */\r
343                                         if((strncmp(Pos, BMARK_MARK_LOCAL, BMARK_MARK_LEN) != 0) &&\r
344                                            (strncmp(Pos, BMARK_MARK_REMOTE, BMARK_MARK_LEN) != 0) &&\r
345                                            (strncmp(Pos, BMARK_MARK_BOTH, BMARK_MARK_LEN) != 0))\r
346                                         {\r
347                                                 strcpy(Tmp, BMARK_MARK_REMOTE);\r
348                                                 strcat(Tmp, Pos);\r
349                                                 AddBookMark(Tmp);\r
350                                         }\r
351                                         else\r
352                                                 AddBookMark(Pos);\r
353 \r
354                                         Pos += strlen(Pos) + 1;\r
355                                 }\r
356                         }\r
357                 }\r
358         }\r
359         return;\r
360 }\r
361 \r
362 \r
363 /*----- ブックマーク編集ウインドウ --------------------------------------------\r
364 *\r
365 *       Parameter\r
366 *               なし\r
367 *\r
368 *       Return Value\r
369 *               ステータス (YES=実行/NO=取消)\r
370 *----------------------------------------------------------------------------*/\r
371 \r
372 int EditBookMark(void)\r
373 {\r
374         int Sts;\r
375 \r
376         Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(bmark_dlg), GetMainHwnd(), EditBookMarkProc);\r
377         return(Sts);\r
378 }\r
379 \r
380 \r
381 /*----- ブックマーク編集ウインドウのコールバック ------------------------------\r
382 *\r
383 *       Parameter\r
384 *               HWND hDlg : ウインドウハンドル\r
385 *               UINT message : メッセージ番号\r
386 *               WPARAM wParam : メッセージの WPARAM 引数\r
387 *               LPARAM lParam : メッセージの LPARAM 引数\r
388 *\r
389 *       Return Value\r
390 *               BOOL TRUE/FALSE\r
391 *----------------------------------------------------------------------------*/\r
392 \r
393 static BOOL CALLBACK EditBookMarkProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
394 {\r
395         HMENU hMenu;\r
396         MENUITEMINFO mInfo;\r
397         int Cur;\r
398         int Max;\r
399         char Tmp[BMARK_MARK_LEN + FMAX_PATH * 2 + BMARK_SEP_LEN + 1];\r
400 \r
401         static DIALOGSIZE DlgSize = {\r
402                 { BMARK_NEW, BMARK_SET, BMARK_DEL, BMARK_DOWN, BMARK_UP, IDHELP, BMARK_SIZEGRIP, -1 },\r
403                 { IDOK, BMARK_JUMP, BMARK_SIZEGRIP, -1 },\r
404                 { BMARK_LIST, -1 },\r
405                 { 0, 0 },\r
406                 { 0, 0 }\r
407         };\r
408 \r
409         switch (message)\r
410         {\r
411                 case WM_INITDIALOG :\r
412                         if(ListFont != NULL)\r
413                                 SendDlgItemMessage(hDlg, BMARK_LIST, WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
414 \r
415                         hMenu = GetSubMenu(GetMenu(GetMainHwnd()), BMARK_SUB_MENU);\r
416                         Max = GetMenuItemCount(hMenu);\r
417                         for(Cur = DEFAULT_BMARK_ITEM; Cur < Max; Cur++)\r
418                         {\r
419                                 mInfo.cbSize = sizeof(MENUITEMINFO);\r
420                                 mInfo.fMask = MIIM_TYPE;\r
421                                 mInfo.dwTypeData = Tmp;\r
422                                 mInfo.cch = FMAX_PATH;\r
423                                 if(GetMenuItemInfo(hMenu, Cur, TRUE, &mInfo) == TRUE)\r
424                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_ADDSTRING, 0, (LPARAM)Tmp);\r
425                         }\r
426                         DlgSizeInit(hDlg, &DlgSize, &BmarkDlgSize);\r
427                     return(TRUE);\r
428 \r
429                 case WM_COMMAND :\r
430                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
431                         {\r
432                                 case BMARK_JUMP :\r
433                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
434                                                 PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(Cur+MENU_BMARK_TOP, 0), 0);\r
435                                         /* ここに break はない */\r
436 \r
437                                 case IDCANCEL :\r
438                                 case IDOK :\r
439                                         ClearBookMark();\r
440                                         Max = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0);\r
441                                         for(Cur = 0; Cur < Max; Cur++)\r
442                                         {\r
443                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETTEXT, Cur, (LPARAM)Tmp);\r
444                                                 AddBookMark(Tmp);\r
445                                         }\r
446                                         AskDlgSize(hDlg, &DlgSize, &BmarkDlgSize);\r
447                                         EndDialog(hDlg, YES);\r
448                                         break;\r
449 \r
450                                 case BMARK_SET :\r
451                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
452                                         {\r
453                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETTEXT, Cur, (LPARAM)Tmp);\r
454                                                 if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(bmark_edit_dlg), hDlg, BookMarkEditCallBack, (LPARAM)Tmp) == YES)\r
455                                                 {\r
456                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_DELETESTRING, Cur, 0);\r
457                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_INSERTSTRING, Cur, (LPARAM)Tmp);\r
458                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
459                                                 }\r
460                                         }\r
461                                         break;\r
462 \r
463                                 case BMARK_NEW :\r
464                                         strcpy(Tmp, "");\r
465                                         if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(bmark_edit_dlg), hDlg, BookMarkEditCallBack, (LPARAM)Tmp) == YES)\r
466                                         {\r
467                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_ADDSTRING, 0, (LPARAM)Tmp);\r
468                                                 Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0) - 1;\r
469                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
470                                         }\r
471                                         break;\r
472 \r
473                                 case BMARK_DEL :\r
474                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
475                                         {\r
476                                                 SendDlgItemMessage(hDlg, BMARK_LIST, LB_DELETESTRING, Cur, 0);\r
477                                                 if(Cur >= SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0))\r
478                                                         Cur = max1(0, SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0)-1);\r
479                                                 if(SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0) > 0)\r
480                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
481                                         }\r
482                                         break;\r
483 \r
484                                 case BMARK_UP :\r
485                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
486                                         {\r
487                                                 if(Cur > 0)\r
488                                                 {\r
489                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETTEXT, Cur, (LPARAM)Tmp);\r
490                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_DELETESTRING, Cur, 0);\r
491                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_INSERTSTRING, --Cur, (LPARAM)Tmp);\r
492                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
493                                                 }\r
494                                         }\r
495                                         break;\r
496 \r
497                                 case BMARK_DOWN :\r
498                                         if((Cur = SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCURSEL, 0, 0)) != LB_ERR)\r
499                                         {\r
500                                                 if(Cur < SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETCOUNT, 0, 0)-1)\r
501                                                 {\r
502                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_GETTEXT, Cur, (LPARAM)Tmp);\r
503                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_DELETESTRING, Cur, 0);\r
504                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_INSERTSTRING, ++Cur, (LPARAM)Tmp);\r
505                                                         SendDlgItemMessage(hDlg, BMARK_LIST, LB_SETCURSEL, Cur, 0);\r
506                                                 }\r
507                                         }\r
508                                         break;\r
509 \r
510                                 case IDHELP :\r
511                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000019);\r
512                                         break;\r
513                         }\r
514                         return(TRUE);\r
515 \r
516                 case WM_SIZING :\r
517                         DlgSizeChange(hDlg, &DlgSize, (RECT *)lParam, (int)wParam);\r
518                     return(TRUE);\r
519 \r
520         }\r
521     return(FALSE);\r
522 }\r
523 \r
524 \r
525 /*----- ブックマーク入力ダイアログのコールバック ------------------------------\r
526 *\r
527 *       Parameter\r
528 *               HWND hDlg : ウインドウハンドル\r
529 *               UINT message : メッセージ番号\r
530 *               WPARAM wParam : メッセージの WPARAM 引数\r
531 *               LPARAM lParam : メッセージの LPARAM 引数\r
532 *\r
533 *       Return Value\r
534 *               BOOL TRUE/FALSE\r
535 *----------------------------------------------------------------------------*/\r
536 \r
537 static BOOL CALLBACK BookMarkEditCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
538 {\r
539         static char *Str;\r
540         char *Path1;\r
541         char *Path2;\r
542         char Local[FMAX_PATH+1];\r
543         char Remote[FMAX_PATH+1];\r
544         int Num;\r
545 \r
546         switch (iMessage)\r
547         {\r
548                 case WM_INITDIALOG :\r
549                         Str = (char *)lParam;\r
550                         SendDlgItemMessage(hDlg, BEDIT_LOCAL, EM_LIMITTEXT, FMAX_PATH-1, 0);\r
551                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, EM_LIMITTEXT, FMAX_PATH-1, 0);\r
552                         if(strlen(Str) > BMARK_MARK_LEN)\r
553                         {\r
554                                 Num = GetBothPath(Str, &Path1, &Path2);\r
555                                 if(strncmp(Str, BMARK_MARK_LOCAL, BMARK_MARK_LEN) == 0)\r
556                                         SendDlgItemMessage(hDlg, BEDIT_LOCAL, WM_SETTEXT, 0, (LPARAM)Path1);\r
557                                 else if(strncmp(Str, BMARK_MARK_REMOTE, BMARK_MARK_LEN) == 0)\r
558                                 {\r
559                                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, WM_SETTEXT, 0, (LPARAM)Path1);\r
560                                         /* ホスト側にカーソルを移動しておく */\r
561                                         SetFocus(GetDlgItem(hDlg, BEDIT_REMOTE));\r
562                                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, EM_SETSEL, 0, -1);\r
563                                         return(FALSE);\r
564                                 }\r
565                                 else if((strncmp(Str, BMARK_MARK_BOTH, BMARK_MARK_LEN) == 0) && (Num == 2))\r
566                                 {\r
567                                         SendDlgItemMessage(hDlg, BEDIT_LOCAL, WM_SETTEXT, 0, (LPARAM)Path1);\r
568                                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, WM_SETTEXT, 0, (LPARAM)Path2);\r
569                                 }\r
570                         }\r
571                         return(TRUE);\r
572 \r
573                 case WM_COMMAND :\r
574                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
575                         {\r
576                                 case IDOK :\r
577                                         SendDlgItemMessage(hDlg, BEDIT_LOCAL, WM_GETTEXT, FMAX_PATH+1, (LPARAM)Local);\r
578                                         SendDlgItemMessage(hDlg, BEDIT_REMOTE, WM_GETTEXT, FMAX_PATH+1, (LPARAM)Remote);\r
579                                         if(strlen(Local) > 0)\r
580                                         {\r
581                                                 if(strlen(Remote) > 0)\r
582                                                 {\r
583                                                         /* 両方 */\r
584                                                         strcpy(Str, BMARK_MARK_BOTH);\r
585                                                         strcat(Str, Local);\r
586                                                         strcat(Str, BMARK_SEP);\r
587                                                         strcat(Str, Remote);\r
588                                                 }\r
589                                                 else\r
590                                                 {\r
591                                                         /* ローカルのみ */\r
592                                                         strcpy(Str, BMARK_MARK_LOCAL);\r
593                                                         strcat(Str, Local);\r
594                                                 }\r
595                                                 EndDialog(hDlg, YES);\r
596                                         }\r
597                                         else if(strlen(Remote) > 0)\r
598                                         {\r
599                                                 /* ホストのみ */\r
600                                                 strcpy(Str, BMARK_MARK_REMOTE);\r
601                                                 strcat(Str, Remote);\r
602                                                 EndDialog(hDlg, YES);\r
603                                         }\r
604                                         else\r
605                                                 EndDialog(hDlg, NO);\r
606                                         break;\r
607 \r
608                                 case IDCANCEL :\r
609                                         EndDialog(hDlg, NO);\r
610                                         break;\r
611                         }\r
612             return(TRUE);\r
613         }\r
614         return(FALSE);\r
615 }\r
616 \r
617 \r