⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 本上机平台专门为《计算机辅助设计技术基础》课程中的vC语言编程和交互技术与用户接口实验部分设计。
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "Cg50.h"
#include "Cg50Doc.h"
#include "MainFrm.h"
#include "Cg50View.h"
#include "Dib.h"
#include "Cgdraw.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern BOOL bLoad=false;
extern CString name="";
CDIB dib;
BOOL m_bFullScreen=FALSE;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_FILE_NEW, OnFileNew)
	ON_WM_CLOSE()
	ON_COMMAND(ID_EXPORT, OnExport)
	ON_COMMAND(ID_LOAD, OnLoad)
	ON_COMMAND(ID_FULL, OnFull)
	ON_WM_GETMINMAXINFO()
	//}}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

	glhwnd = glp = NULL;
	
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{ AfxOleInit();
	if (CFrameWnd::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
	}

	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);

	// 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);
	
	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFrameWnd::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// 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::OnShowgl() 
{
	// TODO: Add your command handler code here
	glhwnd = ::FindWindowEx(GetActiveView()->GetSafeHwnd(),NULL,NULL, "Light.exe");
	if (glhwnd) return;
	::WinExec("Light.exe",SW_SHOWMINIMIZED);
	Sleep(2000);
	glhwnd = ::FindWindow(NULL ,"Light.exe");
	glp = ::GetParent(glhwnd);
	::SetParent(glhwnd, GetActiveView()->GetSafeHwnd());

}
*/

void CMainFrame::OnFileNew() 
{

}

void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
    CCgDraw cd;
	cd.deletepen();
	CFrameWnd::OnClose();
}

void CMainFrame::OnExport() 
{
CWnd *child=GetWindow(GW_CHILD);
dib.CaptureDIB(child);
CFileDialog cfd(false,"BMP",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"BMP files (*.bmp)|*.bmp||");
cfd.m_ofn.lpstrTitle="Export to BMP";
if (cfd.DoModal()==IDOK)
{
dib.SaveBmp((LPCSTR)cfd.GetFileName());
MessageBox("Export completely!");
}
else
MessageBox("No Export!");
dib.Show(child);
}



void CMainFrame::OnLoad() 
{dib.CaptureDIB(GetWindow(GW_CHILD));
extern bool after;
after=1;
CFileDialog cfd(true,"BMP",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"BMP files (*.bmp)|*.bmp|Jpeg files (*.jpg)|*.jpg|Gif files(*.gif)|*.gif||");
cfd.m_ofn.lpstrTitle="Load from Image";
if (cfd.DoModal()==IDOK)
{  
bLoad=true;name=cfd.GetFileName();
InvalidateRect(0,0);
}
}

void CMainFrame::OnFull() 
{extern bool after;
	if (m_bFullScreen==FALSE){
      m_bFullScreen=TRUE;
	  dib.CaptureDIB(GetWindow(GW_CHILD));
	  after=1;
	  ShowWindow(SW_SHOWMAXIMIZED);
	}
    else
	{
     m_bFullScreen=FALSE;
	 dib.CaptureDIB(GetWindow(GW_CHILD));
	 after=1;
	 ShowWindow(SW_RESTORE);
	}
}

void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{
  if(m_bFullScreen)
               {
                  CRect rc;
                  rc.SetRect(0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
                  AdjustWindowRectEx(&rc,GetStyle(),GetMenu()!=NULL,GetExStyle());
                   
                   

                  lpMMI->ptMaxSize.x=lpMMI->ptMaxTrackSize.x=lpMMI->ptMinTrackSize.x=rc.Width();
                  lpMMI->ptMaxSize.y=lpMMI->ptMaxTrackSize.y=lpMMI->ptMinTrackSize.y=rc.Height();
                  lpMMI->ptMaxPosition.x=rc.left;
                  lpMMI->ptMaxPosition.y=rc.top;

               }
               else
                CFrameWnd::OnGetMinMaxInfo(lpMMI);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -