OSDN Git Service

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