diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-26 17:25:14 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-26 17:25:14 +0000 |
commit | 6a1a045e620dba38a7a64070af59d1a91b104921 (patch) | |
tree | a883339faf5d30db219509d86acb090eae77e2b6 /plugins/FTPFileYM/src/manager.cpp | |
parent | 1c023b4c677e8dcf0a776b07d8679a6464d2ee61 (diff) |
massive code cleaning due to numerous name conflicts
git-svn-id: http://svn.miranda-ng.org/main/trunk@15036 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/FTPFileYM/src/manager.cpp')
-rw-r--r-- | plugins/FTPFileYM/src/manager.cpp | 498 |
1 files changed, 225 insertions, 273 deletions
diff --git a/plugins/FTPFileYM/src/manager.cpp b/plugins/FTPFileYM/src/manager.cpp index 5b5250169e..ebe4755682 100644 --- a/plugins/FTPFileYM/src/manager.cpp +++ b/plugins/FTPFileYM/src/manager.cpp @@ -30,17 +30,18 @@ extern Options &opt; extern ServerList &ftpList;
Manager::Manager()
-{ }
+{
+}
Manager::~Manager()
{
- for (UINT i = 0; i < this->rootItems.size(); i++)
- delete this->rootItems[i];
+ for (UINT i = 0; i < m_rootItems.size(); i++)
+ delete m_rootItems[i];
- for (UINT i = 0; i < this->items.size(); i++)
- delete this->items[i];
+ for (UINT i = 0; i < m_items.size(); i++)
+ delete m_items[i];
- ImageList_Destroy(this->himlStates);
+ ImageList_Destroy(m_himlStates);
DBEntry::cleanupDB();
instance = NULL;
@@ -50,16 +51,14 @@ Manager::~Manager() void Manager::init()
{
ServerList::FTP *ftp = ftpList.getSelected();
- if (ftp->bEnabled)
- {
- this->hwnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DLG_MANAGER), NULL, Manager::ManagerDlgProc);
- this->hwndFileTree = GetDlgItem(this->hwnd, IDC_FILELIST);
- this->initImageList();
- this->fillTree();
- this->show();
+ if (ftp->m_bEnabled) {
+ m_hwnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DLG_MANAGER), NULL, Manager::ManagerDlgProc);
+ m_hwndFileTree = GetDlgItem(m_hwnd, IDC_FILELIST);
+ initImageList();
+ fillTree();
+ show();
}
- else
- {
+ else {
Utils::msgBox(TranslateT("You have to fill and enable at least one FTP server in setting."), MB_OK);
delete this;
}
@@ -67,45 +66,42 @@ void Manager::init() void Manager::show()
{
- ShowWindow(this->hwnd, SW_SHOWNORMAL);
- BringWindowToTop(this->hwnd);
+ ShowWindow(m_hwnd, SW_SHOWNORMAL);
+ BringWindowToTop(m_hwnd);
}
void Manager::initImageList()
{
char buff[256];
- this->himlStates = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, ServerList::FTP_COUNT + 4, 0);
- ImageList_AddIcon(himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE)); // image index 0 is useless for INDEXTOSTATEIMAGEMASK
- ImageList_AddIcon(himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE));
- ImageList_AddIcon(himlStates, Skin_LoadIcon(SKINICON_OTHER_NOTICK));
- ImageList_AddIcon(himlStates, Skin_LoadIcon(SKINICON_OTHER_TICK));
+ m_himlStates = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, ServerList::FTP_COUNT + 4, 0);
+ ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE)); // image index 0 is useless for INDEXTOSTATEIMAGEMASK
+ ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE));
+ ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_NOTICK));
+ ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_TICK));
- for (int i = 0; i < ServerList::FTP_COUNT; i++)
- {
+ for (int i = 0; i < ServerList::FTP_COUNT; i++) {
mir_snprintf(buff, "ftp%d", i);
- ImageList_AddIcon(himlStates, Utils::loadIconEx(buff));
+ ImageList_AddIcon(m_himlStates, Utils::loadIconEx(buff));
}
- TreeView_SetImageList(this->hwndFileTree, himlStates, TVSIL_STATE);
- TreeView_SetItemHeight(this->hwndFileTree, 18);
+ TreeView_SetImageList(m_hwndFileTree, m_himlStates, TVSIL_STATE);
+ TreeView_SetItemHeight(m_hwndFileTree, 18);
}
void Manager::initRootItems()
{
- TVINSERTSTRUCT tvi = {0};
+ TVINSERTSTRUCT tvi = { 0 };
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_STATE;
tvi.item.stateMask = TVIS_STATEIMAGEMASK | TVIS_EXPANDED | TVIS_BOLD;
- for (UINT i = 0; i < ServerList::FTP_COUNT; i++)
- {
- if (ftpList[i]->bEnabled)
- {
- tvi.item.pszText = ftpList[i]->stzName;
+ for (UINT i = 0; i < ServerList::FTP_COUNT; i++) {
+ if (ftpList[i]->m_bEnabled) {
+ tvi.item.pszText = ftpList[i]->m_stzName;
tvi.item.state = INDEXTOSTATEIMAGEMASK(i + 4) | TVIS_EXPANDED | TVIS_BOLD;
- HTREEITEM hItem = TreeView_InsertItem(this->hwndFileTree, &tvi);
- this->AddRoot(hItem);
+ HTREEITEM hItem = TreeView_InsertItem(m_hwndFileTree, &tvi);
+ AddRoot(hItem);
}
}
}
@@ -114,7 +110,7 @@ void Manager::fillTree() {
initRootItems();
- TVINSERTSTRUCT tvi = {0};
+ TVINSERTSTRUCT tvi = { 0 };
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_STATE;
tvi.item.stateMask = TVIS_STATEIMAGEMASK;
@@ -122,15 +118,13 @@ void Manager::fillTree() mir_cslock lock(DBEntry::mutexDB);
- DBEntry *entry = DBEntry::getFirts();
- while (entry != NULL)
- {
- if ((UINT)entry->iFtpNum < this->rootItems.size())
- {
- tvi.item.pszText = mir_a2t(entry->szFileName);
- tvi.hParent = this->rootItems[entry->iFtpNum]->handle;
- HTREEITEM hItem = TreeView_InsertItem(this->hwndFileTree, &tvi);
- this->AddLeaf(hItem, tvi.hParent, entry->fileID);
+ DBEntry *entry = DBEntry::getFirst();
+ while (entry != NULL) {
+ if ((UINT)entry->m_iFtpNum < m_rootItems.size()) {
+ tvi.item.pszText = mir_a2t(entry->m_szFileName);
+ tvi.hParent = m_rootItems[entry->m_iFtpNum]->m_handle;
+ HTREEITEM hItem = TreeView_InsertItem(m_hwndFileTree, &tvi);
+ AddLeaf(hItem, tvi.hParent, entry->m_fileID);
FREE(tvi.item.pszText);
}
@@ -140,9 +134,8 @@ void Manager::fillTree() int Manager::indexOf(HTREEITEM handle)
{
- for (UINT i = 0; i < this->rootItems.size(); i++)
- {
- if (this->rootItems[i]->handle == handle)
+ for (UINT i = 0; i < m_rootItems.size(); i++) {
+ if (m_rootItems[i]->m_handle == handle)
return i;
}
@@ -151,59 +144,58 @@ int Manager::indexOf(HTREEITEM handle) Manager::TreeItem *Manager::getItem(HTREEITEM handle)
{
- for (UINT i = 0; i < this->rootItems.size(); i++)
- {
- if (this->rootItems[i]->handle == handle)
- return this->rootItems[i];
+ for (UINT i = 0; i < m_rootItems.size(); i++) {
+ if (m_rootItems[i]->m_handle == handle)
+ return m_rootItems[i];
}
- for (UINT i = 0; i < this->items.size(); i++)
- {
- if (this->items[i]->handle == handle)
- return this->items[i];
+ for (UINT i = 0; i < m_items.size(); i++) {
+ if (m_items[i]->m_handle == handle)
+ return m_items[i];
}
return NULL;
}
-Manager::TreeItem::TreeItem(HTREEITEM _handle, HTREEITEM _parent, int _id)
-:handle(_handle),parent(_parent),fileID(_id)
-{
- stzToolTip[0] = 0;
+Manager::TreeItem::TreeItem(HTREEITEM _handle, HTREEITEM _parent, int _id) :
+ m_handle(_handle),
+ m_parent(_parent),
+ m_fileID(_id)
+{
+ m_tszToolTip[0] = 0;
}
void Manager::TreeItem::setState(UINT state)
{
- TVITEM item = {0};
+ TVITEM item = { 0 };
item.mask = TVIF_HANDLE | TVIF_STATE;
item.stateMask = TVIS_STATEIMAGEMASK;
- item.hItem = this->handle;
- TreeView_GetItem(manDlg->hwndFileTree, &item);
+ item.hItem = m_handle;
+ TreeView_GetItem(manDlg->m_hwndFileTree, &item);
- if (TreeItem::_GETSTATE(item.state) != 0)
- {
+ if (TreeItem::_GETSTATE(item.state) != 0) {
item.state = state;
- TreeView_SetItem(manDlg->hwndFileTree, &item);
+ TreeView_SetItem(manDlg->m_hwndFileTree, &item);
}
}
UINT Manager::TreeItem::getState()
{
- TVITEM item = {0};
+ TVITEM item = { 0 };
item.mask = TVIF_HANDLE | TVIF_STATE;
item.stateMask = TVIS_STATEIMAGEMASK;
- item.hItem = this->handle;
- TreeView_GetItem(manDlg->hwndFileTree, &item);
+ item.hItem = m_handle;
+ TreeView_GetItem(manDlg->m_hwndFileTree, &item);
return TreeItem::_GETSTATE(item.state);
}
void Manager::TreeItem::toggleState()
{
- TVITEM item = {0};
+ TVITEM item = { 0 };
item.mask = TVIF_HANDLE | TVIF_STATE;
item.stateMask = TVIS_STATEIMAGEMASK;
- item.hItem = this->handle;
- TreeView_GetItem(manDlg->hwndFileTree, &item);
+ item.hItem = m_handle;
+ TreeView_GetItem(manDlg->m_hwndFileTree, &item);
UINT state = TreeItem::_GETSTATE(item.state);
if (state == STATE_UNCHECKED)
@@ -211,238 +203,198 @@ void Manager::TreeItem::toggleState() else if (state == STATE_CHECKED || state == STATE_ERROR)
item.state = TreeItem::_UNCHECKED();
- TreeView_SetItem(manDlg->hwndFileTree, &item);
+ TreeView_SetItem(manDlg->m_hwndFileTree, &item);
}
void Manager::TreeItem::remove()
{
- TreeView_DeleteItem(manDlg->hwndFileTree, this->handle);
- DBEntry::remove(this->fileID);
+ TreeView_DeleteItem(manDlg->m_hwndFileTree, m_handle);
+ DBEntry::remove(m_fileID);
}
bool Manager::TreeItem::isRoot()
{
- return (this->parent != NULL) ? false : true;
+ return (m_parent != NULL) ? false : true;
}
-INT_PTR CALLBACK Manager::ManagerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK Manager::ManagerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Utils::loadIconEx("main"));
- SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_TICK));
- SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select All"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_NOTICK));
- SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear All"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("clear"));
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from List"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("delete"));
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from FTP"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_EXIT));
- SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Close"), BATF_TCHAR);
-
- return TRUE;
- }
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
- {
- switch (LOWORD(wParam))
- {
- case IDC_BTN_DELETE:
- {
- for (UINT i = 0; i < manDlg->items.size(); i++)
- {
- TreeItem *item = manDlg->items[i];
- if (item->getState() == STATE_CHECKED)
- {
- DeleteJob *job = new DeleteJob(DBEntry::get(item->fileID), item);
- job->start();
- }
- }
- break;
- }
- case IDC_BTN_DELETEFROMLIST:
- {
- for (UINT i = 0; i < manDlg->items.size(); i++)
- {
- TreeItem *item = manDlg->items[i];
- if (item->getState() == STATE_CHECKED)
- item->remove();
- }
- break;
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Utils::loadIconEx("main"));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_TICK));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select All"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_NOTICK));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear All"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("clear"));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from List"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("delete"));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from FTP"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_EXIT));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Close"), BATF_TCHAR);
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
+ case IDC_BTN_DELETE:
+ for (UINT i = 0; i < manDlg->m_items.size(); i++) {
+ TreeItem *item = manDlg->m_items[i];
+ if (item->getState() == STATE_CHECKED) {
+ DeleteJob *job = new DeleteJob(DBEntry::get(item->m_fileID), item);
+ job->start();
}
- case IDC_BTN_SELECTALL:
- case IDC_BTN_DESELECTALL:
- {
- UINT newState = (LOWORD(wParam) == IDC_BTN_SELECTALL) ?
- TreeItem::_CHECKED() : TreeItem::_UNCHECKED();
+ }
+ break;
- for (UINT i = 0; i < manDlg->items.size(); i++)
- manDlg->items[i]->setState(newState);
+ case IDC_BTN_DELETEFROMLIST:
+ for (UINT i = 0; i < manDlg->m_items.size(); i++) {
+ TreeItem *item = manDlg->m_items[i];
+ if (item->getState() == STATE_CHECKED)
+ item->remove();
+ }
+ break;
+
+ case IDC_BTN_SELECTALL:
+ case IDC_BTN_DESELECTALL:
+ {
+ UINT newState = (LOWORD(wParam) == IDC_BTN_SELECTALL) ?
+ TreeItem::_CHECKED() : TreeItem::_UNCHECKED();
+
+ for (UINT i = 0; i < manDlg->m_items.size(); i++)
+ manDlg->m_items[i]->setState(newState);
- break;
- }
- case IDC_BTN_CLOSE:
- {
- DestroyWindow(hwndDlg);
- break;
- }
}
- }
+ break;
- break;
+ case IDC_BTN_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+ }
}
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->idFrom == IDC_FILELIST)
- {
- switch(((LPNMHDR)lParam)->code)
+ break;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->idFrom == IDC_FILELIST) {
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_KEYDOWN:
+ if (((LPNMTVKEYDOWN)lParam)->wVKey != VK_SPACE)
+ break;
+
+ case NM_CLICK:
{
- case TVN_KEYDOWN:
- if (((LPNMTVKEYDOWN)lParam)->wVKey != VK_SPACE)
- break;
- case NM_CLICK:
- {
- HTREEITEM hItem;
- TVHITTESTINFO hti = {0};
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
- if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || ((LPNMHDR)lParam)->code == TVN_KEYDOWN)
- {
- if (((LPNMHDR)lParam)->code == TVN_KEYDOWN)
- {
- hti.flags |= TVHT_ONITEMSTATEICON;
- hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
- }
- else
- {
- hItem = hti.hItem;
- }
-
- TreeItem *item = manDlg->getItem(hItem);
- if (item && (hti.flags & TVHT_ONITEMSTATEICON))
- {
- if (item->isRoot())
- {
- for (UINT i = 0; i < manDlg->items.size(); i++)
- {
- if (manDlg->items[i]->parent == item->handle)
- manDlg->items[i]->toggleState();
- }
- }
- else
- {
- item->toggleState();
+ HTREEITEM hItem;
+ TVHITTESTINFO hti = { 0 };
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
+ if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || ((LPNMHDR)lParam)->code == TVN_KEYDOWN) {
+ if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) {
+ hti.flags |= TVHT_ONITEMSTATEICON;
+ hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
+ }
+ else {
+ hItem = hti.hItem;
+ }
+
+ TreeItem *item = manDlg->getItem(hItem);
+ if (item && (hti.flags & TVHT_ONITEMSTATEICON)) {
+ if (item->isRoot()) {
+ for (UINT i = 0; i < manDlg->m_items.size(); i++) {
+ if (manDlg->m_items[i]->m_parent == item->m_handle)
+ manDlg->m_items[i]->toggleState();
}
}
+ else {
+ item->toggleState();
+ }
}
- return TRUE;
- }
- case NM_RCLICK:
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(manDlg->hwndFileTree, &hti.pt);
- if (TreeView_HitTest(manDlg->hwndFileTree, &hti))
- {
- HTREEITEM hItem = hti.hItem;
- TreeItem *item = manDlg->getItem(hItem);
- if (item && !item->isRoot())
- {
- POINT pt;
- GetCursorPos(&pt);
- SetForegroundWindow(hwndDlg);
- HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_MANAGER));
- if (hMenu)
- {
- HMENU hPopupMenu = GetSubMenu(hMenu, 0);
- TranslateMenu(hPopupMenu);
- int command = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
- switch (command)
- {
-
- case IDM_DELETEFROMLIST:
- {
- item->remove();
- break;
- }
- case IDM_DELETEFROMFTP:
- {
- DeleteJob *job = new DeleteJob(DBEntry::get(item->fileID), item);
- job->start();
- break;
- }
- case IDM_COPYLINK:
- case IDM_DOWNLOAD:
- {
- int ftpNum = manDlg->indexOf(item->parent);
- if (ftpNum != -1)
- {
- char buff[256];
-
- DBEntry *entry = DBEntry::get(item->fileID);
- Utils::createFileDownloadLink(ftpList[ftpNum]->szUrl, entry->szFileName, buff, sizeof(buff));
- delete entry;
-
- if (command == IDM_COPYLINK)
- Utils::copyToClipboard(buff);
- else
- ShellExecuteA(NULL, "open", buff, NULL, NULL, SW_SHOWNORMAL);
- }
- break;
- }
+ }
+ }
+ return TRUE;
+
+ case NM_RCLICK:
+ {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(manDlg->m_hwndFileTree, &hti.pt);
+ if (TreeView_HitTest(manDlg->m_hwndFileTree, &hti)) {
+ HTREEITEM hItem = hti.hItem;
+ TreeItem *item = manDlg->getItem(hItem);
+ if (item && !item->isRoot()) {
+ POINT pt;
+ GetCursorPos(&pt);
+ SetForegroundWindow(hwndDlg);
+ HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_MANAGER));
+ if (hMenu) {
+ HMENU hPopupMenu = GetSubMenu(hMenu, 0);
+ TranslateMenu(hPopupMenu);
+ int command = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
+ switch (command) {
+ case IDM_DELETEFROMLIST:
+ item->remove();
+ break;
+
+ case IDM_DELETEFROMFTP:
+ (new DeleteJob(DBEntry::get(item->m_fileID), item))->start();
+ break;
+
+ case IDM_COPYLINK:
+ case IDM_DOWNLOAD:
+ int ftpNum = manDlg->indexOf(item->m_parent);
+ if (ftpNum != -1) {
+ char buff[256];
+
+ DBEntry *entry = DBEntry::get(item->m_fileID);
+ Utils::createFileDownloadLink(ftpList[ftpNum]->m_szUrl, entry->m_szFileName, buff, sizeof(buff));
+ delete entry;
+
+ if (command == IDM_COPYLINK)
+ Utils::copyToClipboard(buff);
+ else
+ ShellExecuteA(NULL, "open", buff, NULL, NULL, SW_SHOWNORMAL);
}
- DestroyMenu(hMenu);
+ break;
}
+ DestroyMenu(hMenu);
}
}
- return TRUE;
}
- case TVN_GETINFOTIP:
- {
- NMTVGETINFOTIP *tvInfoTip = (NMTVGETINFOTIP *)lParam;
- TreeItem *item = manDlg->getItem(tvInfoTip->hItem);
-
- if (item)
- {
- if (item->stzToolTip[0])
- {
- _tcsncpy(tvInfoTip->pszText, item->stzToolTip, tvInfoTip->cchTextMax - 1);
- tvInfoTip->pszText[tvInfoTip->cchTextMax - 1] = 0;
- }
- }
-
- return TRUE;
+ return TRUE;
+ }
+ case TVN_GETINFOTIP:
+ NMTVGETINFOTIP *tvInfoTip = (NMTVGETINFOTIP *)lParam;
+ TreeItem *item = manDlg->getItem(tvInfoTip->hItem);
+
+ if (item) {
+ if (item->m_tszToolTip[0]) {
+ _tcsncpy(tvInfoTip->pszText, item->m_tszToolTip, tvInfoTip->cchTextMax - 1);
+ tvInfoTip->pszText[tvInfoTip->cchTextMax - 1] = 0;
}
}
- }
- break;
- }
- case WM_CLOSE:
- {
- DestroyWindow(hwndDlg);
- return TRUE;
- }
- case WM_DESTROY:
- {
- delete manDlg;
- return TRUE;
+ return TRUE;
+ }
}
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ return TRUE;
+
+ case WM_DESTROY:
+ delete manDlg;
+ return TRUE;
}
return FALSE;
-}
\ No newline at end of file +}
|