Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

322 lines
8.4 KiB

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "FileSpyApp.h"
  5. #include "MainFrm.h"
  6. #include "LeftView.h"
  7. #include "FileSpyView.h"
  8. #include "FastIoView.h"
  9. #include "FsFilterView.h"
  10. #include "FilterDlg.h"
  11. #include "global.h"
  12. #include "protos.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CMainFrame
  20. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  21. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  22. //{{AFX_MSG_MAP(CMainFrame)
  23. ON_WM_CREATE()
  24. ON_WM_DESTROY()
  25. ON_COMMAND(ID_EDIT_FILTERS, OnEditFilters)
  26. ON_COMMAND(ID_EDIT_CLEARFASTIO, OnEditClearfastio)
  27. ON_COMMAND(ID_EDIT_CLEARIRP, OnEditClearirp)
  28. ON_COMMAND(ID_EDIT_CLEARFSFILTER, OnEditClearfsfilter)
  29. //}}AFX_MSG_MAP
  30. // Global help commands
  31. ON_COMMAND(ID_HELP_FINDER, CFrameWnd::OnHelpFinder)
  32. ON_COMMAND(ID_HELP, CFrameWnd::OnHelp)
  33. ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
  34. ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpFinder)
  35. ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles)
  36. ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle)
  37. END_MESSAGE_MAP()
  38. static UINT indicators[] =
  39. {
  40. ID_SEPARATOR, // status line indicator
  41. ID_INDICATOR_CAPS,
  42. ID_INDICATOR_NUM,
  43. ID_INDICATOR_SCRL,
  44. };
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CMainFrame construction/destruction
  47. CMainFrame::CMainFrame()
  48. {
  49. // TODO: add member initialization code here
  50. }
  51. CMainFrame::~CMainFrame()
  52. {
  53. }
  54. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  55. {
  56. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  57. return -1;
  58. if (!m_wndToolBar.CreateEx(this) ||
  59. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  60. {
  61. TRACE0("Failed to create toolbar\n");
  62. return -1; // fail to create
  63. }
  64. /* if (!m_wndDlgBar.Create(this, IDR_MAINFRAME,
  65. CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
  66. {
  67. TRACE0("Failed to create dialogbar\n");
  68. return -1; // fail to create
  69. }
  70. */
  71. if (!m_wndReBar.Create(this) ||
  72. !m_wndReBar.AddBar(&m_wndToolBar)) /*||
  73. !m_wndReBar.AddBar(&m_wndDlgBar)) */
  74. {
  75. TRACE0("Failed to create rebar\n");
  76. return -1; // fail to create
  77. }
  78. if (!m_wndStatusBar.Create(this) ||
  79. !m_wndStatusBar.SetIndicators(indicators,
  80. sizeof(indicators)/sizeof(UINT)))
  81. {
  82. TRACE0("Failed to create status bar\n");
  83. return -1; // fail to create
  84. }
  85. // TODO: Remove this if you don't want tool tips
  86. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  87. CBRS_TOOLTIPS | CBRS_FLYBY);
  88. return 0;
  89. }
  90. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
  91. CCreateContext* pContext)
  92. {
  93. // create splitter window
  94. if (!m_wndSplitter.CreateStatic(this, 1, 2))
  95. return FALSE;
  96. if (!m_wndSplitter2.CreateStatic(&m_wndSplitter, 3, 1, WS_CHILD|WS_VISIBLE|WS_BORDER, m_wndSplitter.IdFromRowCol(0, 1)))
  97. {
  98. m_wndSplitter.DestroyWindow();
  99. return FALSE;
  100. }
  101. if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext) ||
  102. !m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CFileSpyView), CSize(100, 100), pContext) ||
  103. !m_wndSplitter2.CreateView(1, 0, RUNTIME_CLASS(CFastIoView), CSize(100, 100), pContext) ||
  104. !m_wndSplitter2.CreateView(2, 0, RUNTIME_CLASS(CFsFilterView), CSize(100, 100), pContext))
  105. {
  106. m_wndSplitter.DestroyWindow();
  107. return FALSE;
  108. }
  109. m_wndSplitter.SetColumnInfo(0, 170, 0);
  110. m_wndSplitter2.SetRowInfo(0, 225, 0);
  111. m_wndSplitter.RecalcLayout();
  112. m_wndSplitter.RecalcLayout();
  113. return TRUE;
  114. }
  115. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  116. {
  117. if( !CFrameWnd::PreCreateWindow(cs) )
  118. return FALSE;
  119. // TODO: Modify the Window class or styles here by modifying
  120. // the CREATESTRUCT cs
  121. return TRUE;
  122. }
  123. /////////////////////////////////////////////////////////////////////////////
  124. // CMainFrame diagnostics
  125. #ifdef _DEBUG
  126. void CMainFrame::AssertValid() const
  127. {
  128. CFrameWnd::AssertValid();
  129. }
  130. void CMainFrame::Dump(CDumpContext& dc) const
  131. {
  132. CFrameWnd::Dump(dc);
  133. }
  134. #endif //_DEBUG
  135. /////////////////////////////////////////////////////////////////////////////
  136. // CMainFrame message handlers
  137. CFileSpyView* CMainFrame::GetRightPane()
  138. {
  139. CWnd* pWnd = m_wndSplitter.GetPane(0, 1);
  140. CFileSpyView* pView = DYNAMIC_DOWNCAST(CFileSpyView, pWnd);
  141. return pView;
  142. }
  143. void CMainFrame::OnUpdateViewStyles(CCmdUI* pCmdUI)
  144. {
  145. // TODO: customize or extend this code to handle choices on the
  146. // View menu.
  147. CFileSpyView* pView = GetRightPane();
  148. // if the right-hand pane hasn't been created or isn't a view,
  149. // disable commands in our range
  150. if (pView == NULL)
  151. pCmdUI->Enable(FALSE);
  152. else
  153. {
  154. DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK;
  155. // if the command is ID_VIEW_LINEUP, only enable command
  156. // when we're in LVS_ICON or LVS_SMALLICON mode
  157. if (pCmdUI->m_nID == ID_VIEW_LINEUP)
  158. {
  159. if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
  160. pCmdUI->Enable();
  161. else
  162. pCmdUI->Enable(FALSE);
  163. }
  164. else
  165. {
  166. // otherwise, use dots to reflect the style of the view
  167. pCmdUI->Enable();
  168. BOOL bChecked = FALSE;
  169. switch (pCmdUI->m_nID)
  170. {
  171. case ID_VIEW_DETAILS:
  172. bChecked = (dwStyle == LVS_REPORT);
  173. break;
  174. case ID_VIEW_SMALLICON:
  175. bChecked = (dwStyle == LVS_SMALLICON);
  176. break;
  177. case ID_VIEW_LARGEICON:
  178. bChecked = (dwStyle == LVS_ICON);
  179. break;
  180. case ID_VIEW_LIST:
  181. bChecked = (dwStyle == LVS_LIST);
  182. break;
  183. default:
  184. bChecked = FALSE;
  185. break;
  186. }
  187. pCmdUI->SetRadio(bChecked ? 1 : 0);
  188. }
  189. }
  190. }
  191. void CMainFrame::OnViewStyle(UINT nCommandID)
  192. {
  193. // TODO: customize or extend this code to handle choices on the
  194. // View menu.
  195. CFileSpyView* pView = GetRightPane();
  196. // if the right-hand pane has been created and is a CFileSpyView,
  197. // process the menu commands...
  198. if (pView != NULL)
  199. {
  200. DWORD dwStyle = (DWORD)-1;
  201. switch (nCommandID)
  202. {
  203. case ID_VIEW_LINEUP:
  204. {
  205. // ask the list control to snap to grid
  206. CListCtrl& refListCtrl = pView->GetListCtrl();
  207. refListCtrl.Arrange(LVA_SNAPTOGRID);
  208. }
  209. break;
  210. // other commands change the style on the list control
  211. case ID_VIEW_DETAILS:
  212. dwStyle = LVS_REPORT;
  213. break;
  214. case ID_VIEW_SMALLICON:
  215. dwStyle = LVS_SMALLICON;
  216. break;
  217. case ID_VIEW_LARGEICON:
  218. dwStyle = LVS_ICON;
  219. break;
  220. case ID_VIEW_LIST:
  221. dwStyle = LVS_LIST;
  222. break;
  223. }
  224. // change the style; window will repaint automatically
  225. if (dwStyle != -1)
  226. pView->ModifyStyle(LVS_TYPEMASK, dwStyle);
  227. }
  228. }
  229. void CMainFrame::OnDestroy()
  230. {
  231. CFrameWnd::OnDestroy();
  232. // TODO: Add your message handler code here
  233. ProgramExit();
  234. }
  235. void CMainFrame::OnEditFilters()
  236. {
  237. // TODO: Add your command handler code here
  238. CFilterDlg cfd;
  239. cfd.DoModal();
  240. }
  241. void CMainFrame::OnEditClearfastio()
  242. {
  243. // TODO: Add your command handler code here
  244. CFastIoView *pView;
  245. pView = (CFastIoView *) pFastIoView;
  246. pView->GetListCtrl().DeleteAllItems();
  247. }
  248. void CMainFrame::OnEditClearirp()
  249. {
  250. // TODO: Add your command handler code here
  251. CFileSpyView* pView;
  252. pView = (CFileSpyView *) pSpyView;
  253. pView->GetListCtrl().DeleteAllItems();
  254. }
  255. void CMainFrame::OnEditClearfsfilter()
  256. {
  257. // TODO: Add your command handler code here
  258. CFsFilterView* pView;
  259. pView = (CFsFilterView *) pFsFilterView;
  260. pView->GetListCtrl().DeleteAllItems();
  261. }