MainFrm.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "EastDraw.h"
  5. #include "MainFrm.h"
  6. #include "Splash.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CMainFrame
  14. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  15. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  16. //{{AFX_MSG_MAP(CMainFrame)
  17. ON_WM_CREATE()
  18. ON_COMMAND(Menu_ShowPorDlg, OnShowPorDlg)
  19. ON_UPDATE_COMMAND_UI(Menu_ShowPorDlg, OnUpdateShowPorDlg)
  20. ON_COMMAND(ID_ShowDrawTool_Bar, OnShowDrawToolBar)
  21. ON_UPDATE_COMMAND_UI(ID_ShowDrawTool_Bar, OnUpdateShowDrawToolBar)
  22. ON_WM_TIMER()
  23. //}}AFX_MSG_MAP
  24. ON_UPDATE_COMMAND_UI(ID_MousPoint,OnUpdateMousPoint)
  25. ON_UPDATE_COMMAND_UI(ID_MousCaption,OnUpdateMousCaption)
  26. END_MESSAGE_MAP()
  27. static UINT indicators[] =
  28. {
  29. ID_SEPARATOR, // status line indicator
  30. ID_MousCaption,
  31. ID_MousPoint,
  32. ID_SEPARATOR,
  33. ID_INDICATOR_CAPS,
  34. ID_INDICATOR_NUM,
  35. ID_INDICATOR_SCRL,
  36. };
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CMainFrame construction/destruction
  39. CMainFrame::CMainFrame()
  40. {
  41. // TODO: add member initialization code here
  42. }
  43. CMainFrame::~CMainFrame()
  44. {
  45. }
  46. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  47. { // CG: The following line was added by the Splash Screen component.
  48. CSplashWnd::ShowSplashScreen(this);
  49. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  50. return -1;
  51. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  52. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  53. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  54. {
  55. TRACE0("Failed to create toolbar\n");
  56. return -1; // fail to create
  57. }
  58. if (!m_wndStatusBar.Create(this) ||
  59. !m_wndStatusBar.SetIndicators(indicators,
  60. sizeof(indicators)/sizeof(UINT)))
  61. {
  62. TRACE0("Failed to create status bar\n");
  63. return -1; // fail to create
  64. }
  65. // TODO: Delete these three lines if you don't want the toolbar to
  66. // be dockable
  67. if (!m_wndDrawToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_LEFT
  68. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  69. !m_wndDrawToolBar.LoadToolBar(IDR_TOOLBAR1_DrawTool))
  70. {
  71. TRACE0("Failed to create toolbar\n");
  72. return -1; // fail to create
  73. }
  74. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  75. EnableDocking(CBRS_ALIGN_ANY);
  76. DockControlBar(&m_wndToolBar);
  77. m_wndDrawToolBar.EnableDocking(CBRS_ALIGN_ANY);
  78. DockControlBar(&m_wndDrawToolBar);
  79. //m_DLineProperty->MoveWindow(500,500,340,240);
  80. if (!m_wndStyleBar.Create (this, WS_CHILD| CBRS_ALIGN_TOP|
  81. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, IDW_STYLE_BAR))
  82. return FALSE;
  83. m_wndStyleBar.SetWindowText (_T ("文字工具条"));
  84. m_wndStyleBar.EnableDocking (CBRS_ALIGN_ANY);
  85. DockControlBar (&m_wndStyleBar);
  86. FloatControlBar(&m_wndStyleBar,CPoint(300,10));
  87. m_DLineProperty=new CDLineProperty(_T("图元属性页"));
  88. m_DLineProperty->Create(this,WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME,WS_EX_TOOLWINDOW);
  89. SetTimer(1, 1000, NULL);
  90. return 0;
  91. }
  92. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  93. {
  94. cs.cy = ::GetSystemMetrics(SM_CYSCREEN);
  95. cs.cx = ::GetSystemMetrics(SM_CXSCREEN);
  96. cs.y = ::GetSystemMetrics(SM_CYSCREEN);
  97. cs.x = -::GetSystemMetrics(SM_CYSCREEN);
  98. if( !CMDIFrameWnd::PreCreateWindow(cs) )
  99. return FALSE;
  100. // TODO: Modify the Window class or styles here by modifying
  101. // the CREATESTRUCT cs
  102. return TRUE;
  103. }
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CMainFrame diagnostics
  106. #ifdef _DEBUG
  107. void CMainFrame::AssertValid() const
  108. {
  109. CMDIFrameWnd::AssertValid();
  110. }
  111. void CMainFrame::Dump(CDumpContext& dc) const
  112. {
  113. CMDIFrameWnd::Dump(dc);
  114. }
  115. #endif //_DEBUG
  116. /////////////////////////////////////////////////////////////////////////////
  117. // CMainFrame message handlers
  118. void CMainFrame::OnShowPorDlg()
  119. {
  120. // TODO: Add your command handler code here
  121. if(m_DLineProperty)
  122. m_DLineProperty->ShowWindow(!m_DLineProperty->IsWindowVisible());
  123. }
  124. void CMainFrame::OnUpdateShowPorDlg(CCmdUI* pCmdUI)
  125. {
  126. // TODO: Add your command update UI handler code here
  127. if(m_DLineProperty)
  128. pCmdUI->SetCheck(m_DLineProperty->IsWindowVisible());
  129. }
  130. void CMainFrame::ShowFontBar(BOOL isShow)
  131. {
  132. if((!(!isShow&&!m_wndStyleBar.IsWindowVisible()))&&!(isShow&&m_wndStyleBar.IsWindowVisible()))
  133. OnBarCheck(IDW_STYLE_BAR);
  134. }
  135. void CMainFrame::OnUpdateMousPoint(CCmdUI* pCmdUI)
  136. {
  137. pCmdUI->Enable();
  138. }
  139. void CMainFrame::OnUpdateMousCaption(CCmdUI* pCmdUI)
  140. {
  141. pCmdUI->Enable();
  142. }
  143. void CMainFrame::SetMousePosText(CPoint Logpoint,CPoint Devpoint)
  144. {
  145. CString strText;
  146. strText.Format("逻辑坐标:(%d,%d)",Logpoint.x,-Logpoint.y);
  147. int nIndex=m_wndStatusBar.CommandToIndex(ID_MousPoint);
  148. m_wndStatusBar.SetPaneText(nIndex,strText);
  149. CWindowDC dc(&m_wndStatusBar);
  150. CSize sizeText=dc.GetTextExtent(strText);
  151. m_wndStatusBar.SetPaneInfo(nIndex,ID_MousPoint,SBPS_NORMAL,sizeText.cx);
  152. strText.Format("屏幕坐标:(%d,%d)",Devpoint.x,Devpoint.y);
  153. nIndex=m_wndStatusBar.CommandToIndex(ID_MousCaption);
  154. m_wndStatusBar.SetPaneText(nIndex,strText);
  155. sizeText=dc.GetTextExtent(strText);
  156. m_wndStatusBar.SetPaneInfo(nIndex,ID_MousCaption,SBPS_NORMAL,sizeText.cx);
  157. }
  158. void CMainFrame::OnShowDrawToolBar()
  159. {
  160. // TODO: Add your command handler code here
  161. ShowControlBar(&m_wndDrawToolBar,!m_wndDrawToolBar.IsWindowVisible(),false);
  162. }
  163. void CMainFrame::OnUpdateShowDrawToolBar(CCmdUI* pCmdUI)
  164. {
  165. // TODO: Add your command update UI handler code here
  166. pCmdUI->SetCheck(m_wndDrawToolBar.IsWindowVisible()?1:0);
  167. }
  168. void CMainFrame::OnTimer(UINT nIDEvent)
  169. {
  170. // TODO: Add your message handler code here and/or call default
  171. static BOOL bShow=false;
  172. if(!bShow)
  173. {
  174. int cscy = ::GetSystemMetrics(SM_CYSCREEN) / 4*3;
  175. int cscx = ::GetSystemMetrics(SM_CXSCREEN) / 4*3;
  176. int csy = cscy/6;
  177. int csx = cscx/6;
  178. CRect rect;
  179. this->MoveWindow(csx,csy,cscx,cscy);
  180. this->ShowWindow(SW_SHOWMAXIMIZED);
  181. this->m_DLineProperty->GetWindowRect(&rect);
  182. this->m_DLineProperty->MoveWindow(cscx*4/3-rect.Width(),0,rect.Width(),rect.Height());
  183. this->m_DLineProperty->ShowWindow(SW_SHOW);
  184. }
  185. bShow=true;
  186. CMDIFrameWnd::OnTimer(nIDEvent);
  187. }
  188. void CMainFrame::AddTempFile()
  189. {
  190. }