MainFrm.cpp
上传用户:trjx11
上传日期:2021-03-01
资源大小:158k
文件大小:7k
源码类别:

工具条

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "ExToolBar.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMainFrame
  13. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  14. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  15. //{{AFX_MSG_MAP(CMainFrame)
  16. ON_WM_CREATE()
  17. ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew)
  18. ON_COMMAND(ID_SHOWTEXT, OnShowtext)
  19. ON_UPDATE_COMMAND_UI(ID_SHOWTEXT, OnUpdateShowtext)
  20. ON_COMMAND(ID_ICONMODE, OnIconmode)
  21. ON_UPDATE_COMMAND_UI(ID_ICONMODE, OnUpdateIconmode)
  22. ON_WM_PAINT()
  23. ON_WM_SETTINGCHANGE()
  24. ON_WM_SYSCOLORCHANGE()
  25. ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  26. ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  27. ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  28. //ON_COMMAND(ID_APP, OnApp)
  29. ON_COMMAND(ID_FILETYPE, OnFiletype)
  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. }
  45. CMainFrame::~CMainFrame()
  46. {
  47. }
  48. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  49. {
  50. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  51. return -1;
  52. if (!m_stdToolBar.Create(this) ||
  53. !m_stdToolBar.LoadToolBar(IDR_MAINFRAME))
  54. {
  55. TRACE0("Failed to create toolbarn");
  56. return -1;      // fail to create
  57. }
  58.     m_stdToolBar.SetBitmap( IBD_SM,         COOBmpToolBar::SmallHot,         RGB( 30, 179, 223 ) );
  59.     m_stdToolBar.SetBitmap( IDB_SM_BW,      COOBmpToolBar::SmallStandard,   RGB( 30, 179, 223 ) );
  60.     m_stdToolBar.SetBitmap( IDB_SM_DB,      COOBmpToolBar::SmallDisable,     RGB( 172, 172, 172 ) );
  61.     m_stdToolBar.SetBitmap( IDB_LG,         COOBmpToolBar::LargeHot,         RGB( 33, 231, 222 ) );
  62.     m_stdToolBar.SetBitmap( IDB_LG_BW,      COOBmpToolBar::LargeStandard,   RGB( 33, 231, 222 ) );
  63.     m_stdToolBar.SetBitmap( IDB_LG_DB,      COOBmpToolBar::LargeDisable,     RGB( 170, 170, 170 ) );
  64.     m_stdToolBar.SetBitmap( IDB_SM_16,      COOBmpToolBar::SmallHot,         RGB( 0, 255, 255 ), false );
  65.     m_stdToolBar.SetBitmap( IDB_SM_BW_16,   COOBmpToolBar::SmallStandard,   RGB( 0, 255, 255 ), false );
  66.     m_stdToolBar.SetBitmap( IDB_SM_DB_16,   COOBmpToolBar::SmallDisable,     RGB( 192, 192, 192 ), false );
  67.     m_stdToolBar.SetBitmap( IDB_LG_16,      COOBmpToolBar::LargeHot,         RGB( 0, 255, 255 ), false );
  68.     m_stdToolBar.SetBitmap( IDB_LG_BW_16,   COOBmpToolBar::LargeStandard,   RGB( 0, 255, 255 ), false );
  69.     m_stdToolBar.SetBitmap( IDB_LG_DB_16,   COOBmpToolBar::LargeDisable,     RGB( 192, 192, 192 ), false );
  70.     m_stdToolBar.InitImageList();
  71.     // set button to dropdown list
  72.     m_stdToolBar.SetButtonDropDown( ID_FILE_OPEN );
  73.     m_stdToolBar.SetButtonDropDown( ID_FILE_SAVE );
  74.     
  75.     if (!m_wndStatusBar.Create(this) ||
  76. !m_wndStatusBar.SetIndicators(indicators,
  77.   sizeof(indicators)/sizeof(UINT)))
  78. {
  79. TRACE0("Failed to create status barn");
  80. return -1;      // fail to create
  81. }
  82. if (!m_IconToolBar.Create(this) ||
  83. !m_IconToolBar.LoadToolBar(IDR_ICONTOOLBAR))
  84. {
  85. TRACE0("Failed to create toolbarn");
  86. return -1;      // fail to create
  87. }
  88.     m_IconToolBar.SetIcon( IDR_MAINFRAME  );
  89.     m_IconToolBar.SetIcon( IDR_EXTOOLTYPE );
  90.     m_IconToolBar.InitImageList();
  91. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  92. m_stdToolBar.SetBarStyle(m_stdToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  93. m_IconToolBar.SetBarStyle(m_stdToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  94. // TODO: Delete these three lines if you don't want the toolbar to
  95. //  be dockable
  96. m_stdToolBar.EnableDocking(CBRS_ALIGN_ANY);
  97. m_IconToolBar.EnableDocking(CBRS_ALIGN_ANY);
  98. EnableDocking(CBRS_ALIGN_ANY);
  99. DockControlBar(&m_stdToolBar);
  100. DockControlBar(&m_IconToolBar);
  101. return 0;
  102. }
  103. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  104. {
  105. // TODO: Modify the Window class or styles here by modifying
  106. //  the CREATESTRUCT cs
  107. return CMDIFrameWnd::PreCreateWindow(cs);
  108. }
  109. /////////////////////////////////////////////////////////////////////////////
  110. // CMainFrame diagnostics
  111. #ifdef _DEBUG
  112. void CMainFrame::AssertValid() const
  113. {
  114. CMDIFrameWnd::AssertValid();
  115. }
  116. void CMainFrame::Dump(CDumpContext& dc) const
  117. {
  118. CMDIFrameWnd::Dump(dc);
  119. }
  120. #endif //_DEBUG
  121. /////////////////////////////////////////////////////////////////////////////
  122. // CMainFrame message handlers
  123. void CMainFrame::OnUpdateFileNew(CCmdUI* pCmdUI) 
  124. {
  125. // TODO: Add your command update UI handler code here
  126.     //pCmdUI->SetCheck( TRUE );
  127. }
  128. void CMainFrame::OnShowtext() 
  129. {
  130. // TODO: Add your command handler code here
  131. m_stdToolBar.SetTextMode( !m_stdToolBar.GetTextMode() );
  132. m_IconToolBar.SetTextMode( m_stdToolBar.GetTextMode() );
  133. }
  134. void CMainFrame::OnUpdateShowtext(CCmdUI* pCmdUI) 
  135. {
  136. // TODO: Add your command update UI handler code here
  137.     pCmdUI->SetCheck( m_stdToolBar.GetTextMode() );
  138. }
  139. void CMainFrame::OnIconmode() 
  140. {
  141.     m_stdToolBar.SetIconMode( !m_stdToolBar.GetIconMode() );
  142.     m_IconToolBar.SetIconMode( m_stdToolBar.GetIconMode() );
  143. }
  144. void CMainFrame::OnUpdateIconmode(CCmdUI* pCmdUI) 
  145. {
  146. // TODO: Add your command update UI handler code here
  147.     pCmdUI->SetCheck( m_stdToolBar.GetIconMode() );
  148. }
  149. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
  150. {
  151. // TODO: Add your message handler code here
  152.     
  153. // Do not call CMDIFrameWnd::OnPaint() for painting messages
  154. return CMDIFrameWnd::OnCreateClient(lpcs, pContext);
  155. }
  156. void CMainFrame::OnPaint() 
  157. {
  158. CPaintDC dc(this); // device context for painting
  159. // TODO: Add your message handler code here
  160.     
  161. // Do not call CMDIFrameWnd::OnPaint() for painting messages
  162. }
  163. void CMainFrame::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) 
  164. {
  165. CMDIFrameWnd::OnSettingChange(uFlags, lpszSection);
  166. // TODO: Add your message handler code here
  167. }
  168. void CMainFrame::OnSysColorChange() 
  169. {
  170. CMDIFrameWnd::OnSysColorChange();
  171. // TODO: Add your message handler code here
  172. }
  173. void CMainFrame::OnEditCopy() 
  174. {
  175. // TODO: Add your command handler code here
  176. }
  177. void CMainFrame::OnEditCut() 
  178. {
  179. // TODO: Add your command handler code here
  180. }
  181. void CMainFrame::OnEditPaste() 
  182. {
  183. // TODO: Add your command handler code here
  184. }
  185. void CMainFrame::OnApp() 
  186. {
  187. // TODO: Add your command handler code here
  188. }
  189. void CMainFrame::OnFiletype() 
  190. {
  191. // TODO: Add your command handler code here
  192. }