📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "MagicScissors.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)
ON_COMMAND_EX(CG_ID_VIEW_MYDIALOGBAR, OnBarCheck)
ON_UPDATE_COMMAND_UI(CG_ID_VIEW_MYDIALOGBAR, OnUpdateControlBarMenu)
ON_COMMAND_EX(CG_ID_VIEW_VIDEOCONTROLBAR, OnBarCheck)
ON_UPDATE_COMMAND_UI(CG_ID_VIEW_VIDEOCONTROLBAR, OnUpdateControlBarMenu)
ON_COMMAND_EX(CG_ID_VIEW_OPTIONBAR, OnBarCheck)
ON_UPDATE_COMMAND_UI(CG_ID_VIEW_OPTIONBAR, OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_VIEW_VIDEO_TOOL, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_VIEW_VIDEO_TOOL, OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_VIEW_SEG_TOOL, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_VIEW_SEG_TOOL, OnUpdateControlBarMenu)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_FILEOPEN, OnFileopen)
//}}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.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 toolbar\n");
return -1; // fail to create
}
if (!m_wndVideoTool.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0, 0, 0, 0),ID_VIEW_VIDEO_TOOL) ||
!m_wndVideoTool.LoadToolBar(IDR_VIDEO_TOOL))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndSegTool.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0, 0, 0, 0),ID_VIEW_SEG_TOOL) ||
!m_wndSegTool.LoadToolBar(IDR_SEG_TOOL))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
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: Delete these three lines if you don't want the toolbar to
// be dockable
CImageList MainBarImageList; // 皋牢 Toolbar ImageList
CImageList MainBarDisImgList; // 皋牢 Toolbar Disabled ImageList
CBitmap MainBarBitmap; // 皋牢 Toolbar Image
CBitmap MainBarDisBitmap; // 皋牢 Toolbar Disabled Image
// 皋牢 Toolbar 汲沥
MainBarBitmap.LoadBitmap(IDB_MAIN0);
MainBarDisBitmap.LoadBitmap(IDB_MAIN1);
MainBarImageList.Create( 25, 25, ILC_MASK | ILC_COLORDDB, 3, 0);
MainBarDisImgList.Create( 25, 25, ILC_MASK | ILC_COLORDDB, 3, 0);
MainBarImageList.Add(&MainBarBitmap, RGB(255,255,0));
MainBarDisImgList.Add(&MainBarDisBitmap, RGB(255,255,0));
m_wndToolBar.GetToolBarCtrl().SetImageList(&MainBarImageList);
m_wndToolBar.GetToolBarCtrl().SetDisabledImageList(&MainBarDisImgList);
MainBarImageList.Detach();
MainBarBitmap.Detach();
MainBarDisImgList.Detach();
MainBarDisBitmap.Detach();
CImageList VideoBarImageList; // 皋牢 Toolbar ImageList
CImageList VideoBarDisImgList; // 皋牢 Toolbar Disabled ImageList
CBitmap VideoBarBitmap; // 皋牢 Toolbar Image
CBitmap VideoBarDisBitmap; // 皋牢 Toolbar Disabled Image
// 皋牢 Video Tool 汲沥
VideoBarBitmap.LoadBitmap(IDB_VIDEO0);
VideoBarDisBitmap.LoadBitmap(IDB_VIDEO1);
VideoBarImageList.Create( 25, 25, ILC_MASK | ILC_COLORDDB, 11, 0);
VideoBarDisImgList.Create( 25, 25, ILC_MASK | ILC_COLORDDB, 11, 0);
VideoBarImageList.Add(&VideoBarBitmap, RGB(255,255,0));
VideoBarDisImgList.Add(&VideoBarDisBitmap, RGB(255,255,0));
m_wndVideoTool.GetToolBarCtrl().SetImageList(&VideoBarImageList);
m_wndVideoTool.GetToolBarCtrl().SetDisabledImageList(&VideoBarDisImgList);
VideoBarImageList.Detach();
VideoBarBitmap.Detach();
VideoBarDisImgList.Detach();
VideoBarDisBitmap.Detach();
CImageList SegBarImageList;
CImageList SegBarDisImgList;
CBitmap SegBarBitmap;
CBitmap SegBarDisBitmap;
// 皋牢 Segment Tool 汲沥
SegBarBitmap.LoadBitmap(IDB_SEG0);
SegBarDisBitmap.LoadBitmap(IDB_SEG1);
SegBarImageList.Create( 25, 25, ILC_MASK | ILC_COLORDDB, 7, 0);
SegBarDisImgList.Create( 25, 25, ILC_MASK | ILC_COLORDDB, 7, 0);
SegBarImageList.Add(&SegBarBitmap, RGB(255,255,0));
SegBarDisImgList.Add(&SegBarDisBitmap, RGB(255,255,0));
m_wndSegTool.GetToolBarCtrl().SetImageList(&SegBarImageList);
m_wndSegTool.GetToolBarCtrl().SetDisabledImageList(&SegBarDisImgList);
SegBarImageList.Detach();
SegBarBitmap.Detach();
SegBarDisImgList.Detach();
SegBarDisBitmap.Detach();
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndVideoTool.EnableDocking(CBRS_ALIGN_ANY);
m_wndSegTool.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
DockControlBarLeftOf( &m_wndVideoTool, &m_wndToolBar );
DockControlBarLeftOf( &m_wndSegTool, &m_wndVideoTool );
// TODO: Add a menu item that will toggle the visibility of the // dialog bar named "VideoControlBar": // 1. In ResourceView, open the menu resource that is used by // the CMainFrame class // 2. Select the View submenu // 3. Double-click on the blank item at the bottom of the submenu // 4. Assign the new item an ID: CG_ID_VIEW_VIDEOCONTROLBAR // 5. Assign the item a Caption: VideoControlBar // TODO: Change the value of CG_ID_VIEW_VIDEOCONTROLBAR to an appropriate value: // 1. Open the file resource.h // CG: The following block was inserted by the 'Dialog Bar' component { // Initialize dialog bar m_wndVideoControlBar if (!m_wndVideoControlBar.Create(this, CG_IDD_VIDEOCONTROLBAR, CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE, CG_ID_VIEW_VIDEOCONTROLBAR)) { TRACE0("Failed to create dialog bar m_wndVideoControlBar\n"); return -1; // fail to create }
m_wndVideoControlBar.Init(0,0, NULL);
m_wndVideoControlBar.EnableSlider(FALSE); }
// TODO: Add a menu item that will toggle the visibility of the // dialog bar named "My Dialog Bar": // 1. In ResourceView, open the menu resource that is used by // the CMainFrame class // 2. Select the View submenu // 3. Double-click on the blank item at the bottom of the submenu // 4. Assign the new item an ID: CG_ID_VIEW_MYDIALOGBAR // 5. Assign the item a Caption: My Dialog Bar // TODO: Change the value of CG_ID_VIEW_MYDIALOGBAR to an appropriate value: // 1. Open the file resource.h // CG: The following block was inserted by the 'Dialog Bar' component { // Initialize dialog bar m_wndOptionBar if (!m_wndOptionBar.Create(this, CG_IDD_MYDIALOGBAR, CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE, CG_ID_VIEW_MYDIALOGBAR)) { TRACE0("Failed to create dialog bar m_wndOptionBar\n"); return -1; // fail to create } m_wndOptionBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndOptionBar);
DockControlBarLeftOf( (CToolBar*)&m_wndOptionBar, &m_wndSegTool );
CSpinButtonCtrl* pSpin = (CSpinButtonCtrl*)m_wndOptionBar.GetDlgItem(IDC_SPIN1);
pSpin->SetRange( 3, 20 );
pSpin = (CSpinButtonCtrl*)m_wndOptionBar.GetDlgItem(IDC_SPIN2);
pSpin->SetRange( 2, 10 );
pSpin = (CSpinButtonCtrl*)m_wndOptionBar.GetDlgItem(IDC_SPIN3);
pSpin->SetRange( 1, 4 );
m_wndOptionBar.m_nSearchWidth = 10;
m_wndOptionBar.m_nSmoothTab = 5;
m_wndOptionBar.m_nEdge = 2;
m_wndOptionBar.UpdateData(FALSE); }
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
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
void CMainFrame::DockControlBarLeftOf(CToolBar * desBar, CToolBar * srcBar)
{
CRect rect;
DWORD dw;
UINT n;
RecalcLayout();
srcBar->GetWindowRect( &rect );
rect.OffsetRect( 1, 0 );
dw = srcBar->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;
DockControlBar( desBar, n, &rect );
}
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if(CMDIFrameWnd::OnCreateClient(lpcs, pContext))
{
m_wndClient.SubclassWindow(m_hWndMDIClient);
return TRUE;
}
else return FALSE;
}
void CMainFrame::OnFileopen()
{
// TODO: Add your command handler code here
CFileDialog dlg(true);
if(dlg.DoModal() == IDOK)
{
// CImage image;
// image.LoadImage(dlg.GetFileName());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -