MainFrm.cpp
资源名称:DrawSys.zip [点击查看]
上传用户:mosfetic
上传日期:2022-06-16
资源大小:4612k
文件大小:4k
源码类别:
GDI/图象编程
开发平台:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "DrawSys.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code !
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndDrawToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndDrawToolBar.LoadToolBar(IDR_TOOLBAR_DRAW))
- {
- TRACE0("Failed to create Draw toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndDrawToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- DockControlBar(&m_wndDrawToolBar);
- DockControlBarLeftOf(&m_wndDrawToolBar, &m_wndToolBar);
- if(!m_wndLeftBar.Create(this, IDD_DIALOGBAR_LEFT, CBRS_LEFT|CBRS_TOOLTIPS, IDD_DIALOGBAR_LEFT))
- {
- TRACE0("Failed to create left barn");
- return -1; // fail to create
- }
- if(!m_wndShapeTree.CreateEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
- WS_VISIBLE|WS_CHILD|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS|TVS_DISABLEDRAGDROP|TVS_SHOWSELALWAYS,
- CRect(0, 0, 0, 0), &m_wndLeftBar, ID_SHAPETREE_IN_LEFTBAR))
- {
- TRACE0("Failed to create treen");
- return -1; // fail to create
- }
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::DockControlBarLeftOf(CToolBar* leftBar, CToolBar* rightBar)
- {
- // 设置工具条并列停靠在同一条边上
- CRect rect; // 矩形区域定义
- DWORD dw;
- UINT n = 0;
- RecalcLayout(); //重新显示
- rightBar->GetWindowRect(&rect);
- rect.OffsetRect(1, 0);
- dw=rightBar->GetBarStyle();
- n=(dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
- n=(dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
- n=(dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
- n=(dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
- DockControlBar(leftBar, n, &rect);
- }