MainFrm.cpp
Upload User: ch83438830
Upload Date: 2007-01-01
Package Size: 104k
Code Size: 6k
Category:

File Operate

Development Platform:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include <AFXPRIV.H>
  5. #include "winpe.h"
  6. #include "MainFrm.h"
  7. #include "winpedoc.h"
  8. #include "dumpxview.h"
  9. #include "ImportView.h"
  10. #include "headerview.h"
  11. #include "sectiontblview.h"
  12. #include "debugdirview.h"
  13. #include "resourcesview.h"
  14. #include "exportview.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CMainFrame
  22. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  23. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  24.     ON_MESSAGE(WM_RESET_FRAMEVIEW,OnFrameView) 
  25. ON_COMMAND_RANGE(ID_VIEWS_IMPORTS,ID_VIEWS_RESOURCES,OnViewChange)
  26. //{{AFX_MSG_MAP(CMainFrame)
  27. ON_WM_CREATE()
  28. ON_COMMAND(ID_FONTS_PRINTER, OnFontsPrinter)
  29. ON_COMMAND(ID_FONTS_DISPLAY, OnFontsDisplay)
  30. //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32. static UINT indicators[] =
  33. {
  34. ID_SEPARATOR,           // status line indicator
  35. ID_INDICATOR_CAPS,
  36. ID_INDICATOR_NUM,
  37. ID_INDICATOR_SCRL,
  38. };
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CMainFrame construction/destruction
  41. CMainFrame::CMainFrame()
  42. {
  43. // TODO: add member initialization code here
  44. m_pImportView = NULL;
  45. m_nCurrentView = 0;
  46. }
  47. CMainFrame::~CMainFrame()
  48. {
  49. }
  50. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  51. {
  52. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  53. return -1;
  54. if (!m_wndToolBar.Create(this) ||
  55. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  56. {
  57. TRACE0("Failed to create toolbarn");
  58. return -1;      // fail to create
  59. }
  60. if (!m_wndStatusBar.Create(this) ||
  61. !m_wndStatusBar.SetIndicators(indicators,
  62.   sizeof(indicators)/sizeof(UINT)))
  63. {
  64. TRACE0("Failed to create status barn");
  65. return -1;      // fail to create
  66. }
  67. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  68. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  69. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  70. // TODO: Delete these three lines if you don't want the toolbar to
  71. //  be dockable
  72. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  73. EnableDocking(CBRS_ALIGN_ANY);
  74. DockControlBar(&m_wndToolBar);
  75. return 0;
  76. }
  77. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  78. {
  79. // TODO: Modify the Window class or styles here by modifying
  80. //  the CREATESTRUCT cs
  81. return CFrameWnd::PreCreateWindow(cs);
  82. }
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CMainFrame diagnostics
  85. #ifdef _DEBUG
  86. void CMainFrame::AssertValid() const
  87. {
  88. CFrameWnd::AssertValid();
  89. }
  90. void CMainFrame::Dump(CDumpContext& dc) const
  91. {
  92. CFrameWnd::Dump(dc);
  93. }
  94. #endif //_DEBUG
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CMainFrame message handlers
  97. LRESULT CMainFrame::OnFrameView(WPARAM wParam,LPARAM lParam) 
  98. {
  99. OnViewChange((UINT)wParam);
  100. return 0;
  101. }
  102. void CMainFrame::OnViewChange(UINT nCmdID) 
  103. {
  104. if (nCmdID == m_nCurrentView)
  105. return; // its showing!
  106. // Set the child window ID of the active view to AFX_IDW_PANE_FIRST.
  107. // This is necessary so that CFrameWnd::RecalcLayout will allocate
  108. // this "first pane" to that portion of the frame window's client
  109. // area not allocated to control bars.  Set the child ID of
  110. // the previously active view to some other ID; we will use the
  111. // command ID as the child ID.
  112. CView* pOldActiveView = GetActiveView();
  113. ::SetWindowLong(pOldActiveView->m_hWnd,
  114. GWL_ID,
  115. m_nCurrentView);
  116. CRuntimeClass* pNewViewClass;
  117. switch (nCmdID)
  118. {
  119. case ID_VIEWS_IMPORTS:
  120. pNewViewClass = RUNTIME_CLASS(CImportView);
  121. break;
  122.         case ID_VIEWS_DUMP:
  123. pNewViewClass = RUNTIME_CLASS(CDumpXView);
  124. break;
  125. case ID_VIEWS_HEADERS:
  126. pNewViewClass = RUNTIME_CLASS(CHeaderView);
  127. break;
  128. case ID_VIEWS_SECTNTBL:
  129. pNewViewClass = RUNTIME_CLASS(CSectionTblView);
  130. break;
  131. case ID_VIEWS_DEBUGDIR:
  132. pNewViewClass = RUNTIME_CLASS(CDebugDirView);
  133. break;
  134. case ID_VIEWS_RESOURCES:
  135. pNewViewClass = RUNTIME_CLASS(CResourceSView);
  136. break;
  137. case ID_VIEWS_EXPORTS:
  138. pNewViewClass = RUNTIME_CLASS(CExportView);
  139. break;
  140. default:
  141. ASSERT(0);
  142. return;
  143. }
  144. // create the new view
  145. CCreateContext context;
  146. context.m_pNewViewClass = pNewViewClass;
  147. context.m_pCurrentDoc = GetActiveDocument();
  148. CView* pNewView = STATIC_DOWNCAST(CView, CreateView(&context));
  149. if (pNewView != NULL)
  150. {
  151. // the new view is there, but invisible and not active...
  152. pNewView->ShowWindow(SW_SHOW);
  153. pNewView->OnInitialUpdate();
  154. SetActiveView(pNewView);
  155. RecalcLayout();
  156. m_nCurrentView = nCmdID;
  157. // finally destroy the old view...
  158. pOldActiveView->DestroyWindow();
  159. }
  160. return;
  161. }
  162. void CMainFrame::OnFontsPrinter() 
  163. {
  164. // TODO: Add your command handler code here
  165. LOGFONT mlf;
  166. CPrintDialog printDialog(FALSE);
  167. if (printDialog.DoModal() == IDCANCEL)
  168. return;
  169. CWinpeDoc* pDoc = (CWinpeDoc*)GetActiveDocument();
  170. pDoc->m_printerFont->GetLogFont(&mlf);
  171. CFontDialog my_fdlg(&mlf);
  172. if (my_fdlg.DoModal() == IDCANCEL)
  173. return;
  174. CClientDC dc (AfxGetMainWnd());
  175. pDoc->SetDocPrtFont(&mlf);
  176. //pOldFont = dc.SelectObject(&m_printerFont);
  177. return;
  178. }
  179. void CMainFrame::OnFontsDisplay() 
  180. {
  181. // TODO: Add your command handler code here
  182. LOGFONT mlf;
  183. CWinpeDoc* pDoc = (CWinpeDoc*)GetActiveDocument();
  184. pDoc->m_screenFont->GetLogFont(&mlf);
  185. CFontDialog my_fdlg(&mlf);
  186. if (my_fdlg.DoModal() == IDCANCEL)
  187. return;
  188. CClientDC dc (AfxGetMainWnd());
  189. pDoc->SetDocScrnFont(&mlf);
  190. dc.SelectObject(pDoc->m_screenFont);
  191. pDoc->UpdateAllViews(FALSE);
  192. return;
  193. }