📄 mainfrm.cpp
字号:
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
// SaveBarState(_T("yyhh"));
CFrameWnd::OnClose();
}
void CMainFrame::DockControlBarLeftOf(CToolBar* Bar,CToolBar* LeftOf)
{
CRect rect;
DWORD dw;
UINT n;
// get MFC to adjust the dimensions of all docked ToolBars
// so that GetWindowRect will be accurate
RecalcLayout();
LeftOf->GetWindowRect(&rect);
rect.OffsetRect(1,0);
dw=LeftOf->GetBarStyle();
n = 0;
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;
// When we take the default parameters on rect, DockControlBar will dock
// each Toolbar on a seperate line. By calculating a rectangle, we in effect
// are simulating a Toolbar being dragged to that location and docked.
DockControlBar(Bar,n,&rect);
}
BOOL CMainFrame::CreateDrawToolBar()
{
/* //绘图工具条初始化(老版本)
if (!m_wndShapeBar.Create(this,
WS_CHILD | WS_VISIBLE | CBRS_TOP, ID_VIEW_DRAWTOOLS) ||
!m_wndShapeBar.LoadToolBar(IDR_DRAWTOOLS))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
*/
//绘图工具条初始化(新版本动态按钮)
////////////////////////////yhyhyh
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_DRAWTOOLS))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndDrawToolBar.SetWindowText(_T("常用绘图工具"));
ShowControlBar( &m_wndDrawToolBar, TRUE, FALSE );
m_wndDrawToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBarLeftOf(&m_wndDrawToolBar,&m_wndPathLineToolBar);
return TRUE;
}
//创建工具条
BOOL CMainFrame::CreatePathLineToolBar()
{
if (!m_wndPathLineToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndPathLineToolBar.LoadToolBar(IDR_LINEPATHTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndPathLineToolBar.SetWindowText(_T("直线"));
ShowControlBar( &m_wndPathLineToolBar, TRUE, FALSE );
m_wndPathLineToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
// FloatControlBar(&m_wndLineToolBar, CPoint(500,300));
// DockControlBar(&m_wndLineToolBar,AFX_IDW_DOCKBAR_RIGHT);
DockControlBarLeftOf(&m_wndPathLineToolBar,&m_wndPathArcToolBar);
return TRUE;
}
BOOL CMainFrame::CreatePathArcToolBar()
{
if (!m_wndPathArcToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndPathArcToolBar.LoadToolBar(IDR_ARCPATHTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndPathArcToolBar.SetWindowText(_T("圆弧"));
ShowControlBar( &m_wndPathArcToolBar, TRUE, FALSE );
m_wndPathArcToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
// FloatControlBar(&m_wndArcToolBar, CPoint(500,300));
DockControlBar(&m_wndPathArcToolBar);//,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreatePathLazysToolBar()
{
if (!m_wndPathLazysToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndPathLazysToolBar.LoadToolBar(IDR_LAZYSPATHTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndPathLazysToolBar.SetWindowText(_T("懒-S"));
ShowControlBar( &m_wndPathLazysToolBar, FALSE, FALSE );
m_wndPathLazysToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndPathLazysToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreatePathSideToolBar()
{
if (!m_wndPathSideToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndPathSideToolBar.LoadToolBar(IDR_SIDEPATHTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndPathSideToolBar.SetWindowText(_T("硬侧移"));
ShowControlBar( &m_wndPathSideToolBar,FALSE, FALSE );
m_wndPathSideToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndPathSideToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreatePathScpToolBar()
{
if (!m_wndPathScpToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndPathScpToolBar.LoadToolBar(IDR_SCPPATHTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndPathScpToolBar.SetWindowText(_T("软侧移"));
ShowControlBar( &m_wndPathScpToolBar, FALSE, FALSE );
m_wndPathScpToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndPathScpToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
/*
BOOL CMainFrame::CreateDrawToolBar()//绘图工具条
{
return TRUE;
}
*/
BOOL CMainFrame::CreateBuildingLineToolBar()
{
if (!m_wndBuildingLineToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingLineToolBar.LoadToolBar(IDR_LINEBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingLineToolBar.SetWindowText(_T("直线"));
ShowControlBar( &m_wndBuildingLineToolBar, FALSE, FALSE );
m_wndBuildingLineToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingLineToolBar, CPoint(500,300));
return TRUE;
}
BOOL CMainFrame::CreateBuildingArcToolBar()
{
if (!m_wndBuildingArcToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingArcToolBar.LoadToolBar(IDR_ARCBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingArcToolBar.SetWindowText(_T("圆弧"));
ShowControlBar( &m_wndBuildingArcToolBar, FALSE, FALSE );
m_wndBuildingArcToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingArcToolBar, CPoint(500,300));
return TRUE;
}
BOOL CMainFrame::CreateBuildingLazysToolBar()
{
if (!m_wndBuildingLazysToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingLazysToolBar.LoadToolBar(IDR_LAZYSBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingLazysToolBar.SetWindowText(_T("懒-S"));
ShowControlBar( &m_wndBuildingLazysToolBar, FALSE, FALSE );
m_wndBuildingLazysToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingLazysToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreateBuildingEllipseToolBar()
{
if (!m_wndBuildingEllipseToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingEllipseToolBar.LoadToolBar(IDR_ELLIPSEBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingEllipseToolBar.SetWindowText(_T("椭圆"));
ShowControlBar( &m_wndBuildingEllipseToolBar, FALSE, FALSE );
m_wndBuildingEllipseToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingEllipseToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreateBuildingRectToolBar()
{
if (!m_wndBuildingRectToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingRectToolBar.LoadToolBar(IDR_RECTBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingRectToolBar.SetWindowText(_T("矩形"));
ShowControlBar( &m_wndBuildingRectToolBar, FALSE, FALSE );
m_wndBuildingRectToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingRectToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreateBuildingPolygonToolBar()
{
if (!m_wndBuildingPolygonToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingPolygonToolBar.LoadToolBar(IDR_POLYGONBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingPolygonToolBar.SetWindowText(_T("多边形"));
ShowControlBar( &m_wndBuildingPolygonToolBar, FALSE, FALSE );
m_wndBuildingPolygonToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingPolygonToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreateBuildingRoundrectToolBar()
{
if (!m_wndBuildingRoundrectToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingRoundrectToolBar.LoadToolBar(IDR_ROUNDRECTBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingRoundrectToolBar.SetWindowText(_T("圆角矩形"));
ShowControlBar( &m_wndBuildingRoundrectToolBar, FALSE, FALSE );
m_wndBuildingRoundrectToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingRoundrectToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreateBuildingChordToolBar()
{
if (!m_wndBuildingChordToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingChordToolBar.LoadToolBar(IDR_CHORDBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingChordToolBar.SetWindowText(_T("弦"));
ShowControlBar( &m_wndBuildingChordToolBar, FALSE, FALSE );
m_wndBuildingChordToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingChordToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreateBuildingPieToolBar()
{
if (!m_wndBuildingPieToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndBuildingPieToolBar.LoadToolBar(IDR_PIEBUILDINGTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndBuildingPieToolBar.SetWindowText(_T("扇形"));
ShowControlBar( &m_wndBuildingPieToolBar, FALSE, FALSE );
m_wndBuildingPieToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndBuildingPieToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreateDeviceLineToolBar()
{
if (!m_wndDeviceLineToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndDeviceLineToolBar.LoadToolBar(IDR_LINEDEVICETOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndDeviceLineToolBar.SetWindowText(_T("直线"));
ShowControlBar( &m_wndDeviceLineToolBar, FALSE, FALSE );
m_wndDeviceLineToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndDeviceLineToolBar, CPoint(500,300));
return TRUE;
}
BOOL CMainFrame::CreateDeviceArcToolBar()
{
if (!m_wndDeviceArcToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndDeviceArcToolBar.LoadToolBar(IDR_ARCDEVICETOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndDeviceArcToolBar.SetWindowText(_T("圆弧"));
ShowControlBar( &m_wndDeviceArcToolBar, FALSE, FALSE );
m_wndDeviceArcToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndDeviceArcToolBar, CPoint(500,300));
return TRUE;
}
BOOL CMainFrame::CreateDeviceLazysToolBar()
{
if (!m_wndDeviceLazysToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndDeviceLazysToolBar.LoadToolBar(IDR_LAZYSDEVICETOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndDeviceLazysToolBar.SetWindowText(_T("懒-S"));
ShowControlBar( &m_wndDeviceLazysToolBar, FALSE, FALSE );
m_wndDeviceLazysToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndDeviceLazysToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
return TRUE;
}
BOOL CMainFrame::CreateDeviceEllipseToolBar()
{
if (!m_wndDeviceEllipseToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndDeviceEllipseToolBar.LoadToolBar(IDR_ELLIPSEDEVICETOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndDeviceEllipseToolBar.SetWindowText(_T("椭圆"));
ShowControlBar( &m_wndDeviceEllipseToolBar, FALSE, FALSE );
m_wndDeviceEllipseToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
FloatControlBar(&m_wndDeviceEllipseToolBar, CPoint(500,300));
// DockControlBar(&m_wndArcToolBar,AFX_IDW_DOCKBAR_RIGHT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -