📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "RSImageStar.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
CBrowseBar CMainFrame::m_wndBrowseBar;
CLayerDlg CMainFrame::m_wndMyDialogBar;
CPaintParambar CMainFrame::m_wndPaintParamBar;
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_COMMAND_EX(ID_WINDOW_PENTYPECOLOR, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_WINDOW_PENTYPECOLOR, OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_WINDOW_LAYER, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_WINDOW_LAYER, OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_VIEW_NAVIGATION, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_VIEW_NAVIGATION, OnUpdateControlBarMenu)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_RSTOOLBAR, OnViewRstoolbar)
ON_UPDATE_COMMAND_UI(ID_VIEW_RSTOOLBAR, OnUpdateViewRstoolbar)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
static UINT BASED_CODE palette[] =
{
// same order as in the bitmap 'palette.bmp'
ID_PALETTESELECT,
ID_PALETTEMOVE,
ID_PALETTEPEN,
ID_PALETTEERASE,
ID_PALETTECURVE,
ID_PALETTESPRAY,
ID_PALETTEPAINT,
ID_PALETTELINE,
ID_PALETTEEYEDROP,
ID_IMAGEIN,
ID_IMAGEOUT,
ID_IMAGEBROWSE,
ID_PALETTERECTANGLE,
ID_PALETTEROUND,
ID_PALETTEOVAL,
ID_PALETTETEXT
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
flagbrowse=true;
}
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.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER | CBRS_BORDER_3D );
ShowControlBar(&m_wndToolBar, true, FALSE);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
if (!m_wndPaletteBar.Create(this) ||!m_wndPaletteBar.LoadToolBar(IDR_TOOLBAR1))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndPaletteBar.SetBarStyle(m_wndPaletteBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_GRIPPER | CBRS_BORDER_3D );
ShowControlBar(&m_wndPaletteBar, true, FALSE);
m_wndPaletteBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndPaletteBar);
//*********************************
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
}
CRect rFrame1;
GetWindowRect(rFrame1);
int x1 = rFrame1.right - 400;
int y1 = rFrame1.top + 90;
// CG: The following block was inserted by the 'Dialog Bar' component
{
// Initialize dialog bar m_wndMyDialogBar
if (!m_wndMyDialogBar.Create(this, CG_IDD_IMAGELAYER,
CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,
ID_WINDOW_LAYER))
{
TRACE0("Failed to create dialog bar m_wndMyDialogBar\n");
return -1; // fail to create
}
ShowControlBar(&m_wndMyDialogBar, false, FALSE);
m_wndMyDialogBar.SetWindowText("图层");
m_wndMyDialogBar.EnableDocking(0);
x1 = rFrame1.right - 420;
y1 = rFrame1.top + 200;
FloatControlBar(&m_wndMyDialogBar, CPoint(x1, y1), CBRS_ALIGN_TOP);
}
//*********************************
{
m_wndBrowseBar.Create(this, IDD_BROWSEBAR, CBRS_LEFT, ID_VIEW_NAVIGATION);
ShowControlBar(&m_wndBrowseBar, false, FALSE);
m_wndBrowseBar.SetWindowText("缩略图");
m_wndBrowseBar.EnableDocking(0);
x1 = rFrame1.right - 280;
y1 = rFrame1.top + 80;
FloatControlBar(&m_wndBrowseBar, CPoint(x1, y1), CBRS_ALIGN_TOP);
}
//********************************************
{
if (!m_wndPaintParamBar.Create(this, IDD_PAINTPARAM,
CBRS_RIGHT|CBRS_FLYBY,ID_WINDOW_PENTYPECOLOR))
{
TRACE0("Failed to create dialogbar m_wndPaintParamBar\n");
return -1; // fail to create
}
ShowControlBar(&m_wndPaintParamBar, false, FALSE);
m_wndPaintParamBar.SetWindowText(_T("设置盒"));
m_wndPaintParamBar.EnableDocking(0);
x1 = rFrame1.right - 280;
y1 = rFrame1.top + 80;
FloatControlBar(&m_wndPaintParamBar, CPoint(x1, y1), CBRS_ALIGN_TOP);
}
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.x=cs.y=0;
cs.cx=GetSystemMetrics(SM_CXSCREEN);
cs.cy=GetSystemMetrics(SM_CYSCREEN);
if( !CMDIFrameWnd::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
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::CreatePaletteBar()
{
if (!m_wndPaletteBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_FIXED |
CBRS_TOP | CBRS_TOOLTIPS|CBRS_FLYBY, ID_VIEW_RSTOOLBAR) ||
!m_wndPaletteBar.LoadToolBar(IDR_TOOLBAR1) ||
!m_wndPaletteBar.SetButtons(palette,
sizeof(palette)/sizeof(UINT)))
{
TRACE0("Failed to create toolbar\n");
return FALSE; // fail to create
}
// m_wndPaletteBar.SetWindowText(_T("编辑栏"));
m_wndPaletteBar.EnableDocking(0);
// Create the Palette. We are using hardcoded numbers for ease here
// normally the location would be read in from an ini file.
CPoint pt(GetSystemMetrics(SM_CXSCREEN) - 100,
GetSystemMetrics(SM_CYSCREEN) / 3);
m_wndPaletteBar.SetColumns(2);
FloatControlBar(&m_wndPaletteBar, pt);
return TRUE;
}
void CMainFrame::OnViewRstoolbar()
{
// TODO: Add your command handler code here
BOOL bVisible = ((m_wndPaletteBar.GetStyle() & WS_VISIBLE) != 0);
ShowControlBar(&m_wndPaletteBar, !bVisible, FALSE);
RecalcLayout();
}
void CMainFrame::OnUpdateViewRstoolbar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
BOOL bVisible = ((m_wndPaletteBar.GetStyle() & WS_VISIBLE) != 0);
pCmdUI->SetCheck(bVisible);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -