MainFrm.cpp
上传用户:wlkj888
上传日期:2022-08-01
资源大小:806k
文件大小:5k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "ToolBarsDemo.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. #define BTN_TEST  500
  14. #define BTN_TEST1  501
  15. #define BTN_TEST2  502
  16. #define BTN_TEST3  503
  17. #define BTN_TEST4  504
  18. #define BTN_TEST5  505
  19. #define BTN_TEST6  506
  20. #define BTN_TEST7  507
  21. #define BTN_TEST8  508
  22. #define BTN_TEST9  509
  23. #define BTN_TEST10  510
  24. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  25. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  26. //{{AFX_MSG_MAP(CMainFrame)
  27. ON_WM_CREATE()
  28. ON_COMMAND(ID_DROP, OnDrop)
  29. ON_COMMAND(ID_PANELS, OnPanels)
  30. ON_COMMAND(BTN_TEST,  OnTest)
  31. ON_COMMAND(BTN_TEST1,  OnTest)
  32. ON_COMMAND(BTN_TEST2,  OnTest)
  33. ON_COMMAND(BTN_TEST3,  OnTest)
  34. ON_COMMAND(BTN_TEST4,  OnTest)
  35. ON_COMMAND(BTN_TEST5,  OnTest)
  36. ON_COMMAND(BTN_TEST6,  OnTest)
  37. ON_COMMAND(BTN_TEST7,  OnTest)
  38. ON_COMMAND(BTN_TEST8,  OnTest)
  39. ON_COMMAND(BTN_TEST9,  OnTest)
  40. ON_COMMAND(BTN_TEST10,  OnTest)
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. static UINT indicators[] =
  44. {
  45. ID_SEPARATOR,           // status line indicator
  46. ID_INDICATOR_CAPS,
  47. ID_INDICATOR_NUM,
  48. ID_INDICATOR_SCRL,
  49. };
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CMainFrame construction/destruction
  52. CMainFrame::CMainFrame()
  53. {
  54. // TODO: add member initialization code here
  55. }
  56. CMainFrame::~CMainFrame()
  57. {
  58. }
  59. void CMainFrame::OnTest()
  60. {
  61. CString sText;
  62. static val=0;
  63. CEditView* pView = (CEditView*)((CMDIFrameWnd*)AfxGetMainWnd())->GetActiveFrame()->GetActiveView();
  64. sText.Format ("Number= %drn",val );
  65. pView->GetEditCtrl().ReplaceSel (sText);
  66. val++;
  67. }
  68. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  69. {
  70. if (CGuiMDIFrame::OnCreate(lpCreateStruct) == -1)
  71. return -1;
  72. InitMenu(IDR_MAINFRAME);
  73. InitToolBar(IDR_MAINFRAME);
  74. InitStatusBar(indicators,sizeof(indicators)/sizeof(UINT));
  75. // TODO: Delete these three lines if you don't want the toolbar to
  76. //  be dockable
  77. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  78. EnableDocking(CBRS_ALIGN_ANY);
  79. m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
  80. m_wndMenuBar.SetSaveHistory("MyHistory1",TRUE);
  81. DockControlBar(&m_wndMenuBar,m_dockTop);
  82. DockControlBar(&m_wndToolBar,m_dockTop);
  83. m_wndStatusBar.SetStyle(CGuiStatusBar::OFFICE);
  84. DockControlBar(&m_wndToolBar);
  85. sProfile = _T("GuiFlatDemo");
  86. if (!m_ctSolution.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),this,124))
  87. return -1;
  88. const DWORD dwStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS|WS_HSCROLL|WS_HSCROLL ;
  89. if (!m_tree.Create(dwStyle, CRect(0,0,100,100),&m_ctSolution, 2))
  90. return -1;
  91. m_ctSolution.AddComponen(&m_tree);
  92. HTREEITEM hRoot =m_tree.InsertItem (_T("Gui_DevStudio"), 0, 0);
  93. HTREEITEM hGlobal = m_tree.InsertItem (_T("Global Functions and Variables"), 16, 16, hRoot);
  94. m_tree.InsertItem (_T("indicators"), 18, 18, hGlobal);
  95. m_tree.InsertItem (_T("theApp"), 18, 18, hGlobal);
  96. m_tree.InsertItem (_T("THIS_FILE"), 18, 18, hGlobal);
  97. m_tree.InsertItem (_T("theApp"), 18, 18, hGlobal);
  98. m_tree.InsertItem (_T("THIS_FILE"), 18, 18, hGlobal);
  99. m_tree.InsertItem (_T("theApp"), 18, 18, hGlobal);
  100. m_tree.InsertItem (_T("THIS_FILE"), 18, 18, hGlobal);
  101. m_wndToolBar.SetButtonDropDown(ID_DROP,8,&m_ctSolution,_T("Prueba"));
  102. if (!m_panAcc.Create(WS_VISIBLE|WS_CHILD,CRect(0,0,100,100),this,1000))
  103. return -1;
  104. m_panAcc.SetColor(GuiDrawLayer::GetRGBFondoXP());
  105. m_panAcc.SetImageList(IDB_BITMAP1,16,11,RGB (255, 0, 0));
  106. m_panAcc.AddButton(BTN_TEST,0,&m_btn1,"Option 1");
  107. m_panAcc.AddButton(BTN_TEST1,1,&m_btn2,"Option 2");
  108. m_panAcc.AddButton(BTN_TEST2,2,&m_btn3,"Option 3");
  109. m_panAcc.AddButton(BTN_TEST3,3,&m_btn4,"Option 4");
  110. m_panAcc.AddButton(BTN_TEST4,4,&m_btn5,"Option 5");
  111. m_panAcc.AddButton(BTN_TEST5,5,&m_btn6,"Option 6");
  112. m_panAcc.AddButton(BTN_TEST6,6,&m_btn7,"Option 7");
  113. m_panAcc.AddButton(BTN_TEST7,7,&m_btn8,"Option 8");
  114. m_panAcc.AddButton(BTN_TEST8,0,&m_btn9,"Option 9");
  115. m_panAcc.AddButton(BTN_TEST9,4,&m_btn10,"Option 10");
  116. m_wndToolBar.SetButtonDropDown(ID_PANELS,6,&m_panAcc,_T("Prueba"));
  117. // LoadBars();
  118. return 0;
  119. }
  120. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  121. {
  122. if( !CMDIFrameWnd::PreCreateWindow(cs) )
  123. return FALSE;
  124. // TODO: Modify the Window class or styles here by modifying
  125. //  the CREATESTRUCT cs
  126. return TRUE;
  127. }
  128. /////////////////////////////////////////////////////////////////////////////
  129. // CMainFrame diagnostics
  130. #ifdef _DEBUG
  131. void CMainFrame::AssertValid() const
  132. {
  133. CMDIFrameWnd::AssertValid();
  134. }
  135. void CMainFrame::Dump(CDumpContext& dc) const
  136. {
  137. CMDIFrameWnd::Dump(dc);
  138. }
  139. #endif //_DEBUG
  140. /////////////////////////////////////////////////////////////////////////////
  141. // CMainFrame message handlers
  142. void CMainFrame::OnDrop() 
  143. {
  144. // TODO: Add your command handler code here
  145. }
  146. void CMainFrame::OnPanels() 
  147. {
  148. // TODO: Add your command handler code here
  149. }