View.h
上传用户:hy_wanghao
上传日期:2007-01-08
资源大小:279k
文件大小:7k
- // View.h : Declaration of the CView
- //
- // Written by Bjarke Viksoe (bjarke@viksoe.dk)
- // Copyright (c) 2001 Bjarke Viksoe.
- //
- // This code may be used in compiled form in any way you desire. This
- // file may be redistributed by any means PROVIDING it is
- // not sold for profit without the authors written consent, and
- // providing that this notice and the authors name is included.
- //
- // This file is provided "as is" with no expressed or implied warranty.
- // The author accepts no liability if it causes any damage to you or your
- // computer whatsoever. It's free, so don't hassle me about it.
- //
- // Beware of bugs.
- #ifndef __VIEW_H_
- #define __VIEW_H_
- #include "resource.h" // main symbols
- #include "Folder.h"
- /////////////////////////////////////////////////////////////////////////////
- // CView
- class ATL_NO_VTABLE CView :
- public CComObjectRootEx<CComSingleThreadModel>,
- public CComCoClass<CView, &CLSID_View>,
- public IShellViewImpl<CView>
- {
- public:
- HRESULT FinalConstruct();
- void FinalRelease();
- DECLARE_NOT_AGGREGATABLE(CView)
- DECLARE_PROTECT_FINAL_CONSTRUCT()
- BEGIN_COM_MAP(CView)
- COM_INTERFACE_ENTRY_IID(IID_IShellView,IShellView)
- COM_INTERFACE_ENTRY_IID(IID_IShellView2,IShellView2)
- COM_INTERFACE_ENTRY(IOleWindow)
- END_COM_MAP()
- BEGIN_MSG_MAP(CView)
- MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
- MESSAGE_HANDLER(WM_MENUSELECT, OnMenuSelect)
- NOTIFY_CODE_HANDLER(LVN_GETDISPINFO, OnNotifyDispInfo)
- NOTIFY_CODE_HANDLER(LVN_ITEMACTIVATE, OnItemActivated)
- NOTIFY_CODE_HANDLER(LVN_DELETEITEM, OnDeleteItem)
- NOTIFY_CODE_HANDLER(HDN_ITEMCLICK, OnHeaderClick)
- NOTIFY_CODE_HANDLER(LVN_BEGINLABELEDIT, OnLabelEditBegin)
- NOTIFY_CODE_HANDLER(LVN_ENDLABELEDIT, OnLabelEditEnd)
- NOTIFY_CODE_HANDLER(LVN_BEGINDRAG, OnBeginDrag)
- NOTIFY_CODE_HANDLER(LVN_BEGINRDRAG, OnBeginDrag)
- NOTIFY_CODE_HANDLER(LVN_ITEMCHANGED, OnItemChanged)
- COMMAND_ID_HANDLER(ID_GO_UP, OnGoUp)
- COMMAND_ID_HANDLER(ID_NEWITEM_FOLDER, OnNewFolder)
- COMMAND_ID_HANDLER(ID_FILE_OPEN, OnFileOpen)
- COMMAND_ID_HANDLER(ID_FILE_RENAME, OnFileRename)
- COMMAND_ID_HANDLER(ID_FILE_UNDELETE, OnFileUndelete)
- COMMAND_ID_HANDLER(ID_EDIT_DELETE, OnFileDelete)
- COMMAND_ID_HANDLER(ID_EDIT_PROPERTIES, OnFileProperties)
- COMMAND_ID_HANDLER(ID_EDIT_COPY, OnCopy)
- COMMAND_ID_HANDLER(ID_EDIT_CUT, OnCut)
- COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnPaste)
- COMMAND_ID_HANDLER(ID_EDIT_SELECTALL, OnSelectAll)
- COMMAND_ID_HANDLER(ID_EDIT_INVERTSEL, OnInvertSelection)
- COMMAND_ID_HANDLER(ID_VIEW_REFRESH, OnRefresh)
- COMMAND_ID_HANDLER(ID_VIEW_DELETEDFILES, OnViewDeletedFiles)
- COMMAND_ID_HANDLER(ID_VIEW_REPORT, OnViewChange)
- COMMAND_ID_HANDLER(ID_VIEW_SMALLICONS, OnViewChange)
- COMMAND_ID_HANDLER(ID_VIEW_LARGEICONS, OnViewChange)
- COMMAND_ID_HANDLER(ID_VIEW_LIST, OnViewChange)
- COMMAND_ID_HANDLER(ID_VIEW_CHANGE, OnViewChange)
- COMMAND_ID_HANDLER(ID_HELP_HELPTOPICS, OnShowHelp)
- CHAIN_MSG_MAP(IShellViewImpl<CView>)
- END_MSG_MAP()
- // CView
- public:
- static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
- {
- CComBSTR bstrDescription;
- CComBSTR bstrCLSID(CLSID_View);
- bstrDescription.LoadString(IDS_DESCRIPTION);
- _ATL_REGMAP_ENTRY rm[] = {
- { OLESTR("DESCRIPTION"), bstrDescription },
- { OLESTR("CLSID"), bstrCLSID },
- { NULL,NULL } };
- return _Module.UpdateRegistryFromResource(IDR_VIEW, bRegister, rm);
- }
- // IShellView
- public:
- STDMETHOD(CreateViewWindow)(
- IShellView *lpPrevView,
- LPCFOLDERSETTINGS lpfs,
- IShellBrowser *psb,
- RECT *prcView,
- HWND *phWnd);
- STDMETHOD(DestroyViewWindow)(void);
- STDMETHOD(TranslateAccelerator)(LPMSG lpmsg);
- STDMETHOD(GetItemObject)(UINT uItem, REFIID riid, LPVOID *ppRetVal);
- // Implementation
- public:
- HRESULT _Init(CFolder *pFolder);
- BOOL _InitListView();
- BOOL _FillListView();
- static int CALLBACK _ListViewSortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
- //
- BOOL _MergeToolbar(UINT uState);
- BOOL _UpdateToolbar();
- BOOL _MergeMenus(UINT uState);
- BOOL _UpdateMenu(HMENU hMenu);
- private:
- HRESULT _DoCopyOperation(bool bDragDrop, bool bCut);
- BOOL _HasClipDataReady();
- // Message handlers
- LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnViewRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- LRESULT OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- //
- LRESULT OnNotifyDispInfo(UINT CtlID, LPNMHDR lpnmh, BOOL &bHandled);
- LRESULT OnHeaderClick(UINT CtlID, LPNMHDR lpnmh, BOOL &bHandled);
- LRESULT OnItemActivated(UINT CtlID, LPNMHDR lpnmh, BOOL &bHandled);
- LRESULT OnDeleteItem(UINT CtlID, LPNMHDR lpnmh, BOOL &bHandled);
- LRESULT OnLabelEditBegin(UINT CtlID, LPNMHDR lpnmh, BOOL &bHandled);
- LRESULT OnLabelEditEnd(UINT CtlID, LPNMHDR lpnmh, BOOL &bHandled);
- LRESULT OnBeginDrag(UINT CtlID, LPNMHDR lpnmh, BOOL &bHandled);
- LRESULT OnItemChanged(UINT CtlID, LPNMHDR lpnmh, BOOL &bHandled);
- //
- LRESULT OnNewFolder(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnGoUp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnFileOpen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnFileRename(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnFileDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnFileUndelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnFileProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnViewChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnViewDeletedFiles(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnRefresh(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnInvertSelection(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnShowHelp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- // Attributes
- protected:
- CFolder *m_pFolder;
- HMENU m_hMenu;
- HACCEL m_hAccels;
- bool m_bInEdit;
- bool m_bShowDeletedFiles;
- };
- #endif //__VIEW_H_