00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "HFE_FileList.h"
00009 #include "HFEWnd.h"
00010 #include "plugincmds.h"
00011 #include "DownloadsWnd.h"
00012 #include "WaitDlg.h"
00013 #include "CreateDownloadsDlg.h"
00014 #include "HFESheet.h"
00015 #include "MainFrm.h"
00016
00017 #ifdef _DEBUG
00018 #define new DEBUG_NEW
00019 #undef THIS_FILE
00020 static char THIS_FILE[] = __FILE__;
00021 #endif
00022
00023 extern CHFEWnd *_pwndHFE;
00024 extern CDownloadsWnd* _pwndDownloads;
00025
00026 CHFE_FileList::CHFE_FileList()
00027 {
00028 m_bDontUpdateList = FALSE;
00029 }
00030
00031 CHFE_FileList::~CHFE_FileList()
00032 {
00033 }
00034
00035 BEGIN_MESSAGE_MAP(CHFE_FileList, CListCtrlEx)
00036
00037 ON_WM_RBUTTONDOWN()
00038 ON_COMMAND(ID_HFE_DOWNLOAD, OnHfeDownload)
00039 ON_COMMAND(ID_HFE_GO, OnHfeGo)
00040 ON_COMMAND(ID_HFE_REFRESH, OnHfeRefresh)
00041 ON_COMMAND(ID_HFE_SETTINGS, OnHfeSettings)
00042 ON_COMMAND(ID_HFE_STOP, OnHfeStop)
00043 ON_COMMAND(ID_HFE_OPENFOLDER, OnHfeOpenfolder)
00044 ON_COMMAND(ID_HFE_PARENTFOLDER, OnHfeParentfolder)
00045 ON_WM_LBUTTONDBLCLK()
00046 ON_WM_DRAWITEM()
00047 ON_WM_MEASUREITEM()
00048 ON_COMMAND(ID_HFE_DISCONNECT, OnHfeDisconnect)
00049
00050 END_MESSAGE_MAP()
00051
00052 BOOL CHFE_FileList::Create(CWnd *pParent)
00053 {
00054 CRect rc (0, 0, 50, 50);
00055
00056 if (FALSE == CListCtrlEx::Create (LVS_REPORT|LVS_OWNERDRAWFIXED|LVS_NOSORTHEADER|LVS_SHOWSELALWAYS,
00057 rc, pParent, 0x56789))
00058 return FALSE;
00059
00060 SetExtendedStyle (LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_INFOTIP);
00061
00062 m_images.Create (16, 17, ILC_COLOR24 | ILC_MASK, 4, 1);
00063 CBitmap bmp;
00064 bmp.Attach (SBMP (IDB_FILELIST));
00065 m_images.Add (&bmp, RGB (255, 0, 255));
00066 SetImageList (&m_images, LVSIL_SMALL);
00067
00068 m_selImages.Create (16, 17, ILC_COLOR24 | ILC_MASK, 4, 1);
00069 CBitmap bmp1;
00070 bmp1.Attach (SBMP (IDB_FILELIST_SEL));
00071 m_selImages.Add (&bmp1, RGB (255, 0, 255));
00072 SetSelectedImages (&m_selImages);
00073
00074 InsertColumn (0, LS (L_FILENAME), LVCFMT_LEFT, 300, 0);
00075 InsertColumn (1, LS (L_SIZE), LVCFMT_LEFT, 80, 0);
00076 InsertColumn (2, LS (L_DATE), LVCFMT_LEFT, 170, 0);
00077
00078 ReadState ("HFEFileList");
00079
00080 ShowWindow (SW_SHOW);
00081
00082 return TRUE;
00083 }
00084
00085 void CHFE_FileList::UpdateList()
00086 {
00087 if (m_bDontUpdateList)
00088 return;
00089
00090 fsInternetFileListMgr *mgr = _pwndHFE->GetMgr ();
00091
00092 DeleteAllItems ();
00093
00094 if (mgr->IsConnected () == FALSE || mgr->GetLastError () != IR_SUCCESS)
00095 return;
00096
00097 UINT cFiles = mgr->GetFileCount ();
00098
00099 if (mgr->IsCurrentPathRoot () == FALSE)
00100 {
00101
00102 int iItem = AddItem ("..", GetSysColor (COLOR_WINDOW), GetSysColor (COLOR_WINDOWTEXT), 0);
00103 SetItemData (iItem, NULL);
00104 }
00105
00106 for (UINT i = 0; i < cFiles; i++)
00107 {
00108 fsFileInfo *file = mgr->GetFileInfo (i);
00109 int iImage = GetFileImage (file);
00110
00111 int iItem = AddItem (file->strName, GetSysColor (COLOR_WINDOW), GetSysColor (COLOR_WINDOWTEXT), iImage);
00112 SetItemData (iItem, (DWORD) file);
00113
00114 if (file->uSize != _UI64_MAX)
00115 {
00116 CString str;
00117
00118 if (_pwndDownloads->IsSizesInBytes () == FALSE)
00119 {
00120 CHAR szDim [10];
00121 float val;
00122 BytesToXBytes (file->uSize, &val, szDim);
00123 str.Format ("%.*g %s", val > 999 ? 4 : 3, val, szDim);
00124 }
00125 else
00126 str = fsBytesToStr (file->uSize);
00127
00128 SetItemText (iItem, 1, str);
00129 }
00130
00131 if (file->date.dwHighDateTime != UINT_MAX || file->date.dwLowDateTime != UINT_MAX)
00132 {
00133 SYSTEMTIME time;
00134 CHAR strTime [1000], strDate [1000];
00135
00136 FileTimeToSystemTime (&file->date, &time);
00137
00138 SystemTimeToStr (&time, strDate, strTime);
00139
00140 strcat (strTime, " ");
00141 strcat (strTime, strDate);
00142 SetItemText (iItem, 2, strTime);
00143 }
00144 }
00145
00146 SortItems (_SortFunc, (DWORD) this);
00147 }
00148
00149 int CHFE_FileList::GetFileImage(fsFileInfo *file)
00150 {
00151 int iImage;
00152
00153 if (file->bFolder)
00154 iImage = 0;
00155 else
00156 iImage = 2;
00157
00158 if (file->bAvailable == FALSE)
00159 iImage++;
00160
00161 return iImage;
00162 }
00163
00164 void CHFE_FileList::OnRButtonDown(UINT nFlags, CPoint point)
00165 {
00166 m_rbPt = point;
00167
00168 CListCtrlEx::OnRButtonDown(nFlags, point);
00169 }
00170
00171 void CHFE_FileList::OnRClick()
00172 {
00173 CMenu menu;
00174 menu.LoadMenu (IDM_HFE);
00175 ApplyLanguageToMenu (&menu);
00176 CMenu *pPopup = menu.GetSubMenu (0);
00177
00178 UpdateMenu (pPopup);
00179
00180 ClientToScreen (&m_rbPt);
00181
00182 m_odmenu.Attach (&menu, FALSE);
00183
00184 m_odmenu.SetImageList (&((CMainFrame*)AfxGetApp ()->m_pMainWnd)->m_imgsMenu, &((CMainFrame*)AfxGetApp ()->m_pMainWnd)->m_dimgsMenu);
00185 fsSetImage *pImages;
00186 int cImages;
00187 CHFEWnd::Plugin_GetMenuImages (&pImages, &cImages);
00188 m_odmenu.SetImages (pImages, cImages);
00189
00190 pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN, m_rbPt.x, m_rbPt.y, this);
00191 m_odmenu.Detach ();
00192
00193 menu.DestroyMenu ();
00194 }
00195
00196 void CHFE_FileList::OnHfeDownload()
00197 {
00198 POSITION pos = GetFirstSelectedItemPosition ();
00199
00200 if (pos == NULL)
00201 return;
00202
00203 if (GetSelectedCount () == 1)
00204 {
00205 int iItem = GetNextSelectedItem (pos);
00206
00207 if (((fsFileInfo*) GetItemData (iItem))->bFolder)
00208 DownloadSelected ();
00209 else
00210 {
00211 CString strUrl = GetItemText (iItem, 0);
00212 fsString strFullUrl;
00213
00214 if (IR_SUCCESS != _pwndHFE->GetMgr ()->GetFullUrl (strUrl, strFullUrl))
00215 {
00216 MessageBox (LS (L_BADURL), LS (L_ERR), MB_ICONERROR);
00217 SetFocus ();
00218 return;
00219 }
00220
00221 _pwndDownloads->CreateDownload (strFullUrl);
00222 }
00223 }
00224 else
00225 {
00226 DownloadSelected ();
00227 }
00228
00229 SetFocus ();
00230 }
00231
00232 void CHFE_FileList::OnHfeGo()
00233 {
00234 _pwndHFE->OnGo ();
00235 }
00236
00237 void CHFE_FileList::OnHfeRefresh()
00238 {
00239 DeleteAllItems ();
00240 _pwndHFE->GetMgr ()->Refresh ();
00241 }
00242
00243 void CHFE_FileList::OnHfeSettings()
00244 {
00245 CHFESheet sheet (LS (L_EXPLORERSETTINGS), this);
00246 _DlgMgr.OnDoModal (&sheet);
00247 sheet.DoModal ();
00248 _DlgMgr.OnEndDialog (&sheet);
00249 SetFocus ();
00250 }
00251
00252 void CHFE_FileList::OnHfeStop()
00253 {
00254 _pwndHFE->GetMgr ()->Stop (FALSE);
00255 }
00256
00257 void CHFE_FileList::UpdateMenu(CMenu *pPopup)
00258 {
00259 pPopup->SetDefaultItem (ID_HFE_DOWNLOAD);
00260
00261 if (_pwndHFE->GetMgr ()->IsRunning () == FALSE)
00262 pPopup->EnableMenuItem (ID_HFE_STOP, MF_BYCOMMAND | MF_GRAYED);
00263
00264 if (_pwndHFE->GetMgr ()->IsConnected () == FALSE)
00265 pPopup->EnableMenuItem (ID_HFE_DISCONNECT, MF_BYCOMMAND | MF_GRAYED);
00266
00267 if (_pwndHFE->GetMgr ()->GetCurrentPath () == NULL || _pwndHFE->GetMgr ()->IsRunning ())
00268 {
00269 pPopup->EnableMenuItem (ID_HFE_REFRESH, MF_BYCOMMAND | MF_GRAYED);
00270 pPopup->EnableMenuItem (ID_HFE_PARENTFOLDER, MF_BYCOMMAND | MF_GRAYED);
00271 }
00272
00273 if (_pwndHFE->GetMgr ()->IsCurrentPathRoot ())
00274 pPopup->EnableMenuItem (ID_HFE_PARENTFOLDER, MF_BYCOMMAND | MF_GRAYED);
00275
00276 int cItems = GetSelectedCount ();
00277
00278 if (cItems == 0)
00279 {
00280 pPopup->EnableMenuItem (ID_HFE_DOWNLOAD, MF_BYCOMMAND | MF_GRAYED);
00281 pPopup->EnableMenuItem (ID_HFE_OPENFOLDER, MF_BYCOMMAND | MF_GRAYED);
00282 }
00283 else
00284 {
00285 POSITION pos = GetFirstSelectedItemPosition ();
00286 while (pos)
00287 {
00288 int iItem = GetNextSelectedItem (pos);
00289 fsFileInfo *file = (fsFileInfo*) GetItemData (iItem);
00290 if (iItem == 0 && _pwndHFE->GetMgr ()->IsCurrentPathRoot () == FALSE)
00291 {
00292 pPopup->EnableMenuItem (ID_HFE_DOWNLOAD, MF_BYCOMMAND | MF_GRAYED);
00293 }
00294 else
00295 {
00296 if (file->bFolder == FALSE)
00297 pPopup->EnableMenuItem (ID_HFE_OPENFOLDER, MF_BYCOMMAND | MF_GRAYED);
00298 }
00299 }
00300
00301 if (cItems != 1)
00302 pPopup->EnableMenuItem (ID_HFE_OPENFOLDER, MF_BYCOMMAND | MF_GRAYED);
00303 }
00304 }
00305
00306 int CALLBACK CHFE_FileList::_SortFunc(LPARAM item1, LPARAM item2, LPARAM )
00307 {
00308 fsFileInfo *file1 = (fsFileInfo*) item1;
00309 fsFileInfo *file2 = (fsFileInfo*) item2;
00310
00311 if (file1 == NULL)
00312 return -1;
00313 else if (file2 == NULL)
00314 return -1;
00315
00316
00317 if (file1->bFolder && file2->bFolder == FALSE)
00318 return -1;
00319 else if (file2->bFolder && file1->bFolder == FALSE)
00320 return 1;
00321
00322 return stricmp (file1->strName, file2->strName);
00323 }
00324
00325 void CHFE_FileList::OnHfeOpenfolder()
00326 {
00327 POSITION pos = GetFirstSelectedItemPosition ();
00328 int iItem = GetNextSelectedItem (pos);
00329
00330 char szUrl [10000];
00331
00332
00333 if (iItem == 0 && _pwndHFE->GetMgr ()->IsCurrentPathRoot () == FALSE)
00334 {
00335
00336 _pwndHFE->GetMgr ()->GetParentFolderUrl (szUrl);
00337 _pwndHFE->GetMgr ()->GoParentFolder ();
00338 }
00339 else
00340 {
00341
00342 CString strFolder = GetItemText (iItem, 0);
00343 _pwndHFE->GetMgr ()->FolderToUrl (strFolder, szUrl);
00344 _pwndHFE->GetMgr ()->GoFolder (strFolder);
00345 }
00346
00347
00348 _pwndHFE->m_wndUrl.PushUrl (szUrl);
00349 }
00350
00351 void CHFE_FileList::OnHfeParentfolder()
00352 {
00353 fsInternetFileListMgr* mgr = _pwndHFE->GetMgr ();
00354
00355 if (mgr->IsCurrentPathRoot ())
00356 return;
00357
00358 mgr->GoParentFolder ();
00359 }
00360
00361 void CHFE_FileList::OnLButtonDblClk(UINT nFlags, CPoint point)
00362 {
00363 Open1SelectedItem ();
00364
00365 CListCtrlEx::OnLButtonDblClk(nFlags, point);
00366 }
00367
00368 BOOL CHFE_FileList::Open1SelectedItem()
00369 {
00370 POSITION pos = GetFirstSelectedItemPosition ();
00371 if (pos && GetSelectedCount () == 1)
00372 {
00373 fsFileInfo *file = (fsFileInfo*) GetItemData (GetNextSelectedItem (pos));
00374
00375
00376 if (file == NULL || file->bFolder)
00377 OnHfeOpenfolder ();
00378 else
00379 OnHfeDownload ();
00380
00381 return TRUE;
00382 }
00383
00384 return FALSE;
00385 }
00386
00387 void CHFE_FileList::OnKeyDown(WORD wVK)
00388 {
00389 switch (wVK)
00390 {
00391 case VK_RETURN:
00392 if (Open1SelectedItem () == FALSE)
00393 OnHfeDownload ();
00394 break;
00395
00396 case VK_APPS:
00397 CalcCoordsForCurSel ();
00398 OnRClick ();
00399 break;
00400 }
00401 }
00402
00403 void CHFE_FileList::DownloadSelected()
00404 {
00405 m_bDontUpdateList = TRUE;
00406
00407 CWaitDlg dlg;
00408
00409 fsInternetFileListMgr *mgr = _pwndHFE->GetMgr ();
00410
00411 BOOL bRI = mgr->RetreiveInfoWhileGettingList ();
00412
00413 mgr->RetreiveInfoWhileGettingList (FALSE);
00414
00415 char szUrl [10000];
00416 mgr->GetCurrentUrl (szUrl, 10000);
00417
00418 CString strOrigUrl;
00419 _pwndHFE->m_wndUrl.m_wndUrl.GetWindowText (strOrigUrl);
00420
00421
00422 bool bWasError = false;
00423 if (IDOK == dlg.StartWaiting (LS (L_BUILDINGLIST), _threadBuildList, TRUE, this, &bWasError) &&
00424 m_pList != NULL)
00425 {
00426 CCreateDownloadsDlg dlg;
00427
00428 dlg.m_pFileList = m_pList;
00429 dlg.m_strRootUrl = szUrl;
00430
00431 _DlgMgr.DoModal (&dlg);
00432
00433 SAFE_DELETE (m_pList);
00434 }
00435
00436 m_bDontUpdateList = FALSE;
00437
00438 if (mgr->IsRunning ())
00439 {
00440 mgr->Stop (FALSE);
00441 while (mgr->IsRunning ()) {
00442 MSG msg;
00443 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
00444 DispatchMessage (&msg);
00445 Sleep (10);
00446 }
00447 }
00448
00449 if (mgr->IsConnected ())
00450 mgr->GetList (szUrl, NULL, NULL);
00451 else
00452 DeleteAllItems ();
00453
00454 mgr->RetreiveInfoWhileGettingList (bRI);
00455
00456 _pwndHFE->m_wndUrl.m_wndUrl.SetWindowText (strOrigUrl);
00457 if (bWasError)
00458 _pwndHFE->LogFailedMessage (LS (L_FAILED));
00459 }
00460
00461 fs::tree <fsFileInfo*>* CHFE_FileList::BuildList(LPCSTR pszFolder, BOOL *pbNeedStop, int* piProgress, int iProgressDone)
00462 {
00463 fsInternetFileListMgr *mgr = _pwndHFE->GetMgr ();
00464 fs::tree <fsFileInfo*> *pRoot = NULL;
00465 fs::tree <fsFileInfo*> *pCur;
00466
00467 if (*pbNeedStop)
00468 return NULL;
00469
00470 if (pszFolder)
00471 {
00472
00473 mgr->GoFolder (pszFolder);
00474 MSG msg;
00475
00476 while (mgr->IsRunning ())
00477 {
00478 if (*pbNeedStop)
00479 mgr->Stop ();
00480
00481 while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
00482 DispatchMessage (&msg);
00483
00484 Sleep (20);
00485 }
00486
00487 while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
00488 DispatchMessage (&msg);
00489 }
00490
00491 if (*pbNeedStop)
00492 return NULL;
00493
00494
00495 if (mgr->IsConnected () == FALSE)
00496 return NULL;
00497
00498 UINT cFiles = mgr->GetFileCount ();
00499
00500 if (cFiles == 0)
00501 goto _lExit;
00502
00503 fsnew1 (pCur, fs::tree <fsFileInfo*>);
00504 pRoot = pCur;
00505
00506 UINT i;
00507 int iProgress; iProgress = *piProgress;
00508
00509 for (i = 0; i < cFiles && *pbNeedStop == FALSE; i++)
00510 {
00511 fsFileInfo *file = mgr->GetFileInfo (i);
00512
00513 pCur->Data (file);
00514
00515 if (file->bFolder)
00516 {
00517 fsString str = file->strName;
00518
00519 str [str.Length ()-1] = 0;
00520 if (strchr (str, '\\') || strchr (str, '/'))
00521 continue;
00522
00523 try {
00524 fs::tree <fsFileInfo*>* pChildren = BuildList (file->strName, pbNeedStop,
00525 piProgress, iProgressDone/cFiles);
00526 pCur->Right (pChildren);
00527 if (mgr->GetFileCount () != cFiles)
00528 throw 1;
00529 }
00530 catch (...) {
00531 SAFE_DELETE (pRoot);
00532 throw 1;
00533 }
00534 }
00535
00536 if (i < cFiles - 1)
00537 {
00538 fs::tree <fsFileInfo*> *p;
00539
00540 fsnew1 (p, fs::tree <fsFileInfo*>);
00541 pCur->Left (p);
00542 pCur->Left ()->Root (pCur);
00543 pCur = pCur->Left ();
00544 }
00545
00546 *piProgress = iProgress + MulDiv (i, iProgressDone, cFiles);
00547 }
00548
00549 _lExit:
00550
00551 if (pszFolder)
00552 {
00553
00554 mgr->GoParentFolder ();
00555 MSG msg;
00556 while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
00557 DispatchMessage (&msg);
00558 }
00559
00560 return pRoot;
00561 }
00562
00563 DWORD WINAPI CHFE_FileList::_threadBuildList(LPVOID lp)
00564 {
00565 ProcWaitInfo *info = (ProcWaitInfo*) lp;
00566 CHFE_FileList *pThis = (CHFE_FileList*) info->lpParam1;
00567 bool *pbWasError = (bool*) info->lpParam2;
00568 *pbWasError = false;
00569
00570 POSITION pos = pThis->GetFirstSelectedItemPosition ();
00571
00572 pThis->m_pList = NULL;
00573
00574 if (pos == NULL)
00575 return 0;
00576
00577 fsnew1 (pThis->m_pList, fs::tree <fsFileInfo*>);
00578 fs::tree <fsFileInfo*>* pCur = pThis->m_pList;
00579
00580 fs::list <int> vItems;
00581 while (pos)
00582 vItems.add (pThis->GetNextSelectedItem (pos));
00583
00584 int cItems = vItems.size ();
00585 bool bFatalError = false;
00586 for (int i = 0; i < cItems && info->bNeedStop == FALSE; i++)
00587 {
00588 fsFileInfo *file = (fsFileInfo*) pThis->GetItemData (vItems [i]);
00589 pCur->Data (file);
00590 if (file->bFolder)
00591 {
00592 try {
00593 fs::tree <fsFileInfo*>* pChildren = BuildList (file->strName, &info->bNeedStop,
00594 &info->iProgress, 100/cItems);
00595 pCur->Right (pChildren);
00596 }
00597 catch (...) {
00598 bFatalError = true;
00599 break;
00600 }
00601 }
00602
00603 if (i < cItems - 1)
00604 {
00605 fs::tree <fsFileInfo*> *p;
00606 fsnew1 (p, fs::tree <fsFileInfo*>);
00607 pCur->Left (p);
00608 pCur->Left ()->Root (pCur);
00609 pCur = pCur->Left ();
00610 }
00611
00612 info->iProgress = MulDiv (i, 100, cItems);
00613 }
00614
00615 if (info->bNeedStop == FALSE && bFatalError)
00616 {
00617 *pbWasError = true;
00618 info->bNeedStop = TRUE;
00619 }
00620
00621 if (info->bNeedStop)
00622 {
00623 SAFE_DELETE (pThis->m_pList);
00624 info->bNeedStop = FALSE;
00625 }
00626
00627 info->bWaitDone = TRUE;
00628
00629 return 0;
00630 }
00631
00632 int CHFE_FileList::OnUpdateToolBar(UINT nID)
00633 {
00634 BOOL bEnabled = TRUE;
00635
00636 switch (nID)
00637 {
00638 case ID_HFE_STOP:
00639 if (_pwndHFE->GetMgr ()->IsRunning () == FALSE)
00640 bEnabled = FALSE;
00641 break;
00642
00643 case ID_HFE_REFRESH:
00644 case ID_HFE_PARENTFOLDER:
00645 if (_pwndHFE->GetMgr ()->GetCurrentPath () == NULL || _pwndHFE->GetMgr ()->IsRunning ())
00646 bEnabled = FALSE;
00647
00648 if (nID == ID_HFE_PARENTFOLDER && _pwndHFE->GetMgr ()->IsCurrentPathRoot ())
00649 bEnabled = FALSE;
00650 break;
00651
00652 case ID_HFE_BACK:
00653 bEnabled = _pwndHFE->m_wndUrl.m_vAddrs.size () > 1;
00654 break;
00655 }
00656
00657 int cItems = GetSelectedCount ();
00658
00659 if (cItems == 0)
00660 {
00661 if (nID == ID_HFE_DOWNLOAD || nID == ID_HFE_OPENFOLDER)
00662 bEnabled = FALSE;
00663 }
00664 else
00665 {
00666 POSITION pos = GetFirstSelectedItemPosition ();
00667 while (pos)
00668 {
00669 int iItem = GetNextSelectedItem (pos);
00670 fsFileInfo *file = (fsFileInfo*) GetItemData (iItem);
00671
00672 switch (nID)
00673 {
00674 case ID_HFE_DOWNLOAD:
00675 if (iItem == 0 && _pwndHFE->GetMgr ()->IsCurrentPathRoot () == FALSE)
00676 bEnabled = FALSE;
00677 break;
00678
00679 case ID_HFE_OPENFOLDER:
00680 if (iItem == 0 && _pwndHFE->GetMgr ()->IsCurrentPathRoot () && file->bFolder == FALSE)
00681 bEnabled = FALSE;
00682 break;
00683 }
00684 }
00685
00686 if (cItems != 1 && nID == ID_HFE_OPENFOLDER)
00687 bEnabled = FALSE;
00688 }
00689
00690 return bEnabled ? WGP_CMDITEMSTATE_ENABLED : WGP_CMDITEMSTATE_DISABLED;
00691 }
00692
00693 void CHFE_FileList::OnDrawItem(int , LPDRAWITEMSTRUCT lpDrawItemStruct)
00694 {
00695 m_odmenu.OnDrawItem (lpDrawItemStruct);
00696 }
00697
00698 void CHFE_FileList::OnMeasureItem(int , LPMEASUREITEMSTRUCT lpMeasureItemStruct)
00699 {
00700 m_odmenu.OnMeasureItem (lpMeasureItemStruct);
00701 }
00702
00703 void CHFE_FileList::OnHfeDisconnect()
00704 {
00705 _pwndHFE->GetMgr ()->Disconnect ();
00706 DeleteAllItems ();
00707 }
00708
00709 void CHFE_FileList::ApplyLanguageToMenu(CMenu * menu)
00710 {
00711 menu->ModifyMenu (0, MF_BYPOSITION|MF_STRING, 0, LS (L_EXPLORER));
00712
00713 menu->ModifyMenu (ID_HFE_OPENFOLDER, MF_BYCOMMAND|MF_STRING, ID_HFE_OPENFOLDER, LS (L_OPENFOLDER));
00714 menu->ModifyMenu (ID_HFE_PARENTFOLDER, MF_BYCOMMAND|MF_STRING, ID_HFE_PARENTFOLDER, LS (L_OPENPARENTFOLDER));
00715 menu->ModifyMenu (ID_HFE_STOP, MF_BYCOMMAND|MF_STRING, ID_HFE_STOP, LS (L_STOP));
00716 menu->ModifyMenu (ID_HFE_REFRESH, MF_BYCOMMAND|MF_STRING, ID_HFE_REFRESH, LS (L_REFRESH));
00717 menu->ModifyMenu (ID_HFE_DISCONNECT, MF_BYCOMMAND|MF_STRING, ID_HFE_DISCONNECT, LS (L_DISCONNECT));
00718 menu->ModifyMenu (ID_HFE_DOWNLOAD, MF_BYCOMMAND|MF_STRING, ID_HFE_DOWNLOAD, LS (L_DOWNLOAD));
00719 menu->ModifyMenu (ID_HFE_SETTINGS, MF_BYCOMMAND|MF_STRING, ID_HFE_SETTINGS, LS (L_EXPLORERSETTINGS));
00720 }
00721
00722 void CHFE_FileList::ApplyLanguage()
00723 {
00724 SetColumnText (0, LS (L_FILENAME));
00725 SetColumnText (1, LS (L_SIZE));
00726 SetColumnText (2, LS (L_DATE));
00727 }
00728
00729 void CHFE_FileList::CalcCoordsForCurSel()
00730 {
00731 int iCurSel = GetSelectionMark ();
00732 if (iCurSel == -1)
00733 {
00734 POSITION pos = GetFirstSelectedItemPosition ();
00735 if (pos)
00736 iCurSel = GetNextSelectedItem (pos);
00737 }
00738
00739 if (iCurSel != -1)
00740 {
00741 RECT rc;
00742 GetItemRect (iCurSel, &rc, LVIR_BOUNDS);
00743 m_rbPt.x = rc.left + 30;
00744 m_rbPt.y = rc.top;
00745 }
00746 else
00747 m_rbPt.x = m_rbPt.y = 30;
00748 }
00749
00750 void CHFE_FileList::OnForceUpdate()
00751 {
00752 UpdateList ();
00753 }