1 // MainFrm.cpp : implementation of the CMainFrame class
6 #include "MFCExplorerDlg.h"
8 #include "ShellTreeDlg.h"
11 #include "SeaShellView.h"
16 static char THIS_FILE[] = __FILE__;
19 /////////////////////////////////////////////////////////////////////////////
22 IMPLEMENT_DYNCREATE(CMainFrame, CUIExplorerFrameWnd)
24 BEGIN_MESSAGE_MAP(CMainFrame, CUIExplorerFrameWnd)
25 //{{AFX_MSG_MAP(CMainFrame)
27 ON_COMMAND(ID_VIEW_EXPLORERDIALOG, OnViewExplorerdialog)
28 ON_COMMAND(ID_VIEW_FILEFILTER, OnViewFilefilter)
29 ON_COMMAND(ID_VIEW_TREEDIALOG, OnViewTreedialog)
31 ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles)
32 ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle)
33 ON_MESSAGE(WM_SETTINGCHANGE,OnSettingChange)
36 static UINT indicators[] =
38 ID_SEPARATOR, // status line indicator
44 /////////////////////////////////////////////////////////////////////////////
45 // CMainFrame construction/destruction
47 CMainFrame::CMainFrame()
49 // TODO: add member initialization code here
50 m_IDToolbar = IDR_MAINFRAME;
51 SetExplorerView(RUNTIME_CLASS(CSeaShellView));
54 CMainFrame::~CMainFrame()
58 void CMainFrame::CreateCoolBar()
60 if (m_pwndCoolBar == NULL)
61 m_pwndCoolBar = new CWebBrowserCoolBar;
62 // hook up the frame window for notification messages
63 ((CWebBrowserCoolBar*)m_pwndCoolBar)->GetComboBox().SetTreeCtrlWnd(GetSafeHwnd());
66 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
68 if (CUIExplorerFrameWnd::OnCreate(lpCreateStruct) == -1)
73 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
75 if( !CUIExplorerFrameWnd::PreCreateWindow(cs) )
77 // TODO: Modify the Window class or styles here by modifying
78 // the CREATESTRUCT cs
83 /////////////////////////////////////////////////////////////////////////////
84 // CMainFrame diagnostics
87 void CMainFrame::AssertValid() const
89 CUIExplorerFrameWnd::AssertValid();
92 void CMainFrame::Dump(CDumpContext& dc) const
94 CUIExplorerFrameWnd::Dump(dc);
99 /////////////////////////////////////////////////////////////////////////////
100 // CMainFrame message handlers
102 CSeaShellView* CMainFrame::GetRightPane()
104 CWnd* pWnd = GetSplitterWnd().GetPane(0, 1);
105 CSeaShellView* pView = DYNAMIC_DOWNCAST(CSeaShellView, pWnd);
109 void CMainFrame::OnUpdateViewStyles(CCmdUI* pCmdUI)
111 // TODO: customize or extend this code to handle choices on the
114 CSeaShellView* pView = GetRightPane();
116 // if the right-hand pane hasn't been created or isn't a view,
117 // disable commands in our range
120 pCmdUI->Enable(FALSE);
123 DWORD dwStyle = pView->GetListCtrl().GetViewType();
125 // if the command is ID_VIEW_LINEUP, only enable command
126 // when we're in LVS_ICON or LVS_SMALLICON mode
128 if (pCmdUI->m_nID == ID_VIEW_LINEUP)
130 if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
133 pCmdUI->Enable(FALSE);
137 // otherwise, use dots to reflect the style of the view
139 BOOL bChecked = FALSE;
141 switch (pCmdUI->m_nID)
143 case ID_VIEW_DETAILS:
144 bChecked = (dwStyle == LVS_REPORT);
147 case ID_VIEW_SMALLICON:
148 bChecked = (dwStyle == LVS_SMALLICON);
151 case ID_VIEW_LARGEICON:
152 bChecked = (dwStyle == LVS_ICON);
156 bChecked = (dwStyle == LVS_LIST);
164 pCmdUI->SetRadio(bChecked ? 1 : 0);
170 void CMainFrame::OnViewStyle(UINT nCommandID)
172 // TODO: customize or extend this code to handle choices on the
174 CSeaShellView* pView = (CSeaShellView*)theApp.GetView(RUNTIME_CLASS(CSeaShellView));;
176 // if the right-hand pane has been created and is a CSeaShellView,
177 // process the menu commands...
186 // ask the list control to snap to grid
187 CListCtrl& refListCtrl = pView->GetListCtrl();
188 refListCtrl.Arrange(LVA_SNAPTOGRID);
192 // other commands change the style on the list control
193 case ID_VIEW_DETAILS:
194 dwStyle = LVS_REPORT;
197 case ID_VIEW_SMALLICON:
198 dwStyle = LVS_SMALLICON;
201 case ID_VIEW_LARGEICON:
210 // change the style; window will repaint automatically
212 pView->GetListCtrl().SetViewType(dwStyle);
216 LRESULT CMainFrame::OnSettingChange(WPARAM wParam, LPARAM lParam)
218 TRACE(_T("OnSettingChange\n"));
219 CSeaShellView *pListView = (CSeaShellView*)theApp.GetView(RUNTIME_CLASS(CSeaShellView));
221 pListView->GetListCtrl().SendMessage(WM_SETTINGCHANGE,wParam,lParam);
225 void CMainFrame::OnViewExplorerdialog()
227 // TODO: Add your command handler code here
228 CLeftView *pTreeView = (CLeftView*)theApp.GetView(RUNTIME_CLASS(CLeftView));
230 if (pTreeView && pTreeView->GetShellTreeCtrl().GetSelectedItem() != pTreeView->GetShellTreeCtrl().GetRootItem())
232 dlg.SetPath(pTreeView->GetShellTreeCtrl().GetSelectedPath());
237 void CMainFrame::OnViewFilefilter()
239 // TODO: Add your command handler code here
240 CSeaShellView *pListView = (CSeaShellView*)theApp.GetView(RUNTIME_CLASS(CSeaShellView));
244 dlg.m_Filter = pListView->GetShellListCtrl().GetFileFilter();
245 if (!pListView->GetShellListCtrl().GetExcludedFileTypes().IsEmpty())
246 dlg.m_FileType = pListView->GetShellListCtrl().GetExcludedFileTypes().GetHead();
247 if (dlg.DoModal() == IDOK)
249 if (!dlg.m_FileType.IsEmpty())
250 pListView->GetShellListCtrl().ExcludeFileType(dlg.m_FileType);
251 pListView->GetShellListCtrl().SetFileFilter(dlg.m_Filter);
252 pListView->GetShellListCtrl().Refresh();
257 void CMainFrame::OnViewTreedialog()
259 // TODO: Add your command handler code here