MainFrm.cpp
上传用户:z_mail1980
上传日期:2007-06-01
资源大小:647k
文件大小:3k
源码类别:

SNMP编程

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "practise2.h"
  5. #include "ModeDialog.h"
  6. #include "ModeDialog2.h"
  7. #include "MainFrm.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMainFrame
  15. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  16. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  17. //{{AFX_MSG_MAP(CMainFrame)
  18. ON_WM_CREATE()
  19. ON_COMMAND(ID_MODE_DIALOG, OnModeDialog)
  20. ON_COMMAND(ID_MODE_DIALOG2, OnModeDialog2)
  21. ON_COMMAND(ID_MODE_DIALOG3, OnModeDialog3)
  22. ON_COMMAND(ID_MODE_DIALOG4, OnModeDialog4)
  23. //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25. static UINT indicators[] =
  26. {
  27. ID_SEPARATOR,           // status line indicator
  28. ID_INDICATOR_CAPS,
  29. ID_INDICATOR_NUM,
  30. ID_INDICATOR_SCRL,
  31. };
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CMainFrame construction/destruction
  34. CMainFrame::CMainFrame()
  35. {
  36. // TODO: add member initialization code here
  37. }
  38. CMainFrame::~CMainFrame()
  39. {
  40. }
  41. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  42. {
  43. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  44. return -1;
  45. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  46. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  47. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  48. {
  49. TRACE0("Failed to create toolbarn");
  50. return -1;      // fail to create
  51. }
  52. if (!m_wndStatusBar.Create(this) ||
  53. !m_wndStatusBar.SetIndicators(indicators,
  54.   sizeof(indicators)/sizeof(UINT)))
  55. {
  56. TRACE0("Failed to create status barn");
  57. return -1;      // fail to create
  58. }
  59. // TODO: Delete these three lines if you don't want the toolbar to
  60. //  be dockable
  61. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  62. EnableDocking(CBRS_ALIGN_ANY);
  63. DockControlBar(&m_wndToolBar);
  64. return 0;
  65. }
  66. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  67. {
  68. if( !CFrameWnd::PreCreateWindow(cs) )
  69. return FALSE;
  70. // TODO: Modify the Window class or styles here by modifying
  71. //  the CREATESTRUCT cs
  72. return TRUE;
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CMainFrame diagnostics
  76. #ifdef _DEBUG
  77. void CMainFrame::AssertValid() const
  78. {
  79. CFrameWnd::AssertValid();
  80. }
  81. void CMainFrame::Dump(CDumpContext& dc) const
  82. {
  83. CFrameWnd::Dump(dc);
  84. }
  85. #endif //_DEBUG
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CMainFrame message handlers
  88. void CMainFrame::OnModeDialog() 
  89. {
  90. // TODO: Add your command handler code here
  91. CModeDialog ModeDlg;//(RGB(255,0,0),CC_FULLOPEN,this);
  92. if(ModeDlg.DoModal()==IDOK)
  93. {
  94. COLORREF Color=ModeDlg.GetColor();
  95. }
  96. }
  97. void CMainFrame::OnModeDialog2() 
  98. {
  99. // TODO: Add your command handler code here
  100. CModeDialog2 ModeDlg2;
  101. ModeDlg2.DoModal();
  102. }
  103. void CMainFrame::OnModeDialog3() 
  104. {
  105. // TODO: Add your command handler code here
  106. CColorDialog ColorDialog(RGB(255,0,0),CC_FULLOPEN,this);
  107. if((ColorDialog.DoModal())==IDOK){
  108. COLORREF Color=ColorDialog.GetColor();
  109. }
  110. }
  111. void CMainFrame::OnModeDialog4() 
  112. {
  113. LOGFONT lf;
  114. lf.lfHeight=15;
  115. lf.lfWidth=20;
  116. CFontDialog dlg;
  117. dlg.m_cf.lpLogFont=&lf;
  118. dlg.m_cf.rgbColors=RGB(255,0,0);
  119. dlg.m_cf.Flags |=CF_INITTOLOGFONTSTRUCT;
  120. if(dlg.DoModal()==IDOK){
  121. dlg.GetCurrentFont(&lf);
  122. //m_cTextColor=dlg.GetColor();
  123. }
  124. }