www.pudn.com > drawpad.zip > MainFrm.cpp
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "DrawPad.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{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 (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndToolBar.SetWindowText("DrawPad 1.0版 画图工具栏" );
m_wndToolBar.SetButtonText(0,"新建" );
m_wndToolBar.SetButtonText(1,"打开");
m_wndToolBar.SetButtonText(2,"保存");
m_wndToolBar.SetButtonText(4,"直线");
m_wndToolBar.SetButtonText(5,"椭圆");
m_wndToolBar.SetButtonText(6,"矩形框");
m_wndToolBar.SetButtonText(7,"圆");
m_wndToolBar.SetButtonText(8,"文字");
m_wndToolBar.SetButtonText(9,"实椭圆");
m_wndToolBar.SetButtonText(10,"实圆");
m_wndToolBar.SetButtonText(11,"矩形");
m_wndToolBar.SetButtonText(13,"恢复");
m_wndToolBar.SetButtonText(14,"重做");
m_wndToolBar.SetButtonText(16,"选取");
m_wndToolBar.SetButtonText(17,"类型");
m_wndToolBar.SetSizes(CSize(48,40),CSize(22,18));
if (!m_wndClToolBar.Create(this) ||
!m_wndClToolBar.LoadToolBar(IDR_CL_TOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndClToolBar.SetWindowText("DrawPad 1.0版 颜色工具栏" );
m_wndClToolBar.SetButtonText(0,"淡红色" );
m_wndClToolBar.SetButtonText(1,"淡绿色");
m_wndClToolBar.SetButtonText(2,"淡蓝色");
m_wndClToolBar.SetButtonText(3,"淡黄色");
m_wndClToolBar.SetButtonText(4,"自选色");
m_wndClToolBar.SetButtonText(6,"单线宽");
m_wndClToolBar.SetButtonText(7,"双线宽");
m_wndClToolBar.SetButtonText(8,"三线宽");
m_wndClToolBar.SetSizes(CSize(40,32),CSize(20,15));
if (!m_wndStToolBar.Create(this) ||
!m_wndStToolBar.LoadToolBar(IDR_ST_TOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndStToolBar.SetWindowText("DrawPad 1.0版 模式工具栏" );
m_wndStToolBar.SetButtonText(0,"实线");
m_wndStToolBar.SetButtonText(1,"点线");
m_wndStToolBar.SetButtonText(2,"虚线");
m_wndStToolBar.SetButtonText(3,"点划线");
m_wndStToolBar.SetButtonText(4,"双点线");
m_wndStToolBar.SetButtonText(6,"模式1");
m_wndStToolBar.SetButtonText(7,"模式2");
m_wndStToolBar.SetButtonText(8,"模式3");
m_wndStToolBar.SetButtonText(9,"模式4");
m_wndStToolBar.SetButtonText(10,"模式5");
m_wndStToolBar.SetButtonText(11,"模式6");
m_wndStToolBar.SetButtonText(12,"模式7");
m_wndStToolBar.SetSizes(CSize(40,32),CSize(20,15));
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndClToolBar.SetBarStyle(m_wndClToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC|CBRS_ALIGN_LEFT);
m_wndStToolBar.SetBarStyle(m_wndStToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC|CBRS_ALIGN_LEFT);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
m_wndStToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndStToolBar,AFX_IDW_DOCKBAR_LEFT);
m_wndClToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndClToolBar,AFX_IDW_DOCKBAR_LEFT);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CMDIFrameWnd::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers