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

📄 filedlghelper.h

📁 自定义修改打开文件对话框
💻 H
字号:
////////////////////////////////////////////////////////////////
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 6.0 for Windows XP and probably Windows 2000 too.
//
#pragma once

#include "SubClass.h"

class CFileDlgHelper;

//////////////////
// Used to subclass the file dialog
//
class CFileDialogHook : public CSubclassWnd {
protected:
	CFileDlgHelper* m_pHelper;				 // ptr to helper class
	virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
	friend CFileDlgHelper;
};

//////////////////
// Used to subclass the file dialog's parent/owner
//
class CFileDialogOwnerHook : public CSubclassWnd {
protected:
	CFileDlgHelper* m_pHelper;				 // ptr to helper class
	CFileDialog* m_pDlg;						 // ptr your CFileDialog dialog derivate
	HWND m_hwndParent;						 // HWND of real open file dialog
	virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
	void Init(CWnd* pOwner, CFileDialog* pDlg);
	friend CFileDlgHelper;
};


//////////////////
// Class to help parsing file open dialog stuff
//
class CFileDlgHelper {
protected:
	CFileDialogHook m_dlghook;				 // subclass dialog
	CFileDialogOwnerHook m_ownerhook;	 // subclass dialog's owner
	CFileDialog* m_pDlg;						 // your CFileDialog
	BOOL m_bUpdateUI;							 // do idle UI update?

public:
	CFileDlgHelper();
	~CFileDlgHelper();

	// You must call this from your dialog's OnInitDialog
	void Init(CFileDialog* pDlg);

	// usefull fn	s for you to call
	CListCtrl* GetListCtrl();
	
	// get item text--not very useful, use GetItemPathName instead
	CString GetItemText(int i) {
		return GetListCtrl()->GetItemText(i,0);
	}
	
	// get item text--not very useful, use GetItemPathName instead
	CString GetItemName(int i);   // get filename w/o path

	// get item's path name, even if extensions are hidden
	CString GetItemPathName(int i) {
		return GetDisplayNameOf(i, SHGDN_NORMAL|SHGDN_FORPARSING);
	}

	// get display name of an item
	CString GetDisplayNameOf(int i, DWORD flags);
	CString GetDisplayNameOf(LPCITEMIDLIST pidl, DWORD flags);
	CString GetDisplayNameOf(IShellFolder* ish,LPCITEMIDLIST pidl,DWORD flags);
	BOOL IsItemFolder(int i);					// is this item a folder?

	friend CFileDialogHook;
	friend CFileDialogOwnerHook;
};

⌨️ 快捷键说明

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