⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 donutlinksbarctrl.h

📁 一个使用wtl写的完整的多窗口浏览器
💻 H
字号:

#pragma once

#include "OleDragDropExpToolBarCtrl.h"

/////////////////////////////////////////////////////////////////////////////
// Rename dialog

class CDonutRenameFileDialog : 
	public CDialogImpl<CDonutRenameFileDialog>,
	public CWinDataExchange<CDonutRenameFileDialog>
{
public:
	enum { IDD = IDD_DIALOG_RENAMEFILE };

// Data members
	CString m_strName;

// DDX map
	BEGIN_DDX_MAP(CDonutRenameFileDialog)
		DDX_TEXT_LEN(IDC_EDIT_RENAMEFILE, m_strName, MAX_PATH)
	END_DDX_MAP()

// Message map and handlers
	BEGIN_MSG_MAP(CAboutDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(IDOK, OnOkCmd)
		COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
	END_MSG_MAP()

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		CenterWindow(GetParent());
		DoDataExchange(FALSE);
		return TRUE;
	}

	LRESULT OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		DoDataExchange(TRUE);
		EndDialog(wID);
		return 0;
	}

	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		EndDialog(wID);
		return 0;
	}
};

/////////////////////////////////////////////////////////////////////////////
template <class _MainFrame>
class CDonutLinksBarCtrl : public COleDragDrogExplorerToolBarCtrlImpl<CDonutLinksBarCtrl>
{
public:
	DECLARE_WND_SUPERCLASS(_T("Donut_LinksBar"), GetWndClassName())
	typedef COleDragDrogExplorerToolBarCtrlImpl<CDonutLinksBarCtrl> baseClass;
	typedef CDonutLinksBarCtrl<_MainFrame> thisClass;

// Data members
	_MainFrame* __m_pMainFrame;

// Ctor
	CDonutLinksBarCtrl(_MainFrame* __pMainFrame, int nInsertPointMenuItemID) : __m_pMainFrame(__pMainFrame),
		COleDragDrogExplorerToolBarCtrlImpl<CDonutLinksBarCtrl>(nInsertPointMenuItemID, 0x012C, 0x0300)
	{
		CString strPath;
		MtlGetFavoriteLinksFolder(strPath);
		ATLASSERT(!strPath.IsEmpty());
		SetExplorerToolBarRootPath(strPath);
	}

	BEGIN_MSG_MAP(thisClass)
		COMMAND_ID_HANDLER(ID_VIEW_REFRESH_FAVBAR, OnViewRefreshLinkBar)
		CHAIN_MSG_MAP(baseClass)
	ALT_MSG_MAP(1)
		CHAIN_MSG_MAP_ALT(baseClass, 1)
	END_MSG_MAP()

	LRESULT OnViewRefreshLinkBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
	{
		m_ExpMenu.RefreshStyle();
		_UpdateButtons();// sorry
		MtlRefreshBandIdealSize(GetParent(), m_hWnd);
		return 0;
	}	

// Overrides
	void OnExecute(const CString& strFilePath)
	{
		ATLTRACE2(atlTraceUser, 4, _T("CFavoriteMenu::OnExecute: %s\n"), strFilePath);
		_The_OpenAllFiles(strFilePath, __m_pMainFrame);
	}

	bool OnRenameExplorerToolBarCtrl(CString& strName)
	{
		CDonutRenameFileDialog dlg;
		dlg.m_strName = strName;

		if (dlg.DoModal() == IDOK && !dlg.m_strName.IsEmpty()) {
			strName = dlg.m_strName;
			return true;
		}

		return false;
	}

	void OnInitialUpdateTBButtons(CSimpleArray<TBBUTTON>& items, LPCITEMIDLIST pidl)
	{
		ATLASSERT(pidl != NULL);

		DWORD dwStyle = CFavoritesMenuOption::GetStyle();
		if (_check_flag(EMS_ORDER_FAVORITES, dwStyle)) {
			CFavoritesOrder order;
			MtlGetFavoritesOrder(order, CItemIDList(pidl).GetPath());
			std::sort(_begin(items), _end(items), _FavoritesTBButtonCompare<thisClass>(order, this));
		}
		else {
			baseClass::OnInitialUpdateTBButtons(items, pidl);
		}
	}

	template <class _This>
	struct _FavoritesTBButtonCompare : public std::binary_function<const TBBUTTON&, const TBBUTTON&, bool>
	{
		CFavoritesOrder& _order;
		_This* _pThis;

		_FavoritesTBButtonCompare(CFavoritesOrder& order, _This* pThis) : _order(order), _pThis(pThis) { }

		bool operator()(const TBBUTTON& x, const TBBUTTON& y)
		{
			CItemIDList idlA = _pThis->_GetIDListFromCmdID(x.idCommand); ATLASSERT(!idlA.IsNull());
			CItemIDList idlB = _pThis->_GetIDListFromCmdID(y.idCommand); ATLASSERT(!idlB.IsNull());

			const int enough = 10000;
			CString strA = MtlGetFileName(idlA.GetPath());
			CString strB = MtlGetFileName(idlB.GetPath());
			ATLASSERT(!strA.IsEmpty() && !strB.IsEmpty());
			
			int itA = _order.Lookup(strA);
			int itB = _order.Lookup(strB);
			if (itA == -1 || itA == FAVORITESORDER_NOTFOUND)// fixed by fub, thanks.
				itA = enough;
			if (itB == -1 || itB == FAVORITESORDER_NOTFOUND)
				itB = enough;

			if (itA == enough && itB == enough) {
				bool bParentA = _pThis->_IsFolderCmdID(x.idCommand);
				bool bParentB = _pThis->_IsFolderCmdID(y.idCommand);
				if (bParentA == bParentB) {
					return strA < strB;
				}
				else {
					if (bParentA)
						return true;
					else
						return false;
				}
			}
			else 
				return itA < itB;
		}
	};
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -