| 1 |
#include <windows.h> |
| 2 |
#include <commctrl.h> |
| 3 |
#include <tchar.h> |
| 4 |
|
| 5 |
#if defined(PLATFORM_BE500) |
| 6 |
#include <CSO.h> |
| 7 |
#endif |
| 8 |
|
| 9 |
#include "Tombo.h" |
| 10 |
#include "VarBuffer.h" |
| 11 |
#include "MainFrame.h" |
| 12 |
#include "resource.h" |
| 13 |
#include "Message.h" |
| 14 |
#include "Property.h" |
| 15 |
#include "TString.h" |
| 16 |
#include "SipControl.h" |
| 17 |
#include "TreeViewItem.h" |
| 18 |
#include "GrepDialog.h" |
| 19 |
#include "FilterCtlDlg.h" |
| 20 |
#include "VFManager.h" |
| 21 |
#include "BookMark.h" |
| 22 |
#include "DialogTemplate.h" |
| 23 |
#include "BookMarkDlg.h" |
| 24 |
#include "StatusBar.h" |
| 25 |
#include "PlatformLayer.h" |
| 26 |
#include "TomboURI.h" |
| 27 |
#include "Repository.h" |
| 28 |
|
| 29 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5) |
| 30 |
#include "DialogTemplate.h" |
| 31 |
#include "DetailsViewDlg.h" |
| 32 |
#endif |
| 33 |
|
| 34 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5) |
| 35 |
#include <Aygshell.h> |
| 36 |
#include <Imm.h> |
| 37 |
#endif |
| 38 |
#if defined(PLATFORM_PSPC) |
| 39 |
#include <Aygshell.h> |
| 40 |
extern "C" { |
| 41 |
// ?? may be deleted Imm.h ?? |
| 42 |
UINT WINAPI ImmGetVirtualKey(HWND); |
| 43 |
}; |
| 44 |
#endif |
| 45 |
|
| 46 |
#include "AboutDialog.h" |
| 47 |
#include "SearchDlg.h" |
| 48 |
#include "SearchEngine.h" |
| 49 |
#include "SearchTree.h" |
| 50 |
|
| 51 |
#include "Region.h" |
| 52 |
#include "YAEdit.h" |
| 53 |
#include "YAEditor.h" |
| 54 |
|
| 55 |
LPCTSTR MainFrame::pClassName = TOMBO_MAIN_FRAME_WINDOW_CLSS; |
| 56 |
|
| 57 |
static LRESULT CALLBACK MainFrameWndProc(HWND, UINT, WPARAM, LPARAM); |
| 58 |
static HIMAGELIST CreateSelectViewImageList(HINSTANCE hInst); |
| 59 |
|
| 60 |
#define SHGetMenu(hWndMB) (HMENU)SendMessage((hWndMB), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0) |
| 61 |
#define SHGetSubMenu(hWndMB,ID_MENU) (HMENU)SendMessage((hWndMB), SHCMBM_GETSUBMENU, (WPARAM)0, (LPARAM)ID_MENU) |
| 62 |
#define SHSetSubMenu(hWndMB,ID_MENU) (HMENU)SendMessage((hWndMB), SHCMBM_SETSUBMENU, (WPARAM)0, (LPARAM)ID_MENU) |
| 63 |
|
| 64 |
// splitter width |
| 65 |
#if defined(PLATFORM_WIN32) |
| 66 |
#define BORDER_WIDTH 2 |
| 67 |
#endif |
| 68 |
#if defined(PLATFORM_HPC) || defined(PLATFORM_PKTPC) || defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) || defined(PLATFORM_WM5) |
| 69 |
#if defined(FOR_VGA) |
| 70 |
#define BORDER_WIDTH 10 |
| 71 |
#else |
| 72 |
#define BORDER_WIDTH 5 |
| 73 |
#endif |
| 74 |
#endif |
| 75 |
|
| 76 |
// Bookmark menu ID base value |
| 77 |
#define BOOKMARK_ID_BASE 41000 |
| 78 |
|
| 79 |
/////////////////////////////////////// |
| 80 |
// ctor |
| 81 |
/////////////////////////////////////// |
| 82 |
|
| 83 |
MainFrame::MainFrame() : bResizePane(FALSE), //bSelectViewActive(FALSE), |
| 84 |
vtFocusedView(VT_Unknown), |
| 85 |
pBookMark(NULL), pDetailsView(NULL), pPlatform(NULL), lCurrentLayout(LT_Unknown) |
| 86 |
{ |
| 87 |
} |
| 88 |
|
| 89 |
/////////////////////////////////////// |
| 90 |
// dtor |
| 91 |
/////////////////////////////////////// |
| 92 |
|
| 93 |
MainFrame::~MainFrame() |
| 94 |
{ |
| 95 |
delete pDetailsView; |
| 96 |
delete pBookMark; |
| 97 |
delete pPlatform; |
| 98 |
} |
| 99 |
|
| 100 |
/////////////////////////////////////// |
| 101 |
// Regist window class |
| 102 |
/////////////////////////////////////// |
| 103 |
|
| 104 |
BOOL MainFrame::RegisterClass(HINSTANCE hInst) |
| 105 |
{ |
| 106 |
WNDCLASS wc; |
| 107 |
|
| 108 |
wc.style = 0; |
| 109 |
wc.lpfnWndProc = (WNDPROC)MainFrameWndProc; |
| 110 |
wc.cbClsExtra = 0; |
| 111 |
wc.cbWndExtra = sizeof(LONG); |
| 112 |
wc.hInstance = hInst; |
| 113 |
wc.hIcon = NULL; |
| 114 |
#if defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) |
| 115 |
wc.hCursor = NULL; |
| 116 |
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); |
| 117 |
#else |
| 118 |
wc.hCursor = NULL; |
| 119 |
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; |
| 120 |
#endif |
| 121 |
#if defined(PLATFORM_WIN32) |
| 122 |
wc.hCursor = LoadCursor(NULL, IDC_SIZEWE); |
| 123 |
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; |
| 124 |
#endif |
| 125 |
wc.lpszMenuName = NULL; |
| 126 |
wc.lpszClassName = pClassName; |
| 127 |
|
| 128 |
::RegisterClass(&wc); |
| 129 |
return TRUE; |
| 130 |
} |
| 131 |
|
| 132 |
/////////////////////////////////////////////////// |
| 133 |
// Event Handler |
| 134 |
/////////////////////////////////////////////////// |
| 135 |
|
| 136 |
static LRESULT CALLBACK MainFrameWndProc(HWND hWnd, UINT nMessage, WPARAM wParam, LPARAM lParam) |
| 137 |
{ |
| 138 |
if (nMessage == WM_CREATE) { |
| 139 |
LPCREATESTRUCT pCS = (LPCREATESTRUCT)lParam; |
| 140 |
MainFrame *frm = (MainFrame*)pCS->lpCreateParams; |
| 141 |
SetWindowLong(hWnd, 0, (LONG)frm); |
| 142 |
frm->OnCreate(hWnd, wParam, lParam); |
| 143 |
return 0; |
| 144 |
} |
| 145 |
|
| 146 |
MainFrame *frm = (MainFrame*)GetWindowLong(hWnd, 0); |
| 147 |
if (frm == NULL) { |
| 148 |
return DefWindowProc(hWnd, nMessage, wParam, lParam); |
| 149 |
} |
| 150 |
|
| 151 |
BOOL bRes; |
| 152 |
switch(nMessage) { |
| 153 |
case WM_CLOSE: |
| 154 |
return frm->OnExit(); |
| 155 |
case WM_COMMAND: |
| 156 |
frm->OnCommand(hWnd, wParam, lParam); |
| 157 |
return 0; |
| 158 |
case WM_NOTIFY: |
| 159 |
bRes = frm->OnNotify(hWnd, wParam, lParam); |
| 160 |
if (bRes != 0xFFFFFFFF) return bRes; |
| 161 |
break; |
| 162 |
case MWM_SWITCH_VIEW: |
| 163 |
frm->ActivateView(MainFrame::VT_DetailsView); |
| 164 |
return 0; |
| 165 |
case WM_SETFOCUS: |
| 166 |
frm->SetFocus(); |
| 167 |
return 0; |
| 168 |
case WM_SETTINGCHANGE: |
| 169 |
frm->OnSettingChange(wParam); |
| 170 |
return 0; |
| 171 |
case WM_TIMER: |
| 172 |
frm->OnTimer(wParam); |
| 173 |
return 0; |
| 174 |
case WM_SIZE: |
| 175 |
frm->OnResize(wParam, lParam); |
| 176 |
break; |
| 177 |
case WM_HOTKEY: |
| 178 |
// �n���h�������������������������n���h�� |
| 179 |
if (frm->OnHotKey(wParam, lParam)) return 0; |
| 180 |
break; |
| 181 |
case WM_LBUTTONDOWN: |
| 182 |
if (g_Property.GetUseTwoPane()) { |
| 183 |
// �y�C���z�������X�J�n |
| 184 |
frm->OnLButtonDown(wParam, lParam); |
| 185 |
return 0; |
| 186 |
} |
| 187 |
break; |
| 188 |
case WM_MOUSEMOVE: |
| 189 |
if (g_Property.GetUseTwoPane()) { |
| 190 |
// �y�C���z�������X�� |
| 191 |
frm->OnMouseMove(wParam, lParam); |
| 192 |
return 0; |
| 193 |
} |
| 194 |
break; |
| 195 |
case WM_LBUTTONUP: |
| 196 |
if (g_Property.GetUseTwoPane()) { |
| 197 |
// �y�C���z�������X�I�� |
| 198 |
frm->OnLButtonUp(wParam, lParam); |
| 199 |
return 0; |
| 200 |
} |
| 201 |
case MWM_RAISE_MAINFRAME: |
| 202 |
frm->OnMutualExecute(); |
| 203 |
return 0; |
| 204 |
} |
| 205 |
return DefWindowProc(hWnd, nMessage, wParam, lParam); |
| 206 |
} |
| 207 |
|
| 208 |
////////////////////////////////////// |
| 209 |
// message loop |
| 210 |
////////////////////////////////////// |
| 211 |
// ���H������Action�{�^��������������VK_RETURN�������������������������� |
| 212 |
|
| 213 |
//������ACTION�V�[�P���X |
| 214 |
|
| 215 |
//KD VK_F23 1 |
| 216 |
//KU VK_F23 1 |
| 217 |
//KD VK_RETURN 1 |
| 218 |
//KU VK_RETRN 1 |
| 219 |
|
| 220 |
//KD VK_F23(86) 1 |
| 221 |
//KU VK_F23(86) c0000001 |
| 222 |
//KD VK_RETURN(d) 1 |
| 223 |
//KU VK_RETURN(d) c0000001 |
| 224 |
|
| 225 |
//KD VK_PROCESSKEY(e5) 1 |
| 226 |
//KU VK_F23(86) c0000001 |
| 227 |
//KD VK_RETURN(d) 1 |
| 228 |
//KU VK_RETURN(d) c0000001 |
| 229 |
|
| 230 |
#include "File.h" |
| 231 |
#include "Uniconv.h" |
| 232 |
|
| 233 |
int MainFrame::MainLoop() { |
| 234 |
MSG msg; |
| 235 |
|
| 236 |
HACCEL hAccelSv = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDR_ACCEL_SELECT)); |
| 237 |
HACCEL hAccelDv = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDR_ACCEL_DETAIL)); |
| 238 |
|
| 239 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) |
| 240 |
BOOL bIgnoreReturnKeyDown = FALSE; |
| 241 |
BOOL bIgnoreReturnKeyUp = FALSE; |
| 242 |
BOOL bIgnoreEscKeyDown = FALSE; |
| 243 |
BOOL bIgnoreEscKeyUp = FALSE; |
| 244 |
#endif |
| 245 |
|
| 246 |
while(GetMessage(&msg, NULL, 0, 0)) { |
| 247 |
// �p�X���[�h�^�C���A�E�g���� |
| 248 |
pmPasswordMgr.ForgetPasswordIfNotAccessed(); |
| 249 |
if (msg.message == WM_KEYDOWN || msg.message == WM_LBUTTONDOWN) { |
| 250 |
pmPasswordMgr.UpdateAccess(); |
| 251 |
} |
| 252 |
|
| 253 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) |
| 254 |
// �A�N�V�����L�[����������VK_RETURN������ |
| 255 |
|
| 256 |
#if defined(PLATFORM_PKTPC) |
| 257 |
// On PocketPC devices, you can select enable/disable about this feature. |
| 258 |
if (!g_Property.GetDisableExtraActionButton()) { |
| 259 |
//disable logic begin |
| 260 |
#endif |
| 261 |
|
| 262 |
if (msg.message == WM_KEYDOWN) { |
| 263 |
WPARAM w = msg.wParam; |
| 264 |
if (w == VK_PROCESSKEY) { |
| 265 |
w = ImmGetVirtualKey(msg.hwnd); |
| 266 |
} |
| 267 |
if (w == VK_F23) { |
| 268 |
bIgnoreReturnKeyDown = bIgnoreReturnKeyUp = TRUE; |
| 269 |
continue; |
| 270 |
} |
| 271 |
if (w == VK_F24) { |
| 272 |
bIgnoreEscKeyDown = bIgnoreEscKeyUp = TRUE; |
| 273 |
continue; |
| 274 |
} |
| 275 |
if (bIgnoreReturnKeyDown && w == VK_RETURN) { |
| 276 |
bIgnoreReturnKeyDown = FALSE; |
| 277 |
continue; |
| 278 |
} |
| 279 |
if (bIgnoreEscKeyDown && w == VK_ESCAPE) { |
| 280 |
bIgnoreEscKeyDown = FALSE; |
| 281 |
continue; |
| 282 |
} |
| 283 |
} |
| 284 |
if (msg.message == WM_KEYUP) { |
| 285 |
if (msg.wParam == VK_F23) { |
| 286 |
continue; |
| 287 |
} |
| 288 |
if (bIgnoreReturnKeyUp && msg.wParam == VK_RETURN) { |
| 289 |
bIgnoreReturnKeyUp = FALSE; |
| 290 |
PostMessage(hMainWnd, WM_COMMAND, MAKEWPARAM(IDM_ACTIONBUTTON, 0), 0); |
| 291 |
continue; |
| 292 |
} |
| 293 |
if (msg.wParam == VK_F24) { |
| 294 |
continue; |
| 295 |
} |
| 296 |
if (bIgnoreEscKeyUp && msg.wParam == VK_ESCAPE) { |
| 297 |
bIgnoreEscKeyUp = FALSE; |
| 298 |
PostMessage(hMainWnd, WM_COMMAND, MAKEWPARAM(IDM_RETURNLIST, 0), 0); |
| 299 |
continue; |
| 300 |
} |
| 301 |
} |
| 302 |
#if defined(PLATFORM_PKTPC) |
| 303 |
} // disable logic end |
| 304 |
#endif |
| 305 |
|
| 306 |
#endif |
| 307 |
// �{�������� |
| 308 |
if (!TranslateAccelerator(hMainWnd, SelectViewActive() ? hAccelSv : hAccelDv, &msg)) { |
| 309 |
TranslateMessage(&msg); |
| 310 |
DispatchMessage(&msg); |
| 311 |
} |
| 312 |
} |
| 313 |
return msg.wParam; |
| 314 |
} |
| 315 |
|
| 316 |
void MainFrame::NotifyDetailsViewFocused() |
| 317 |
{ |
| 318 |
if (!g_Property.GetUseTwoPane()) return; |
| 319 |
|
| 320 |
SetFocus(MainFrame::VT_DetailsView); |
| 321 |
|
| 322 |
// menu control |
| 323 |
EnableDelete(FALSE); |
| 324 |
EnableRename(FALSE); |
| 325 |
EnableEncrypt(FALSE); |
| 326 |
EnableDecrypt(FALSE); |
| 327 |
EnableNewFolder(FALSE); |
| 328 |
EnableGrep(FALSE); |
| 329 |
|
| 330 |
EnableCut(TRUE); |
| 331 |
EnableCopy(TRUE); |
| 332 |
EnablePaste(TRUE); |
| 333 |
if (pDetailsView) pDetailsView->SetModifyStatus(); |
| 334 |
} |
| 335 |
|
| 336 |
/////////////////////////////////////////////////// |
| 337 |
// Create main window |
| 338 |
/////////////////////////////////////////////////// |
| 339 |
|
| 340 |
BOOL MainFrame::Create(LPCTSTR pWndName, HINSTANCE hInst, int nCmdShow) |
| 341 |
{ |
| 342 |
hInstance = hInst; |
| 343 |
|
| 344 |
YAEditor *pYAE; |
| 345 |
SimpleEditor *pSe; |
| 346 |
if (!g_Property.GetDisableYAEdit()) { |
| 347 |
YAEdit::RegisterClass(hInst); |
| 348 |
|
| 349 |
pYAE = new YAEditor(&mmMemoManager); |
| 350 |
pDetailsView = pYAE; |
| 351 |
} else { |
| 352 |
SimpleEditor::RegisterClass(hInst); |
| 353 |
|
| 354 |
pSe = new SimpleEditor(&mmMemoManager); |
| 355 |
pDetailsView = pSe; |
| 356 |
} |
| 357 |
|
| 358 |
mmMemoManager.Init(this, pDetailsView, &msView); |
| 359 |
msView.Init(&mmMemoManager); |
| 360 |
|
| 361 |
if (!g_Property.GetDisableYAEdit()) { |
| 362 |
pYAE->Init(IDC_TOMBOEDIT); |
| 363 |
} else { |
| 364 |
pSe->Init(IDC_MEMODETAILSVIEW, IDC_MEMODETAILSVIEW_NF); |
| 365 |
} |
| 366 |
|
| 367 |
pVFManager = new VFManager(); |
| 368 |
if (!pVFManager || !pVFManager->Init()) return FALSE; |
| 369 |
|
| 370 |
pBookMark = new BookMark(); |
| 371 |
if (!pBookMark || !pBookMark->Init(BOOKMARK_ID_BASE)) return FALSE; |
| 372 |
|
| 373 |
|
| 374 |
#ifdef _WIN32_WCE |
| 375 |
hMainWnd = CreateWindow(pClassName, pWndName, |
| 376 |
WS_VISIBLE, |
| 377 |
CW_USEDEFAULT, |
| 378 |
CW_USEDEFAULT, |
| 379 |
CW_USEDEFAULT, |
| 380 |
CW_USEDEFAULT, |
| 381 |
NULL, |
| 382 |
NULL, |
| 383 |
hInst, |
| 384 |
this); |
| 385 |
#else |
| 386 |
#if defined(PLATFORM_WIN32) |
| 387 |
hMainWnd = CreateWindow(pClassName, pWndName, |
| 388 |
WS_OVERLAPPEDWINDOW, |
| 389 |
0, |
| 390 |
0, |
| 391 |
640, |
| 392 |
320, |
| 393 |
NULL, |
| 394 |
Win32Platform::LoadMainMenu(), |
| 395 |
hInst, |
| 396 |
this); |
| 397 |
#else |
| 398 |
// debug mode |
| 399 |
hMainWnd = CreateWindow(pClassName, pWndName, |
| 400 |
WS_SYSMENU | WS_THICKFRAME, |
| 401 |
0, |
| 402 |
0, |
| 403 |
240, |
| 404 |
320, |
| 405 |
NULL, |
| 406 |
LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_MAIN)), |
| 407 |
hInst, |
| 408 |
this); |
| 409 |
#endif |
| 410 |
#endif |
| 411 |
|
| 412 |
// set application icon |
| 413 |
SetAppIcon(hInstance, hMainWnd); |
| 414 |
|
| 415 |
// load window positions |
| 416 |
#if defined(PLATFORM_WIN32) |
| 417 |
WINDOWPLACEMENT wpl; |
| 418 |
wpl.length = sizeof(wpl); |
| 419 |
WORD nSelectViewWidth; |
| 420 |
|
| 421 |
if (g_Property.GetWinSize(&(wpl.flags), &(wpl.showCmd), &(wpl.rcNormalPosition), &nSelectViewWidth)) { |
| 422 |
if (!SetWindowPlacement(hMainWnd, &wpl)) { |
| 423 |
UpdateWindow(hMainWnd); |
| 424 |
} |
| 425 |
} else { |
| 426 |
ShowWindow(hMainWnd, nCmdShow); |
| 427 |
UpdateWindow(hMainWnd); |
| 428 |
} |
| 429 |
#else |
| 430 |
ShowWindow(hMainWnd, nCmdShow); |
| 431 |
UpdateWindow(hMainWnd); |
| 432 |
#endif |
| 433 |
|
| 434 |
return TRUE; |
| 435 |
} |
| 436 |
|
| 437 |
/////////////////////////////////////////////////// |
| 438 |
// Initialize window |
| 439 |
/////////////////////////////////////////////////// |
| 440 |
|
| 441 |
void MainFrame::OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 442 |
{ |
| 443 |
hMainWnd = hWnd; |
| 444 |
LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam; |
| 445 |
|
| 446 |
// init password manager |
| 447 |
pmPasswordMgr.Init(hMainWnd, hInstance); |
| 448 |
g_pPassManager = &pmPasswordMgr; |
| 449 |
|
| 450 |
g_pPasswordManager = &pmPasswordMgr; |
| 451 |
|
| 452 |
pPlatform = PLATFORM_TYPE::PlatformFactory(); |
| 453 |
if (!pPlatform || !pPlatform->Init(hMainWnd)) return; |
| 454 |
|
| 455 |
RECT r; |
| 456 |
GetClientRect(hWnd, &r); |
| 457 |
|
| 458 |
// Initialize repository |
| 459 |
g_Repository.Init(); |
| 460 |
DWORD n = g_Property.GetNumSubRepository(); |
| 461 |
for (DWORD i = 0; i < n; i++) { |
| 462 |
RepositoryImpl *pImpl = g_Property.GetSubRepository(i); |
| 463 |
g_Repository.AddSubRepository(pImpl); |
| 464 |
} |
| 465 |
|
| 466 |
// create toolbar |
| 467 |
pPlatform->Create(hWnd, pcs->hInstance); |
| 468 |
|
| 469 |
#if defined(PLATFORM_WIN32) |
| 470 |
pPlatform->ShowRebar(!g_Property.GetHideRebar()); |
| 471 |
#endif |
| 472 |
|
| 473 |
// adjust client area to remove toolbar area |
| 474 |
pPlatform->AdjustUserRect(&r); |
| 475 |
|
| 476 |
// Status Bar |
| 477 |
SetNewMemoStatus(g_Property.GetUseTwoPane()); |
| 478 |
SetModifyStatus(FALSE); |
| 479 |
|
| 480 |
#if defined(PLATFORM_WIN32) || defined(PLATFORM_HPC) |
| 481 |
// control show/hide status bar |
| 482 |
HMENU hMenu = pPlatform->GetMainMenu(); |
| 483 |
if (g_Property.GetHideStatusBar()) { |
| 484 |
CheckMenuItem(hMenu, IDM_SHOWSTATUSBAR, MF_BYCOMMAND | MF_UNCHECKED); |
| 485 |
} else { |
| 486 |
CheckMenuItem(hMenu, IDM_SHOWSTATUSBAR, MF_BYCOMMAND | MF_CHECKED); |
| 487 |
pPlatform->ShowStatusBar(TRUE); |
| 488 |
} |
| 489 |
#endif |
| 490 |
|
| 491 |
pPlatform->CheckMenu(IDM_TOGGLEPANE, g_Property.GetUseTwoPane()); |
| 492 |
|
| 493 |
// Create edit view |
| 494 |
pDetailsView->Create(TEXT("MemoDetails"), r, hWnd, hInstance, g_Property.DetailsViewFont()); |
| 495 |
|
| 496 |
if (!g_Property.GetWrapText()) { |
| 497 |
SetWrapText(g_Property.GetWrapText()); |
| 498 |
} |
| 499 |
|
| 500 |
// Create tree view |
| 501 |
msView.Create(TEXT("MemoSelect"), r, hWnd, IDC_MEMOSELECTVIEW, hInstance, g_Property.SelectViewFont()); |
| 502 |
msView.InitTree(pVFManager); |
| 503 |
|
| 504 |
// set auto switch mode |
| 505 |
if (g_Property.GetUseTwoPane()) { |
| 506 |
msView.SetAutoLoadMode(g_Property.GetAutoSelectMemo()); |
| 507 |
msView.SetSingleClickMode(g_Property.GetSingleClick()); |
| 508 |
} |
| 509 |
|
| 510 |
LoadWinSize(hWnd); |
| 511 |
#if (defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && defined(FOR_VGA) |
| 512 |
// initialize bLandScapeMode |
| 513 |
bLandscapeMode = (r.right - r.left > r.bottom - r.top); |
| 514 |
#endif |
| 515 |
pDetailsView->DiscardMemo(); |
| 516 |
|
| 517 |
if (!EnableApplicationButton(hWnd)) { |
| 518 |
TomboMessageBox(hMainWnd, MSG_INITAPPBTN_FAIL, TEXT("Warning"), MB_ICONEXCLAMATION | MB_OK); |
| 519 |
} |
| 520 |
|
| 521 |
#if defined(PLATFORM_WIN32) |
| 522 |
SetTopMost(); |
| 523 |
#endif |
| 524 |
ActivateView(VT_SelectView); |
| 525 |
|
| 526 |
|
| 527 |
// load bookmark |
| 528 |
LPCTSTR pBM = g_Property.GetBookMark(); |
| 529 |
if (pBM) { |
| 530 |
LoadBookMark(pBM); |
| 531 |
} |
| 532 |
|
| 533 |
BOOL bOpenNote; |
| 534 |
#if defined(PLATFORM_WM5) |
| 535 |
bOpenNote = FALSE; |
| 536 |
#else |
| 537 |
bOpenNote = TRUE; |
| 538 |
#endif |
| 539 |
// open top page |
| 540 |
if (g_Property.GetKeepLastOpen()) { |
| 541 |
if (g_Property.GetLastOpenURI() == NULL) return; |
| 542 |
TomboURI sURI; |
| 543 |
if (!sURI.Init(g_Property.GetLastOpenURI())) return; |
| 544 |
msView.ShowItemByURI(&sURI, TRUE, bOpenNote); |
| 545 |
} else if (_tcslen(g_Property.GetDefaultNote()) != 0) { |
| 546 |
TomboURI sURI; |
| 547 |
if (!sURI.Init(g_Property.GetDefaultNote())) return; |
| 548 |
msView.ShowItemByURI(&sURI, TRUE, bOpenNote); |
| 549 |
} |
| 550 |
} |
| 551 |
|
| 552 |
/////////////////////////////////////////////////// |
| 553 |
// set status indicator on statusbar |
| 554 |
/////////////////////////////////////////////////// |
| 555 |
|
| 556 |
void MainFrame::SetModifyStatus(BOOL bModify) |
| 557 |
{ |
| 558 |
EnableSaveButton(bModify); |
| 559 |
pPlatform->SetStatusIndicator(3, MSG_UPDATE, bModify); |
| 560 |
} |
| 561 |
|
| 562 |
void MainFrame::SetReadOnlyStatus(BOOL bReadOnly) |
| 563 |
{ |
| 564 |
pPlatform->SetStatusIndicator(1, MSG_RONLY, bReadOnly); |
| 565 |
} |
| 566 |
|
| 567 |
void MainFrame::SetNewMemoStatus(BOOL bNew) |
| 568 |
{ |
| 569 |
pPlatform->SetStatusIndicator(2, MSG_NEW, bNew); |
| 570 |
} |
| 571 |
|
| 572 |
/////////////////////////////////////////////////// |
| 573 |
// exiting |
| 574 |
/////////////////////////////////////////////////// |
| 575 |
|
| 576 |
BOOL MainFrame::OnExit() |
| 577 |
{ |
| 578 |
const TomboURI *p = msView.GetCurrentSelectedURI(); |
| 579 |
if (p == NULL) { |
| 580 |
g_Property.SetLastOpenURI(NULL); |
| 581 |
} else { |
| 582 |
g_Property.SetLastOpenURI(p->GetFullURI()); |
| 583 |
} |
| 584 |
|
| 585 |
DWORD nYNC; |
| 586 |
if (!mmMemoManager.SaveIfModify(&nYNC, FALSE)) { |
| 587 |
TCHAR buf[1024]; |
| 588 |
wsprintf(buf, MSG_SAVE_FAILED, GetLastError()); |
| 589 |
TomboMessageBox(hMainWnd, buf, TEXT("ERROR"), MB_ICONSTOP | MB_OK); |
| 590 |
ActivateView(VT_DetailsView); |
| 591 |
return FALSE; |
| 592 |
} |
| 593 |
if (nYNC == IDCANCEL) return FALSE; |
| 594 |
pmPasswordMgr.ForgetPassword(); |
| 595 |
|
| 596 |
SaveWinSize(); |
| 597 |
|
| 598 |
#if defined(PLATFORM_HPC) |
| 599 |
// save rebar info |
| 600 |
COMMANDBANDSRESTOREINFO cbri[NUM_COMMANDBAR]; |
| 601 |
cbri[0].cbSize = cbri[1].cbSize = sizeof(COMMANDBANDSRESTOREINFO); |
| 602 |
CommandBands_GetRestoreInformation(pPlatform->hMSCmdBar, SendMessage(pPlatform->hMSCmdBar, RB_IDTOINDEX, ID_CMDBAR_MAIN, 0), &cbri[0]); |
| 603 |
CommandBands_GetRestoreInformation(pPlatform->hMSCmdBar, SendMessage(pPlatform->hMSCmdBar, RB_IDTOINDEX, ID_BUTTONBAND, 0), &cbri[1]); |
| 604 |
g_Property.SetCommandbarInfo(cbri); |
| 605 |
#endif |
| 606 |
|
| 607 |
// save bookmarks |
| 608 |
LPTSTR pBM = pBookMark->ExportToMultiSZ(); |
| 609 |
g_Property.SetBookMark(pBM); |
| 610 |
delete [] pBM; |
| 611 |
|
| 612 |
// save properties |
| 613 |
if (!g_Property.Save()) { |
| 614 |
MessageBox(MSG_DLG_SAVEPROP_FAILED, TEXT("ERROR"), MB_ICONERROR | MB_OK); |
| 615 |
} |
| 616 |
|
| 617 |
PostQuitMessage(0); |
| 618 |
return TRUE; |
| 619 |
} |
| 620 |
|
| 621 |
/////////////////////////////////////////////////// |
| 622 |
// WM_COMMAND handling |
| 623 |
/////////////////////////////////////////////////// |
| 624 |
|
| 625 |
void MainFrame::OnCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 626 |
{ |
| 627 |
// First, current active view tries to handle WM_COMMAND |
| 628 |
switch(vtFocusedView) { |
| 629 |
case VT_SelectView: |
| 630 |
if (msView.OnCommand(hWnd, wParam, lParam)) return; |
| 631 |
break; |
| 632 |
case VT_DetailsView: |
| 633 |
if (pDetailsView->OnCommand(hWnd, wParam, lParam)) return; |
| 634 |
break; |
| 635 |
} |
| 636 |
|
| 637 |
// if active view can't handle, try to handle main window. |
| 638 |
switch(LOWORD(wParam)) { |
| 639 |
#if defined(PLATFORM_BE500) |
| 640 |
case CSOBAR_ADORNMENTID_CLOSE: |
| 641 |
/* fall through */ |
| 642 |
#endif |
| 643 |
case IDM_EXIT: |
| 644 |
SendMessage(hWnd, WM_CLOSE, 0, 0); |
| 645 |
break; |
| 646 |
case IDM_NEWMEMO: |
| 647 |
NewMemo(); |
| 648 |
break; |
| 649 |
case IDM_NEWFOLDER: |
| 650 |
NewFolder(NULL); |
| 651 |
break; |
| 652 |
case IDM_ABOUT: |
| 653 |
About(); |
| 654 |
break; |
| 655 |
#if defined(PLATFORM_WM5) |
| 656 |
case IDOK: |
| 657 |
LeaveDetailsView(TRUE); |
| 658 |
break; |
| 659 |
#endif |
| 660 |
case IDM_RETURNLIST: |
| 661 |
LeaveDetailsView(TRUE); |
| 662 |
break; |
| 663 |
case IDM_PROPERTY: |
| 664 |
OnProperty(); |
| 665 |
break; |
| 666 |
case IDM_FORGETPASS: |
| 667 |
OnForgetPass(); |
| 668 |
break; |
| 669 |
case IDM_SELALL: |
| 670 |
if (pDetailsView) { pDetailsView->SelectAll(); } |
| 671 |
break; |
| 672 |
case IDM_SAVE: |
| 673 |
if (!mmMemoManager.SaveIfModify(NULL, FALSE)) { |
| 674 |
TCHAR buf[1024]; |
| 675 |
wsprintf(buf, MSG_SAVE_FAILED, GetLastError()); |
| 676 |
TomboMessageBox(NULL, buf, TEXT("ERROR"), MB_ICONERROR | MB_OK); |
| 677 |
} |
| 678 |
break; |
| 679 |
case IDM_DETAILS_HSCROLL: |
| 680 |
g_Property.SetWrapText(!g_Property.GetWrapText()); |
| 681 |
SetWrapText(g_Property.GetWrapText()); |
| 682 |
break; |
| 683 |
case IDM_TOGGLEPANE: |
| 684 |
TogglePane(); |
| 685 |
break; |
| 686 |
#if defined(PLATFORM_WIN32) |
| 687 |
case IDM_TOPMOST: |
| 688 |
g_Property.ToggleStayTopMost(); |
| 689 |
SetTopMost(); |
| 690 |
break; |
| 691 |
#endif |
| 692 |
case IDM_SEARCH: |
| 693 |
OnSearch(); |
| 694 |
break; |
| 695 |
case IDM_SEARCH_NEXT: |
| 696 |
OnSearchNext(TRUE); |
| 697 |
break; |
| 698 |
case IDM_SEARCH_PREV: |
| 699 |
OnSearchNext(FALSE); |
| 700 |
break; |
| 701 |
#if defined(PLATFORM_WIN32) || defined(PLATFORM_HPC) |
| 702 |
case IDM_SHOWSTATUSBAR: |
| 703 |
ToggleShowStatusBar(); |
| 704 |
break; |
| 705 |
#endif |
| 706 |
#if defined(PLATFORM_WIN32) |
| 707 |
case IDM_SHOWREBAR: |
| 708 |
ToggleShowRebar(); |
| 709 |
break; |
| 710 |
#endif |
| 711 |
case IDM_GREP: |
| 712 |
OnGrep(); |
| 713 |
break; |
| 714 |
case IDM_VFOLDER_DEF: |
| 715 |
OnVFolderDef(); |
| 716 |
break; |
| 717 |
case IDM_BOOKMARK_ADD: |
| 718 |
OnBookMarkAdd(hWnd, wParam, lParam); |
| 719 |
break; |
| 720 |
case IDM_BOOKMARK_CONFIG: |
| 721 |
OnBookMarkConfig(hWnd, wParam, lParam); |
| 722 |
break; |
| 723 |
} |
| 724 |
|
| 725 |
if (pBookMark->IsBookMarkID(LOWORD(wParam))) { |
| 726 |
OnBookMark(hWnd, wParam, lParam); |
| 727 |
} |
| 728 |
return; |
| 729 |
} |
| 730 |
|
| 731 |
/////////////////////////////////////////////////// |
| 732 |
// WM_NOTIFY |
| 733 |
/////////////////////////////////////////////////// |
| 734 |
// basically dispatch to each view. |
| 735 |
// return false if dispatch is failed. |
| 736 |
|
| 737 |
BOOL MainFrame::OnNotify(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 738 |
{ |
| 739 |
if (wParam == IDC_MEMOSELECTVIEW) { |
| 740 |
return msView.OnNotify(hWnd, wParam, lParam); |
| 741 |
} |
| 742 |
#if defined(PLATFORM_HPC) |
| 743 |
if (wParam == IDC_CMDBAND) { |
| 744 |
// when move commandbar, Realign MS/MD view. |
| 745 |
NMREBAR *pnm = (NMREBAR*)lParam; |
| 746 |
if (pnm->hdr.code == RBN_HEIGHTCHANGE) { |
| 747 |
RECT r; |
| 748 |
GetClientRect(hMainWnd, &r); |
| 749 |
OnResize(0, MAKELPARAM(r.right - r.left, r.bottom - r.top)); |
| 750 |
} |
| 751 |
} |
| 752 |
#endif |
| 753 |
return FALSE; |
| 754 |
} |
| 755 |
|
| 756 |
/////////////////////////////////////////////////// |
| 757 |
// WM_SETTINGCHANGE |
| 758 |
/////////////////////////////////////////////////// |
| 759 |
|
| 760 |
void MainFrame::OnSettingChange(WPARAM wParam) |
| 761 |
{ |
| 762 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) || defined(PLATFORM_WM5) |
| 763 |
BOOL bStat; |
| 764 |
SipControl sc; |
| 765 |
if (!sc.Init()) return; |
| 766 |
if (!sc.GetSipStat(&bStat)) return; |
| 767 |
|
| 768 |
RECT r = sc.GetRect(); |
| 769 |
OnSIPResize(bStat, &r); |
| 770 |
#endif |
| 771 |
#if defined(PLATFORM_HPC) || defined(PLATFORM_PSPC) |
| 772 |
if (wParam == SPI_SETWORKAREA) { |
| 773 |
// Change taskbar size |
| 774 |
RECT r; |
| 775 |
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); |
| 776 |
MoveWindow(hMainWnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE); |
| 777 |
} |
| 778 |
#endif |
| 779 |
} |
| 780 |
|
| 781 |
/////////////////////////////////////////////////// |
| 782 |
// IM��ON/OFF���������T�C�Y |
| 783 |
/////////////////////////////////////////////////// |
| 784 |
|
| 785 |
void MainFrame::OnSIPResize(BOOL bImeOn, RECT *pSipRect) |
| 786 |
{ |
| 787 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_BE500) || defined(PLATFORM_WM5) |
| 788 |
SetLayout(); |
| 789 |
#endif |
| 790 |
} |
| 791 |
|
| 792 |
/////////////////////////////////////////////////// |
| 793 |
// hotkey events |
| 794 |
/////////////////////////////////////////////////// |
| 795 |
|
| 796 |
BOOL MainFrame::OnHotKey(WPARAM wParam, LPARAM lParam) |
| 797 |
{ |
| 798 |
if (::bDisableHotKey) return FALSE; |
| 799 |
switch (vtFocusedView) { |
| 800 |
case VT_SelectView: |
| 801 |
return msView.OnHotKey(hMainWnd, wParam); |
| 802 |
case VT_DetailsView: |
| 803 |
return pDetailsView->OnHotKey(hMainWnd, wParam); |
| 804 |
} |
| 805 |
return FALSE; |
| 806 |
} |
| 807 |
|
| 808 |
/////////////////////////////////////////////////// |
| 809 |
// Tooltips |
| 810 |
/////////////////////////////////////////////////// |
| 811 |
|
| 812 |
void MainFrame::OnTooltip(WPARAM wParam, LPARAM lParam) |
| 813 |
{ |
| 814 |
} |
| 815 |
|
| 816 |
/////////////////////////////////////////////////// |
| 817 |
// Press left button |
| 818 |
/////////////////////////////////////////////////// |
| 819 |
// |
| 820 |
// start splitter moving |
| 821 |
|
| 822 |
void MainFrame::OnLButtonDown(WPARAM wParam, LPARAM lParam) |
| 823 |
{ |
| 824 |
WORD fwKeys = wParam; |
| 825 |
WORD xPos = LOWORD(lParam); |
| 826 |
|
| 827 |
if (!(fwKeys & MK_LBUTTON)) return; |
| 828 |
bResizePane = TRUE; |
| 829 |
SetCapture(hMainWnd); |
| 830 |
} |
| 831 |
|
| 832 |
/////////////////////////////////////////////////// |
| 833 |
// Dragging |
| 834 |
/////////////////////////////////////////////////// |
| 835 |
|
| 836 |
void MainFrame::OnMouseMove(WPARAM wParam, LPARAM lParam) |
| 837 |
{ |
| 838 |
WORD fwKeys = wParam; |
| 839 |
WORD xPos = LOWORD(lParam); |
| 840 |
|
| 841 |
if (!(fwKeys & MK_LBUTTON) && !bResizePane) return; |
| 842 |
|
| 843 |
RECT rClient; |
| 844 |
GetClientRect(hMainWnd, &rClient); |
| 845 |
|
| 846 |
#if defined(PLATFORM_WIN32) || defined(PLATFORM_HPC) |
| 847 |
|
| 848 |
SHORT yPos = (SHORT)HIWORD(lParam); |
| 849 |
|
| 850 |
SHORT yLimit = (SHORT)rClient.bottom; |
| 851 |
#ifdef COMMENT |
| 852 |
if (!g_Property.HideStatusBar()) { |
| 853 |
RECT rStatBar; |
| 854 |
pPlatform->GetStatusWindowRect(&rStatBar); |
| 855 |
yLimit -= (SHORT)rStatBar.bottom; |
| 856 |
} |
| 857 |
#endif |
| 858 |
if (yPos < 0 || yPos > yLimit) return; |
| 859 |
MovePane(xPos); |
| 860 |
#endif |
| 861 |
} |
| 862 |
|
| 863 |
/////////////////////////////////////////////////// |
| 864 |
// Left button up |
| 865 |
/////////////////////////////////////////////////// |
| 866 |
// |
| 867 |
// end splitter move |
| 868 |
|
| 869 |
void MainFrame::OnLButtonUp(WPARAM wParam, LPARAM lParam) |
| 870 |
{ |
| 871 |
WORD fwKeys = wParam; |
| 872 |
WORD xPos = LOWORD(lParam); |
| 873 |
WORD yPos = HIWORD(lParam); |
| 874 |
|
| 875 |
if (!(fwKeys & MK_LBUTTON) && !bResizePane) return; |
| 876 |
bResizePane = FALSE; |
| 877 |
ReleaseCapture(); |
| 878 |
|
| 879 |
#if defined(PLATFORM_WIN32) || defined(PLATFORM_HPC) |
| 880 |
RECT r; |
| 881 |
GetClientRect(hMainWnd, &r); |
| 882 |
WORD wTotalWidth = (WORD)(r.right - r.left); |
| 883 |
if (xPos < 20) { |
| 884 |
xPos = 20; |
| 885 |
} |
| 886 |
if (xPos > wTotalWidth - 20) { |
| 887 |
xPos = wTotalWidth - 20; |
| 888 |
} |
| 889 |
MovePane(xPos); |
| 890 |
#endif |
| 891 |
#if ((defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && !defined(FOR_VGA)) || defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) |
| 892 |
RECT r; |
| 893 |
GetClientRect(hMainWnd, &r); |
| 894 |
WORD wTotalHeight = (WORD)(r.bottom - r.top); |
| 895 |
if (yPos < 20) { |
| 896 |
yPos = 20; |
| 897 |
} |
| 898 |
if (yPos > wTotalHeight - 20) { |
| 899 |
yPos = wTotalHeight - 20; |
| 900 |
} |
| 901 |
MovePane(yPos); |
| 902 |
#endif |
| 903 |
#if (defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && defined(FOR_VGA) |
| 904 |
RECT r; |
| 905 |
GetClientRect(hMainWnd, &r); |
| 906 |
if (bLandscapeMode) { |
| 907 |
WORD wTotalWidth = (WORD)(r.right - r.left); |
| 908 |
if (xPos < 20) { |
| 909 |
xPos = 20; |
| 910 |
} |
| 911 |
if (xPos >= wTotalWidth - 20) { |
| 912 |
xPos = wTotalWidth - 20; |
| 913 |
} |
| 914 |
MovePane(xPos); |
| 915 |
} else { |
| 916 |
WORD wTotalHeight = (WORD)(r.bottom - r.top); |
| 917 |
if (yPos < 20) { |
| 918 |
yPos = 20; |
| 919 |
} |
| 920 |
if (yPos > wTotalHeight - 20) { |
| 921 |
yPos = wTotalHeight - 20; |
| 922 |
} |
| 923 |
MovePane(yPos); |
| 924 |
} |
| 925 |
#endif |
| 926 |
|
| 927 |
} |
| 928 |
|
| 929 |
/////////////////////////////////////////////////// |
| 930 |
// move pane spliter |
| 931 |
/////////////////////////////////////////////////// |
| 932 |
|
| 933 |
void MainFrame::MovePane(WORD nSplit) |
| 934 |
{ |
| 935 |
if (!g_Property.GetUseTwoPane()) return; |
| 936 |
#if (defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && defined(FOR_VGA) |
| 937 |
if (bLandscapeMode) { |
| 938 |
nSplitterSizeWidth = nSplit; |
| 939 |
} else { |
| 940 |
nSplitterSize = nSplit; |
| 941 |
} |
| 942 |
#else |
| 943 |
nSplitterSize = nSplit; |
| 944 |
#endif |
| 945 |
SetLayout(); |
| 946 |
} |
| 947 |
|
| 948 |
/////////////////////////////////////////////////// |
| 949 |
// Focus window |
| 950 |
/////////////////////////////////////////////////// |
| 951 |
|
| 952 |
void MainFrame::SetFocus(ViewType vt) |
| 953 |
{ |
| 954 |
if (vt != VT_Unknown) { |
| 955 |
vtFocusedView = vt; |
| 956 |
} |
| 957 |
|
| 958 |
switch(vtFocusedView) { |
| 959 |
case VT_SelectView: |
| 960 |
pPlatform->CloseDetailsView(); |
| 961 |
msView.SetFocus(); |
| 962 |
break; |
| 963 |
case VT_DetailsView: |
| 964 |
pPlatform->OpenDetailsView(); |
| 965 |
pDetailsView->SetFocus(); |
| 966 |
break; |
| 967 |
} |
| 968 |
} |
| 969 |
|
| 970 |
/////////////////////////////////////////////////// |
| 971 |
// Create new notes |
| 972 |
/////////////////////////////////////////////////// |
| 973 |
|
| 974 |
void MainFrame::NewMemo() |
| 975 |
{ |
| 976 |
SipControl sc; |
| 977 |
if (!sc.Init() || !sc.SetSipStat(TRUE)) { |
| 978 |
TomboMessageBox(hMainWnd, MSG_GETSIPSTAT_FAILED, TEXT("ERROR"), MB_ICONSTOP | MB_OK); |
| 979 |
} |
| 980 |
|
| 981 |
// if modifying notes, confirm save. |
| 982 |
if (g_Property.GetUseTwoPane()) { |
| 983 |
LeaveDetailsView(TRUE); |
| 984 |
} |
| 985 |
SetNewMemoStatus(TRUE); |
| 986 |
pDetailsView->DiscardMemo(); |
| 987 |
|
| 988 |
// ActivateView(FALSE); |
| 989 |
ActivateView(VT_DetailsView); |
| 990 |
} |
| 991 |
|
| 992 |
/////////////////////////////////////////////////// |
| 993 |
// Create new folder |
| 994 |
/////////////////////////////////////////////////// |
| 995 |
|
| 996 |
void MainFrame::NewFolder(TreeViewItem *pItem) |
| 997 |
{ |
| 998 |
if (!msView.MakeNewFolder(hMainWnd, pItem)) { |
| 999 |
TomboMessageBox(hMainWnd, MSG_CREATEFOLDER_FAILED, TEXT("ERROR"), MB_ICONSTOP | MB_OK); |
| 1000 |
} |
| 1001 |
} |
| 1002 |
|
| 1003 |
/////////////////////////////////////////////////// |
| 1004 |
// version dialog |
| 1005 |
/////////////////////////////////////////////////// |
| 1006 |
|
| 1007 |
void MainFrame::About() |
| 1008 |
{ |
| 1009 |
AboutDialog dlg; |
| 1010 |
BOOL bPrev = bDisableHotKey; |
| 1011 |
bDisableHotKey = TRUE; |
| 1012 |
dlg.Popup(hInstance, hMainWnd); |
| 1013 |
bDisableHotKey = bPrev; |
| 1014 |
} |
| 1015 |
|
| 1016 |
/////////////////////////////////////////////////// |
| 1017 |
// Set note's headline to window title |
| 1018 |
/////////////////////////////////////////////////// |
| 1019 |
|
| 1020 |
void MainFrame::SetWindowTitle(const TomboURI *pURI) |
| 1021 |
{ |
| 1022 |
#if defined(PLATFORM_WIN32) || defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5) |
| 1023 |
if (g_Property.GetSwitchWindowTitle()) { |
| 1024 |
if (pURI == NULL) { |
| 1025 |
SetWindowText(hMainWnd, TOMBO_APP_NAME); |
| 1026 |
return; |
| 1027 |
} |
| 1028 |
|
| 1029 |
// change window title |
| 1030 |
LPCTSTR pPrefix = TEXT("Tombo - "); |
| 1031 |
LPCTSTR pBase; |
| 1032 |
TString sHeadLine; |
| 1033 |
if (g_Repository.GetHeadLine(pURI, &sHeadLine)) { |
| 1034 |
pBase = sHeadLine.Get(); |
| 1035 |
} else { |
| 1036 |
pBase = TEXT(""); |
| 1037 |
} |
| 1038 |
LPCTSTR pWinTitle; |
| 1039 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5) |
| 1040 |
pWinTitle = pBase; |
| 1041 |
#else |
| 1042 |
TString sWinTitle; |
| 1043 |
if (sWinTitle.Join(pPrefix, pBase)) { |
| 1044 |
pWinTitle = sWinTitle.Get(); |
| 1045 |
} else { |
| 1046 |
pWinTitle = pPrefix; |
| 1047 |
} |
| 1048 |
#endif |
| 1049 |
SetWindowText(hMainWnd, pWinTitle); |
| 1050 |
} |
| 1051 |
#endif |
| 1052 |
} |
| 1053 |
|
| 1054 |
void MainFrame::PostSwitchView() |
| 1055 |
{ |
| 1056 |
PostMessage(hMainWnd, MWM_SWITCH_VIEW, (WPARAM)0, (LPARAM)0); |
| 1057 |
} |
| 1058 |
|
| 1059 |
/////////////////////////////////////////////////// |
| 1060 |
// Request open the note |
| 1061 |
/////////////////////////////////////////////////// |
| 1062 |
// switch edit view when bSwitchView is TRUE |
| 1063 |
|
| 1064 |
void MainFrame::OpenDetailsView(const TomboURI *pURI, DWORD nSwitchView) |
| 1065 |
{ |
| 1066 |
URIOption opt(NOTE_OPTIONMASK_ENCRYPTED); |
| 1067 |
if (!g_Repository.GetOption(pURI, &opt)) return; |
| 1068 |
|
| 1069 |
if (((nSwitchView & OPEN_REQUEST_MSVIEW_ACTIVE) == 0) && (opt.bEncrypt && !pmPasswordMgr.IsRememberPassword())) { |
| 1070 |
// bSwitchView��FALSE���A�������J���������p�X���[�h���������������K�v�������������� |
| 1071 |
// �������J������ |
| 1072 |
return; |
| 1073 |
} |
| 1074 |
pDetailsView->LoadNote(pURI); |
| 1075 |
SetNewMemoStatus(FALSE); |
| 1076 |
|
| 1077 |
SetWindowTitle(pURI); |
| 1078 |
|
| 1079 |
if (g_Property.GetUseTwoPane()) { |
| 1080 |
if (nSwitchView & OPEN_REQUEST_MSVIEW_ACTIVE) { |
| 1081 |
ActivateView(VT_DetailsView); |
| 1082 |
} |
| 1083 |
} else { |
| 1084 |
ActivateView(VT_DetailsView); |
| 1085 |
} |
| 1086 |
} |
| 1087 |
|
| 1088 |
/////////////////////////////////////////////////// |
| 1089 |
// load notes |
| 1090 |
/////////////////////////////////////////////////// |
| 1091 |
|
| 1092 |
void MainFrame::LoadMemo(const TomboURI *pURI, BOOL bAskPass) |
| 1093 |
{ |
| 1094 |
URIOption opt(NOTE_OPTIONMASK_ENCRYPTED); |
| 1095 |
if (!g_Repository.GetOption(pURI, &opt)) return; |
| 1096 |
|
| 1097 |
if (opt.bEncrypt && |
| 1098 |
!pmPasswordMgr.IsRememberPassword() && |
| 1099 |
bAskPass == FALSE) { |
| 1100 |
// if TOMBO doesn't keep password even though it is need |
| 1101 |
// and caller don't want to ask password, nothing to do |
| 1102 |
return; |
| 1103 |
} |
| 1104 |
pDetailsView->LoadNote(pURI); |
| 1105 |
SetNewMemoStatus(FALSE); |
| 1106 |
SetWindowTitle(pURI); |
| 1107 |
} |
| 1108 |
|
| 1109 |
/////////////////////////////////////////////////// |
| 1110 |
// leave edit view and return to treeview |
| 1111 |
/////////////////////////////////////////////////// |
| 1112 |
|
| 1113 |
void MainFrame::LeaveDetailsView(BOOL bAskSave) |
| 1114 |
{ |
| 1115 |
SipControl sc; |
| 1116 |
if (!sc.Init() || !sc.SetSipStat(FALSE)) { |
| 1117 |
TomboMessageBox(hMainWnd, MSG_GETSIPSTAT_FAILED, TEXT("ERROR"), MB_ICONSTOP | MB_OK); |
| 1118 |
} |
| 1119 |
|
| 1120 |
DWORD nYNC; |
| 1121 |
BOOL bResult; |
| 1122 |
if (bAskSave) { |
| 1123 |
if (GetKeyState(VK_SHIFT) < 0) { |
| 1124 |
nYNC = IDNO; |
| 1125 |
bResult = TRUE; |
| 1126 |
} else { |
| 1127 |
bResult = mmMemoManager.SaveIfModify(&nYNC, FALSE); |
| 1128 |
} |
| 1129 |
} else { |
| 1130 |
nYNC = IDYES; |
| 1131 |
bResult = mmMemoManager.SaveIfModify(NULL, TRUE); |
| 1132 |
} |
| 1133 |
if (!bResult) { |
| 1134 |
TCHAR buf[1024]; |
| 1135 |
wsprintf(buf, MSG_SAVE_FAILED, GetLastError()); |
| 1136 |
TomboMessageBox(hMainWnd, buf, TEXT("ERROR"), MB_ICONSTOP | MB_OK); |
| 1137 |
ActivateView(VT_DetailsView); |
| 1138 |
return; |
| 1139 |
} |
| 1140 |
if (nYNC == IDCANCEL) return; |
| 1141 |
ActivateView(VT_SelectView); |
| 1142 |
|
| 1143 |
if (g_Property.GetUseTwoPane()) { |
| 1144 |
// clear encrypted notes if two pane mode |
| 1145 |
if (nYNC == IDNO) { |
| 1146 |
// discard current note and load old one. |
| 1147 |
if (pDetailsView->GetCurrentURI()) { |
| 1148 |
OpenDetailsView(pDetailsView->GetCurrentURI(), OPEN_REQUEST_MDVIEW_ACTIVE); |
| 1149 |
} else { |
| 1150 |
pDetailsView->DiscardMemo(); |
| 1151 |
} |
| 1152 |
} else { |
| 1153 |
// nYNC == YES so note has been saved. |
| 1154 |
if (pDetailsView->GetCurrentURI()) { |
| 1155 |
URIOption opt(NOTE_OPTIONMASK_ENCRYPTED); |
| 1156 |
if (!g_Repository.GetOption(pDetailsView->GetCurrentURI(), &opt)) return; |
| 1157 |
if (opt.bEncrypt) { |
| 1158 |
pDetailsView->DiscardMemo(); |
| 1159 |
} |
| 1160 |
} |
| 1161 |
} |
| 1162 |
} else { |
| 1163 |
// User's choise is not "CANCEL", and saved if he/she choose "YES", so discard note. |
| 1164 |
pDetailsView->DiscardMemo(); |
| 1165 |
SetNewMemoStatus(FALSE); |
| 1166 |
} |
| 1167 |
|
| 1168 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5) |
| 1169 |
SetWindowTitle(NULL); |
| 1170 |
#endif |
| 1171 |
SetFocus(); |
| 1172 |
} |
| 1173 |
|
| 1174 |
/////////////////////////////////////////////////// |
| 1175 |
// switch view |
| 1176 |
/////////////////////////////////////////////////// |
| 1177 |
|
| 1178 |
void MainFrame::ActivateView(ViewType vt) |
| 1179 |
{ |
| 1180 |
if (vt == vtFocusedView) { |
| 1181 |
SetFocus(); |
| 1182 |
return; |
| 1183 |
} |
| 1184 |
|
| 1185 |
vtFocusedView = vt; |
| 1186 |
SetLayout(); |
| 1187 |
SetFocus(); |
| 1188 |
} |
| 1189 |
|
| 1190 |
/////////////////////////////////////////////////// |
| 1191 |
// change layout |
| 1192 |
/////////////////////////////////////////////////// |
| 1193 |
|
| 1194 |
void MainFrame::SetLayout() |
| 1195 |
{ |
| 1196 |
if (g_Property.GetUseTwoPane()) { |
| 1197 |
#if defined(PLATFORM_HPC) || defined(PLATFORM_WIN32) |
| 1198 |
ChangeLayout(LT_TwoPane); |
| 1199 |
#endif |
| 1200 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) || defined(PLATFORM_WM5) |
| 1201 |
switch(vtFocusedView) { |
| 1202 |
case VT_SelectView: |
| 1203 |
ChangeLayout(LT_TwoPane); |
| 1204 |
break; |
| 1205 |
case VT_DetailsView: |
| 1206 |
ChangeLayout(LT_OnePaneDetailsView); |
| 1207 |
break; |
| 1208 |
} |
| 1209 |
#endif |
| 1210 |
} else { |
| 1211 |
switch (vtFocusedView) { |
| 1212 |
case VT_SelectView: |
| 1213 |
ChangeLayout(LT_OnePaneSelectView); |
| 1214 |
break; |
| 1215 |
case VT_DetailsView: |
| 1216 |
ChangeLayout(LT_OnePaneDetailsView); |
| 1217 |
break; |
| 1218 |
} |
| 1219 |
} |
| 1220 |
} |
| 1221 |
|
| 1222 |
/////////////////////////////////////////////////// |
| 1223 |
// Switch pane mode |
| 1224 |
/////////////////////////////////////////////////// |
| 1225 |
void MainFrame::TogglePane() |
| 1226 |
{ |
| 1227 |
pPlatform->CheckMenu(IDM_TOGGLEPANE, !g_Property.GetUseTwoPane()); |
| 1228 |
|
| 1229 |
if (g_Property.GetUseTwoPane()) { |
| 1230 |
SaveWinSize(); |
| 1231 |
} |
| 1232 |
|
| 1233 |
DWORD nPane = g_Property.GetUseTwoPane() ? MF_UNCHECKED : MF_CHECKED; |
| 1234 |
g_Property.SetUseTwoPane(nPane); |
| 1235 |
|
| 1236 |
SetLayout(); |
| 1237 |
} |
| 1238 |
|
| 1239 |
/////////////////////////////////////////////////// |
| 1240 |
// Switch pane |
| 1241 |
/////////////////////////////////////////////////// |
| 1242 |
|
| 1243 |
void MainFrame::ChangeLayout(LayoutType layout) |
| 1244 |
{ |
| 1245 |
pPlatform->ShowStatusBar(!g_Property.GetHideStatusBar()); |
| 1246 |
#if defined(PLATFORM_WIN32) |
| 1247 |
pPlatform->ShowRebar(!g_Property.GetHideRebar()); |
| 1248 |
#endif |
| 1249 |
|
| 1250 |
// get tree/edit view area |
| 1251 |
RECT r, rc; |
| 1252 |
GetClientRect(hMainWnd, &r); |
| 1253 |
rc = r; |
| 1254 |
pPlatform->AdjustUserRect(&rc); |
| 1255 |
|
| 1256 |
switch(layout) { |
| 1257 |
case LT_TwoPane: |
| 1258 |
{ |
| 1259 |
#if defined(PLATFORM_WIN32) || defined(PLATFORM_HPC) |
| 1260 |
// split vertical |
| 1261 |
msView.MoveWindow(rc.left, rc.top , nSplitterSize, rc.bottom); |
| 1262 |
pDetailsView->MoveWindow(nSplitterSize + BORDER_WIDTH, rc.top, rc.right - nSplitterSize - BORDER_WIDTH, rc.bottom); |
| 1263 |
#endif |
| 1264 |
#if defined(PLATFORM_BE500) || ((defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && !defined(FOR_VGA)) |
| 1265 |
// split horizontal |
| 1266 |
msView.MoveWindow(rc.left, rc.top , rc.right, nSplitterSize); |
| 1267 |
pDetailsView->MoveWindow( |
| 1268 |
rc.left, rc.top + nSplitterSize + BORDER_WIDTH, |
| 1269 |
rc.right, rc.bottom - nSplitterSize - BORDER_WIDTH); |
| 1270 |
#endif |
| 1271 |
#if (defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && defined(FOR_VGA) |
| 1272 |
if (r.bottom - r.top > r.right - r.left) { |
| 1273 |
// portrait mode |
| 1274 |
bLandscapeMode = FALSE; |
| 1275 |
// split horizontal |
| 1276 |
msView.MoveWindow(rc.left, rc.top , rc.right, nSplitterSize); |
| 1277 |
pDetailsView->MoveWindow( |
| 1278 |
rc.left, rc.top + nSplitterSize + BORDER_WIDTH, |
| 1279 |
rc.right, rc.bottom - nSplitterSize - BORDER_WIDTH); |
| 1280 |
} else { |
| 1281 |
// landscape mode |
| 1282 |
bLandscapeMode = TRUE; |
| 1283 |
|
| 1284 |
// split vertical |
| 1285 |
msView.MoveWindow(rc.left, rc.top , nSplitterSizeWidth, rc.bottom); |
| 1286 |
pDetailsView->MoveWindow(nSplitterSizeWidth + BORDER_WIDTH, rc.top, rc.right - nSplitterSizeWidth - BORDER_WIDTH, rc.bottom); |
| 1287 |
} |
| 1288 |
#endif |
| 1289 |
|
| 1290 |
msView.Show(SW_SHOW); |
| 1291 |
pDetailsView->Show(SW_SHOW); |
| 1292 |
} |
| 1293 |
break; |
| 1294 |
case LT_OnePaneSelectView: |
| 1295 |
{ |
| 1296 |
WORD wLeftWidth, wHeight; |
| 1297 |
msView.GetSize(&wLeftWidth, &wHeight); |
| 1298 |
|
| 1299 |
msView.MoveWindow(rc.left, rc.top, rc.right, rc.bottom); |
| 1300 |
pDetailsView->MoveWindow(rc.left, rc.top, rc.right, rc.bottom); |
| 1301 |
|
| 1302 |
pDetailsView->Show(SW_HIDE); |
| 1303 |
msView.Show(SW_SHOW); |
| 1304 |
} |
| 1305 |
break; |
| 1306 |
case LT_OnePaneDetailsView: |
| 1307 |
{ |
| 1308 |
WORD wLeftWidth, wHeight; |
| 1309 |
msView.GetSize(&wLeftWidth, &wHeight); |
| 1310 |
|
| 1311 |
msView.MoveWindow(rc.left, rc.top, rc.right, rc.bottom); |
| 1312 |
pDetailsView->MoveWindow(rc.left, rc.top, rc.right, rc.bottom); |
| 1313 |
|
| 1314 |
pDetailsView->Show(SW_SHOW); |
| 1315 |
msView.Show(SW_HIDE); |
| 1316 |
} |
| 1317 |
break; |
| 1318 |
} |
| 1319 |
lCurrentLayout = layout; |
| 1320 |
|
| 1321 |
// Staus bar & rebar |
| 1322 |
pPlatform->ResizeStatusBar(0, MAKELPARAM(r.right - r.left, r.bottom - r.top)); |
| 1323 |
} |
| 1324 |
|
| 1325 |
/////////////////////////////////////////////////// |
| 1326 |
// Resize window |
| 1327 |
/////////////////////////////////////////////////// |
| 1328 |
|
| 1329 |
void MainFrame::OnResize(WPARAM wParam, LPARAM lParam) |
| 1330 |
{ |
| 1331 |
SetLayout(); |
| 1332 |
} |
| 1333 |
|
| 1334 |
/////////////////////////////////////////////////// |
| 1335 |
// Menu control |
| 1336 |
/////////////////////////////////////////////////// |
| 1337 |
void MainFrame::EnableEncrypt(BOOL bEnable) { pPlatform->EnableMenu(IDM_ENCRYPT, bEnable);} |
| 1338 |
void MainFrame::EnableDecrypt(BOOL bEnable) { pPlatform->EnableMenu(IDM_DECRYPT, bEnable);} |
| 1339 |
void MainFrame::EnableDelete(BOOL bEnable) { pPlatform->EnableMenu(IDM_DELETEITEM, bEnable); } |
| 1340 |
void MainFrame::EnableRename(BOOL bEnable) { pPlatform->EnableMenu(IDM_RENAME, bEnable); } |
| 1341 |
void MainFrame::EnableNew(BOOL bEnable) { pPlatform->EnableMenu(IDM_NEWMEMO, bEnable); } |
| 1342 |
void MainFrame::EnableCut(BOOL bEnable) { pPlatform->EnableMenu(IDM_CUT, bEnable); } |
| 1343 |
void MainFrame::EnableCopy(BOOL bEnable) { pPlatform->EnableMenu(IDM_COPY, bEnable); } |
| 1344 |
void MainFrame::EnablePaste(BOOL bEnable) { pPlatform->EnableMenu(IDM_PASTE, bEnable); } |
| 1345 |
void MainFrame::EnableNewFolder(BOOL bEnable) { pPlatform->EnableMenu(IDM_NEWFOLDER, bEnable); } |
| 1346 |
void MainFrame::EnableGrep(BOOL bEnable) { pPlatform->EnableMenu(IDM_GREP, bEnable);} |
| 1347 |
void MainFrame::EnableSaveButton(BOOL bEnable) { pPlatform->EnableMenu(IDM_SAVE, bEnable); } |
| 1348 |
|
| 1349 |
/////////////////////////////////////////////////// |
| 1350 |
// erase password information |
| 1351 |
/////////////////////////////////////////////////// |
| 1352 |
|
| 1353 |
void MainFrame::OnForgetPass() |
| 1354 |
{ |
| 1355 |
DWORD nYNC; |
| 1356 |
if (!mmMemoManager.SaveIfModify(&nYNC, FALSE)) { |
| 1357 |
TCHAR buf[1024]; |
| 1358 |
wsprintf(buf, MSG_SAVE_FAILED, GetLastError()); |
| 1359 |
TomboMessageBox(hMainWnd, buf, TEXT("ERROR"), MB_ICONSTOP | MB_OK); |
| 1360 |
// ActivateView(FALSE); |
| 1361 |
ActivateView(VT_DetailsView); |
| 1362 |
return; |
| 1363 |
} |
| 1364 |
if (nYNC == IDCANCEL) return; |
| 1365 |
|
| 1366 |
pmPasswordMgr.ForgetPassword(); |
| 1367 |
TomboMessageBox(hMainWnd, MSG_ERASE_PW, MSG_ERASE_PW_TITLE, MB_ICONINFORMATION | MB_OK); |
| 1368 |
pDetailsView->DiscardMemo(); |
| 1369 |
|
| 1370 |
} |
| 1371 |
|
| 1372 |
/////////////////////////////////////////////////// |
| 1373 |
// change property |
| 1374 |
/////////////////////////////////////////////////// |
| 1375 |
|
| 1376 |
void MainFrame::OnProperty() |
| 1377 |
{ |
| 1378 |
BOOL bPrev = bDisableHotKey; |
| 1379 |
bDisableHotKey = TRUE; |
| 1380 |
|
| 1381 |
// when calling OnProperty, select view is activated and saving check is finished. |
| 1382 |
pDetailsView->DiscardMemo(); |
| 1383 |
|
| 1384 |
int nResult = g_Property.Popup(hInstance, hMainWnd, msView.GetCurrentSelectedURI()); |
| 1385 |
bDisableHotKey = bPrev; |
| 1386 |
if (nResult != IDOK) return; |
| 1387 |
|
| 1388 |
g_Repository.ClearSubRepository(); |
| 1389 |
DWORD n = g_Property.GetNumSubRepository(); |
| 1390 |
for (DWORD i = 0; i < n; i++) { |
| 1391 |
RepositoryImpl *pImpl = g_Property.GetSubRepository(i); |
| 1392 |
g_Repository.AddSubRepository(pImpl); |
| 1393 |
} |
| 1394 |
|
| 1395 |
// font setting |
| 1396 |
msView.SetFont(g_Property.SelectViewFont()); |
| 1397 |
pDetailsView->SetFont(g_Property.DetailsViewFont()); |
| 1398 |
|
| 1399 |
// tabstop setting |
| 1400 |
pDetailsView->SetTabstop(); |
| 1401 |
|
| 1402 |
// reload notes and folders |
| 1403 |
msView.DeleteAllItem(); |
| 1404 |
msView.InitTree(pVFManager); |
| 1405 |
#if defined(PLATFORM_WIN32) || defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5) |
| 1406 |
if (!g_Property.GetSwitchWindowTitle()) { |
| 1407 |
SetWindowText(hMainWnd, TOMBO_APP_NAME); |
| 1408 |
} |
| 1409 |
#endif |
| 1410 |
|
| 1411 |
} |
| 1412 |
|
| 1413 |
/////////////////////////////////////////////////// |
| 1414 |
// timer events |
| 1415 |
/////////////////////////////////////////////////// |
| 1416 |
|
| 1417 |
void MainFrame::OnTimer(WPARAM nTimerID) |
| 1418 |
{ |
| 1419 |
if (nTimerID == 0) { |
| 1420 |
if (pDetailsView->GetCurrentURI()) { |
| 1421 |
URIOption opt(NOTE_OPTIONMASK_ENCRYPTED); |
| 1422 |
if (!g_Repository.GetOption(pDetailsView->GetCurrentURI(), &opt)) return; |
| 1423 |
if (opt.bEncrypt) { |
| 1424 |
LeaveDetailsView(FALSE); |
| 1425 |
} |
| 1426 |
} |
| 1427 |
pmPasswordMgr.ForgetPassword(); |
| 1428 |
} else if (nTimerID == ID_PASSWORDTIMER) { |
| 1429 |
pmPasswordMgr.ForgetPasswordIfNotAccessed(); |
| 1430 |
} |
| 1431 |
} |
| 1432 |
|
| 1433 |
/////////////////////////////////////////////////// |
| 1434 |
// suppress mutual execution |
| 1435 |
/////////////////////////////////////////////////// |
| 1436 |
void MainFrame::OnMutualExecute() |
| 1437 |
{ |
| 1438 |
SetForegroundWindow(hMainWnd); |
| 1439 |
#if defined(PLATFORM_WIN32) |
| 1440 |
BringWindowToTop(hMainWnd); |
| 1441 |
ShowWindow(hMainWnd, SW_RESTORE); |
| 1442 |
#endif |
| 1443 |
OnSettingChange(NULL); |
| 1444 |
} |
| 1445 |
|
| 1446 |
/////////////////////////////////////////////////// |
| 1447 |
// enable application button handling |
| 1448 |
/////////////////////////////////////////////////// |
| 1449 |
// http://www.pocketpcdn.com/qa/handle_hardware_keys.html |
| 1450 |
|
| 1451 |
typedef BOOL (__stdcall *UnregisterFunc1Proc)(UINT, UINT); |
| 1452 |
|
| 1453 |
BOOL MainFrame::EnableApplicationButton(HWND hWnd) |
| 1454 |
{ |
| 1455 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5) |
| 1456 |
HINSTANCE hCoreDll; |
| 1457 |
UnregisterFunc1Proc procUnregisterFunc; |
| 1458 |
hCoreDll = LoadLibrary(TEXT("coredll.dll")); |
| 1459 |
if (!hCoreDll) return FALSE; |
| 1460 |
procUnregisterFunc = (UnregisterFunc1Proc)GetProcAddress(hCoreDll, TEXT("UnregisterFunc1")); |
| 1461 |
if (!procUnregisterFunc) { |
| 1462 |
FreeLibrary(hCoreDll); |
| 1463 |
return FALSE; |
| 1464 |
} |
| 1465 |
if (g_Property.GetAppButton1()) { |
| 1466 |
procUnregisterFunc(MOD_WIN, APP_BUTTON1); |
| 1467 |
RegisterHotKey(hWnd, APP_BUTTON1, MOD_WIN, APP_BUTTON1); |
| 1468 |
} |
| 1469 |
if (g_Property.GetAppButton2()) { |
| 1470 |
procUnregisterFunc(MOD_WIN, APP_BUTTON2); |
| 1471 |
RegisterHotKey(hWnd, APP_BUTTON2, MOD_WIN, APP_BUTTON2); |
| 1472 |
} |
| 1473 |
if (g_Property.GetAppButton3()) { |
| 1474 |
procUnregisterFunc(MOD_WIN, APP_BUTTON3); |
| 1475 |
RegisterHotKey(hWnd, APP_BUTTON3, MOD_WIN, APP_BUTTON3); |
| 1476 |
} |
| 1477 |
if (g_Property.GetAppButton4()) { |
| 1478 |
procUnregisterFunc(MOD_WIN, APP_BUTTON4); |
| 1479 |
RegisterHotKey(hWnd, APP_BUTTON4, MOD_WIN, APP_BUTTON4); |
| 1480 |
} |
| 1481 |
if (g_Property.GetAppButton5()) { |
| 1482 |
procUnregisterFunc(MOD_WIN, APP_BUTTON5); |
| 1483 |
RegisterHotKey(hWnd, APP_BUTTON5, MOD_WIN, APP_BUTTON5); |
| 1484 |
} |
| 1485 |
|
| 1486 |
FreeLibrary(hCoreDll); |
| 1487 |
return TRUE; |
| 1488 |
#else |
| 1489 |
return TRUE; |
| 1490 |
#endif |
| 1491 |
} |
| 1492 |
|
| 1493 |
/////////////////////////////////////////////////// |
| 1494 |
// Save window size |
| 1495 |
/////////////////////////////////////////////////// |
| 1496 |
|
| 1497 |
void MainFrame::SaveWinSize() |
| 1498 |
{ |
| 1499 |
RECT r; |
| 1500 |
UINT flags, showCmd; |
| 1501 |
|
| 1502 |
#if defined(PLATFORM_HPC) || defined(PLATFORM_PKTPC) || defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) || defined(PLATFORM_WM5) |
| 1503 |
GetWindowRect(hMainWnd,&r); |
| 1504 |
flags = showCmd = 0; |
| 1505 |
#else |
| 1506 |
WINDOWPLACEMENT wpl; |
| 1507 |
wpl.length = sizeof(wpl); |
| 1508 |
GetWindowPlacement(hMainWnd, &wpl); |
| 1509 |
r = wpl.rcNormalPosition; |
| 1510 |
flags = wpl.flags; |
| 1511 |
showCmd = wpl.showCmd; |
| 1512 |
#endif |
| 1513 |
|
| 1514 |
WORD nPane; |
| 1515 |
if (g_Property.GetUseTwoPane()) { |
| 1516 |
nPane = nSplitterSize; |
| 1517 |
} else { |
| 1518 |
UINT u1, u2; |
| 1519 |
RECT r2; |
| 1520 |
if (!g_Property.GetWinSize(&u1, &u2, &r2, &nPane)) { |
| 1521 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_BE500) || defined(PLATFORM_PSPC) || defined(PLATFORM_WM5) |
| 1522 |
nPane = (WORD)((r.bottom - r.top) / 3 * 2); |
| 1523 |
#else |
| 1524 |
nPane = (WORD)(r.right - r.left) / 3; |
| 1525 |
#endif |
| 1526 |
} |
| 1527 |
} |
| 1528 |
g_Property.SaveWinSize(flags, showCmd, &r, nPane); |
| 1529 |
#if (defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && defined(FOR_VGA) |
| 1530 |
g_Property.SetWinSize2(nSplitterSizeWidth); |
| 1531 |
#endif |
| 1532 |
} |
| 1533 |
|
| 1534 |
/////////////////////////////////////////////////// |
| 1535 |
// Restore window size |
| 1536 |
/////////////////////////////////////////////////// |
| 1537 |
|
| 1538 |
void MainFrame::LoadWinSize(HWND hWnd) |
| 1539 |
{ |
| 1540 |
RECT rMainFrame; |
| 1541 |
RECT rClientRect; |
| 1542 |
GetClientRect(hWnd, &rClientRect); |
| 1543 |
|
| 1544 |
UINT u1, u2; |
| 1545 |
if (!g_Property.GetWinSize(&u1, &u2, &rMainFrame, &nSplitterSize)) { |
| 1546 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_BE500) || defined(PLATFORM_PSPC) || defined(PLATFORM_WM5) |
| 1547 |
nSplitterSize = (WORD)((rClientRect.right - rClientRect.left) / 3 * 2); |
| 1548 |
#else |
| 1549 |
nSplitterSize = (WORD)(rClientRect.right - rClientRect.left) / 3; |
| 1550 |
#endif |
| 1551 |
} |
| 1552 |
#if (defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && defined(FOR_VGA) |
| 1553 |
WORD w = (WORD)g_Property.GetWinSize2(); |
| 1554 |
if (w == 0xFFFF || w < 0 || w > rClientRect.right - 20) { |
| 1555 |
nSplitterSizeWidth = (WORD)((rClientRect.bottom - rClientRect.top) / 3); |
| 1556 |
} else { |
| 1557 |
nSplitterSizeWidth = w; |
| 1558 |
} |
| 1559 |
#endif |
| 1560 |
} |
| 1561 |
|
| 1562 |
/////////////////////////////////////////////////// |
| 1563 |
// set wrpping text or not |
| 1564 |
/////////////////////////////////////////////////// |
| 1565 |
|
| 1566 |
void MainFrame::SetWrapText(BOOL bWrap) |
| 1567 |
{ |
| 1568 |
// Change edit view status |
| 1569 |
if (!pDetailsView->SetFolding(bWrap)) { |
| 1570 |
TomboMessageBox(NULL, MSG_FOLDING_FAILED, TOMBO_APP_NAME, MB_ICONERROR | MB_OK); |
| 1571 |
return; |
| 1572 |
} |
| 1573 |
|
| 1574 |
pPlatform->CheckMenu(IDM_DETAILS_HSCROLL, bWrap); |
| 1575 |
} |
| 1576 |
|
| 1577 |
/////////////////////////////////////////////////// |
| 1578 |
// Searching |
| 1579 |
/////////////////////////////////////////////////// |
| 1580 |
|
| 1581 |
void MainFrame::OnSearch() |
| 1582 |
{ |
| 1583 |
SearchDialog sd; |
| 1584 |
if (sd.Popup(g_hInstance, hMainWnd, SelectViewActive()) != IDOK) return; |
| 1585 |
|
| 1586 |
SearchEngineA *pSE = new SearchEngineA(); |
| 1587 |
if(!pSE->Init(g_Property.GetCodePage(), sd.IsSearchEncryptMemo(), sd.IsFileNameOnly(), &pmPasswordMgr)) { |
| 1588 |
delete pSE; |
| 1589 |
return; |
| 1590 |
} |
| 1591 |
const char *pReason; |
| 1592 |
if (!pSE->Prepare(sd.SearchString(), sd.IsCaseSensitive(), &pReason)) { |
| 1593 |
LPTSTR p = ConvSJIS2Unicode(pReason); |
| 1594 |
if (p) { |
| 1595 |
MessageBox(p, TOMBO_APP_NAME, MB_OK | MB_ICONEXCLAMATION); |
| 1596 |
delete [] p; |
| 1597 |
} else { |
| 1598 |
MessageBox(MSG_NOT_ENOUGH_MEMORY, TOMBO_APP_NAME, MB_OK | MB_ICONEXCLAMATION); |
| 1599 |
} |
| 1600 |
delete pSE; |
| 1601 |
return; |
| 1602 |
} |
| 1603 |
mmMemoManager.SetSearchEngine(pSE); |
| 1604 |
|
| 1605 |
// Enable FindNext/Prev button |
| 1606 |
pPlatform->EnableSearchNext(); |
| 1607 |
|
| 1608 |
bSearchStartFromTreeView = SelectViewActive(); |
| 1609 |
|
| 1610 |
// execute searching |
| 1611 |
if (SelectViewActive()) { |
| 1612 |
DoSearchTree(TRUE, !sd.IsSearchDirectionUp()); |
| 1613 |
mmMemoManager.SetMSSearchFlg(FALSE); |
| 1614 |
} else { |
| 1615 |
pDetailsView->Search(TRUE, TRUE, TRUE, FALSE); |
| 1616 |
mmMemoManager.SetMDSearchFlg(FALSE); |
| 1617 |
} |
| 1618 |
} |
| 1619 |
|
| 1620 |
void MainFrame::DoSearchTree(BOOL bFirst, BOOL bForward) |
| 1621 |
{ |
| 1622 |
SearchEngineA *pSE = mmMemoManager.GetSearchEngine(); |
| 1623 |
|
| 1624 |
const TomboURI *pCurSelected = msView.GetCurrentSelectedURI(); |
| 1625 |
if (pCurSelected == NULL) return; |
| 1626 |
|
| 1627 |
TomboURI sURI; |
| 1628 |
sURI = *pCurSelected; |
| 1629 |
|
| 1630 |
// Create dialog and do search. |
| 1631 |
SearchTree st; |
| 1632 |
st.Init(pSE, &sURI, bForward, !bFirst, !pSE->IsSearchEncryptMemo()); |
| 1633 |
st.Popup(g_hInstance, hMainWnd); |
| 1634 |
|
| 1635 |
const TomboURI *pMatched = st.GetMatchedURI(); |
| 1636 |
|
| 1637 |
switch(st.GetResult()) { |
| 1638 |
case SR_FOUND: |
| 1639 |
msView.ShowItemByURI(st.GetMatchedURI()); |
| 1640 |
pDetailsView->Search(TRUE, TRUE, TRUE, TRUE); |
| 1641 |
break; |
| 1642 |
case SR_NOTFOUND: |
| 1643 |
MessageBox(MSG_STRING_NOT_FOUND, TOMBO_APP_NAME, MB_OK | MB_ICONINFORMATION); |
| 1644 |
break; |
| 1645 |
case SR_CANCELED: |
| 1646 |
if (st.CurrentURI()) msView.ShowItemByURI(st.CurrentURI()); |
| 1647 |
MessageBox(MSG_STRING_SEARCH_CANCELED, TOMBO_APP_NAME, MB_OK | MB_ICONINFORMATION); |
| 1648 |
break; |
| 1649 |
case SR_FAILED: |
| 1650 |
{ |
| 1651 |
if (st.CurrentURI()) msView.ShowItemByURI(st.CurrentURI()); |
| 1652 |
TCHAR buf[1024]; |
| 1653 |
wsprintf(buf, MSG_SEARCH_FAILED, GetLastError()); |
| 1654 |
MessageBox(buf, TOMBO_APP_NAME, MB_OK | MB_ICONERROR); |
| 1655 |
} |
| 1656 |
break; |
| 1657 |
} |
| 1658 |
} |
| 1659 |
|
| 1660 |
/////////////////////////////////////////////////// |
| 1661 |
// Search next one |
| 1662 |
/////////////////////////////////////////////////// |
| 1663 |
|
| 1664 |
void MainFrame::OnSearchNext(BOOL bForward) |
| 1665 |
{ |
| 1666 |
if (mmMemoManager.GetSearchEngine() == NULL) { |
| 1667 |
OnSearch(); |
| 1668 |
return; |
| 1669 |
} |
| 1670 |
|
| 1671 |
if (SelectViewActive()) { |
| 1672 |
DoSearchTree(mmMemoManager.MSSearchFlg(), bForward); |
| 1673 |
mmMemoManager.SetMSSearchFlg(FALSE); |
| 1674 |
} else { |
| 1675 |
// if search starts at edit view, show message when match failed. |
| 1676 |
// if starts at tree view, search next item. |
| 1677 |
BOOL bMatched = pDetailsView->Search(mmMemoManager.MDSearchFlg(), bForward, !bSearchStartFromTreeView, FALSE); |
| 1678 |
mmMemoManager.SetMDSearchFlg(FALSE); |
| 1679 |
if (bSearchStartFromTreeView && !bMatched) { |
| 1680 |
ActivateView(VT_SelectView); |
| 1681 |
DoSearchTree(mmMemoManager.MSSearchFlg(), bForward); |
| 1682 |
mmMemoManager.SetMSSearchFlg(FALSE); |
| 1683 |
} |
| 1684 |
} |
| 1685 |
} |
| 1686 |
|
| 1687 |
/////////////////////////////////////////////////// |
| 1688 |
// show/hide status bar |
| 1689 |
/////////////////////////////////////////////////// |
| 1690 |
|
| 1691 |
#if defined(PLATFORM_WIN32) || defined(PLATFORM_HPC) |
| 1692 |
void MainFrame::ToggleShowStatusBar() |
| 1693 |
{ |
| 1694 |
g_Property.ToggleShowStatusBar(); |
| 1695 |
|
| 1696 |
HMENU hMenu = pPlatform->GetMainMenu(); |
| 1697 |
|
| 1698 |
if (g_Property.GetHideStatusBar()) { |
| 1699 |
CheckMenuItem(hMenu, IDM_SHOWSTATUSBAR, MF_BYCOMMAND | MF_UNCHECKED); |
| 1700 |
} else { |
| 1701 |
CheckMenuItem(hMenu, IDM_SHOWSTATUSBAR, MF_BYCOMMAND | MF_CHECKED); |
| 1702 |
} |
| 1703 |
|
| 1704 |
RECT r; |
| 1705 |
GetClientRect(hMainWnd, &r); |
| 1706 |
OnResize(0, MAKELPARAM(r.right - r.left, r.bottom - r.top)); |
| 1707 |
} |
| 1708 |
#endif |
| 1709 |
|
| 1710 |
/////////////////////////////////////////////////// |
| 1711 |
// show/hide rebar |
| 1712 |
/////////////////////////////////////////////////// |
| 1713 |
|
| 1714 |
#if defined(PLATFORM_WIN32) |
| 1715 |
void MainFrame::ToggleShowRebar() |
| 1716 |
{ |
| 1717 |
g_Property.ToggleShowRebar(); |
| 1718 |
HMENU hMenu = pPlatform->GetMainMenu(); |
| 1719 |
|
| 1720 |
RECT r; |
| 1721 |
GetClientRect(hMainWnd, &r); |
| 1722 |
|
| 1723 |
pPlatform->ShowRebar(!g_Property.GetHideRebar()); |
| 1724 |
if (g_Property.GetHideRebar()) { |
| 1725 |
CheckMenuItem(hMenu, IDM_SHOWREBAR, MF_BYCOMMAND | MF_UNCHECKED); |
| 1726 |
} else { |
| 1727 |
InvalidateRect(hMainWnd, &r, TRUE); |
| 1728 |
CheckMenuItem(hMenu, IDM_SHOWREBAR, MF_BYCOMMAND | MF_CHECKED); |
| 1729 |
} |
| 1730 |
|
| 1731 |
OnResize(0, MAKELPARAM(r.right - r.left, r.bottom - r.top)); |
| 1732 |
} |
| 1733 |
#endif |
| 1734 |
|
| 1735 |
/////////////////////////////////////////////////// |
| 1736 |
// get command bar from command band by ID |
| 1737 |
/////////////////////////////////////////////////// |
| 1738 |
|
| 1739 |
int MainFrame::MessageBox(LPCTSTR pText, LPCTSTR pCaption, UINT uType) |
| 1740 |
{ |
| 1741 |
return TomboMessageBox(hMainWnd, pText, pCaption, uType); |
| 1742 |
} |
| 1743 |
|
| 1744 |
/////////////////////////////////////////////////// |
| 1745 |
// Grep |
| 1746 |
/////////////////////////////////////////////////// |
| 1747 |
|
| 1748 |
void MainFrame::OnGrep() |
| 1749 |
{ |
| 1750 |
HTREEITEM hItem; |
| 1751 |
TString sPath; |
| 1752 |
hItem = msView.GetPathForNewItem(&sPath); |
| 1753 |
if (hItem == NULL) return; |
| 1754 |
|
| 1755 |
GrepDialog gd; |
| 1756 |
if (!gd.Init(sPath.Get())) return; |
| 1757 |
if (gd.Popup(hInstance, hMainWnd) == IDOK) { |
| 1758 |
const VFInfo *pInfo; |
| 1759 |
pInfo = pVFManager->GetGrepVFInfo(gd.GetPath(), gd.GetMatchString(), |
| 1760 |
gd.IsCaseSensitive(), gd.IsCheckCryptedMemo(), |
| 1761 |
gd.IsCheckFileName(), gd.IsNegate()); |
| 1762 |
if (pInfo == NULL) return; |
| 1763 |
if (!msView.InsertVirtualFolder(pInfo)) { |
| 1764 |
MessageBox(MSG_INSERTVFOLDER_FAIL, TOMBO_APP_NAME, MB_OK | MB_ICONERROR); |
| 1765 |
} |
| 1766 |
} |
| 1767 |
} |
| 1768 |
|
| 1769 |
/////////////////////////////////////////////////// |
| 1770 |
// stay topmost of the screen |
| 1771 |
/////////////////////////////////////////////////// |
| 1772 |
|
| 1773 |
void MainFrame::SetTopMost() |
| 1774 |
{ |
| 1775 |
#if defined(PLATFORM_WIN32) |
| 1776 |
HMENU hMenu = GetMenu(hMainWnd); |
| 1777 |
|
| 1778 |
if (g_Property.GetStayTopMost()) { |
| 1779 |
CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_CHECKED); |
| 1780 |
SendMessage(pPlatform->hToolBar, TB_SETSTATE, IDM_TOPMOST, MAKELONG(TBSTATE_ENABLED |TBSTATE_PRESSED, 0)); |
| 1781 |
|
| 1782 |
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); |
| 1783 |
} else { |
| 1784 |
CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_UNCHECKED); |
| 1785 |
SendMessage(pPlatform->hToolBar, TB_SETSTATE, IDM_TOPMOST, MAKELONG(TBSTATE_ENABLED, 0)); |
| 1786 |
|
| 1787 |
SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); |
| 1788 |
} |
| 1789 |
#endif |
| 1790 |
} |
| 1791 |
|
| 1792 |
/////////////////////////////////////////////////// |
| 1793 |
// stay topmost of the screen |
| 1794 |
/////////////////////////////////////////////////// |
| 1795 |
|
| 1796 |
void MainFrame::OnVFolderDef() |
| 1797 |
{ |
| 1798 |
FilterCtlDlg dlg; |
| 1799 |
if (!dlg.Init(&msView, pVFManager)) return; |
| 1800 |
msView.CloseVFRoot(); |
| 1801 |
dlg.Popup(g_hInstance, hMainWnd, msView.GetImageList()); |
| 1802 |
} |
| 1803 |
|
| 1804 |
/////////////////////////////////////////////////// |
| 1805 |
// Bookmark related members |
| 1806 |
/////////////////////////////////////////////////// |
| 1807 |
|
| 1808 |
void MainFrame::OnBookMarkAdd(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 1809 |
{ |
| 1810 |
// get note's path |
| 1811 |
const TomboURI *pURI = msView.GetCurrentSelectedURI(); |
| 1812 |
if (pURI == NULL) return; |
| 1813 |
|
| 1814 |
// add to bookmark manager |
| 1815 |
const BookMarkItem *pItem = pBookMark->Assign(pURI->GetFullURI()); |
| 1816 |
if (pItem == NULL) return; |
| 1817 |
|
| 1818 |
AppendBookMark(pPlatform->GetMSBookMarkMenu(), pItem); |
| 1819 |
} |
| 1820 |
|
| 1821 |
void MainFrame::OnBookMarkConfig(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 1822 |
{ |
| 1823 |
BookMarkDlg dlg; |
| 1824 |
if (!dlg.Init(pBookMark)) return; |
| 1825 |
|
| 1826 |
// release current bookmark |
| 1827 |
const BookMarkItem *p; |
| 1828 |
HMENU hBookMark = pPlatform->GetMSBookMarkMenu(); |
| 1829 |
DWORD n = pBookMark->NumItems(); |
| 1830 |
for (DWORD i = 0; i < n; i++) { |
| 1831 |
p = pBookMark->GetUnit(i); |
| 1832 |
DeleteMenu(hBookMark, p->nID, MF_BYCOMMAND); |
| 1833 |
} |
| 1834 |
|
| 1835 |
// popup dialog and get info |
| 1836 |
dlg.Popup(g_hInstance, hMainWnd); |
| 1837 |
|
| 1838 |
// set bookmarks |
| 1839 |
LPTSTR pBM = pBookMark->ExportToMultiSZ(); |
| 1840 |
LoadBookMark(pBM); |
| 1841 |
delete [] pBM; |
| 1842 |
} |
| 1843 |
|
| 1844 |
void MainFrame::OnBookMark(HWND hWnd, WPARAM wParam, LPARAM lParam) |
| 1845 |
{ |
| 1846 |
const BookMarkItem *pItem = pBookMark->Find(LOWORD(wParam)); |
| 1847 |
if (pItem) { |
| 1848 |
TomboURI sURI; |
| 1849 |
if (!sURI.Init(pItem->pPath)) return; |
| 1850 |
msView.ShowItemByURI(&sURI); |
| 1851 |
} |
| 1852 |
} |
| 1853 |
|
| 1854 |
void MainFrame::AppendBookMark(HMENU hMenu, const BookMarkItem *pItem) |
| 1855 |
{ |
| 1856 |
#if defined(PLATFORM_WIN32) |
| 1857 |
// add to menu |
| 1858 |
MENUITEMINFO mii; |
| 1859 |
|
| 1860 |
memset(&mii, 0, sizeof(mii)); |
| 1861 |
|
| 1862 |
mii.cbSize = sizeof(mii); |
| 1863 |
mii.fMask = MIIM_ID | MIIM_DATA | MIIM_STATE | MIIM_TYPE; |
| 1864 |
mii.fType = MFT_STRING; |
| 1865 |
mii.fState = MFS_ENABLED; |
| 1866 |
|
| 1867 |
mii.wID = pItem->nID; |
| 1868 |
mii.dwTypeData = pItem->pName; |
| 1869 |
mii.cch = _tcslen(pItem->pName); |
| 1870 |
if (!InsertMenuItem(hMenu, pItem->nID - pBookMark->GetBaseID() + NUM_BOOKMARK_SUBMENU_DEFAULT, TRUE, &mii)) return; |
| 1871 |
#endif |
| 1872 |
#if defined(PLATFORM_HPC) || defined(PLATFORM_PKTPC) || defined(PLATFORM_PSPC) || defined(PLATFORM_BE500) || defined(PLATFORM_WM5) |
| 1873 |
if (!AppendMenu(hMenu, MF_STRING, pItem->nID, pItem->pName)) return; |
| 1874 |
#endif |
| 1875 |
} |
| 1876 |
|
| 1877 |
void MainFrame::LoadBookMark(LPCTSTR pBookMarks) |
| 1878 |
{ |
| 1879 |
const BookMarkItem *p; |
| 1880 |
|
| 1881 |
HMENU hBookMark = pPlatform->GetMSBookMarkMenu(); |
| 1882 |
|
| 1883 |
DWORD i; |
| 1884 |
// release current bookmark |
| 1885 |
DWORD n = pBookMark->NumItems(); |
| 1886 |
for (i = 0; i < n; i++) { |
| 1887 |
p = pBookMark->GetUnit(i); |
| 1888 |
DeleteMenu(hBookMark, p->nID, MF_BYCOMMAND); |
| 1889 |
} |
| 1890 |
|
| 1891 |
// load bookmark list |
| 1892 |
pBookMark->ImportFromMultiSZ(pBookMarks); |
| 1893 |
|
| 1894 |
// add to menu |
| 1895 |
n = pBookMark->NumItems(); |
| 1896 |
for (i = 0; i < n; i++) { |
| 1897 |
p = pBookMark->GetUnit(i); |
| 1898 |
AppendBookMark(hBookMark, p); |
| 1899 |
} |
| 1900 |
} |