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

📄 modalwinview.cpp

📁 VC++ 编程宝典,电子工业出版社,源代码,第三部分
💻 CPP
字号:
// ModalWinView.cpp : implementation of the CModalWinView class
//

#include "stdafx.h"
#include "ModalWin.h"

#include "ModalWinDoc.h"
#include "ModalWinView.h"
#include "ModalArea.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define CHILD_WND_ID 89
/////////////////////////////////////////////////////////////////////////////
// CModalWinView

IMPLEMENT_DYNCREATE(CModalWinView, CView)

BEGIN_MESSAGE_MAP(CModalWinView, CView)
	//{{AFX_MSG_MAP(CModalWinView)
	ON_COMMAND(ID_VIEW_GO_MODAL, OnViewGoModal)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CModalWinView construction/destruction

CModalWinView::CModalWinView()
{
	// TODO: add construction code here

}

CModalWinView::~CModalWinView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CModalWinView drawing

void CModalWinView::OnDraw(CDC* pDC)
{
	CModalWinDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CModalWinView printing

BOOL CModalWinView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CModalWinView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CModalWinView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CModalWinView diagnostics

#ifdef _DEBUG
void CModalWinView::AssertValid() const
{
	CView::AssertValid();
}

void CModalWinView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CModalWinDoc* CModalWinView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CModalWinDoc)));
	return (CModalWinDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CModalWinView message handlers

void CModalWinView::OnViewGoModal() 
{

	// TODO: Add your command handler code here
	CRect rectDeskTop;
	CWnd * pWndDeskTop;	// Pointer to desktop

	pWndDeskTop = GetDesktopWindow();
	pWndDeskTop->GetWindowRect(&rectDeskTop);
	
	// Add a pointer to use for the modal window
	ModalArea * pSampleModalWindow;

	// Instantiate the frame window object
	pSampleModalWindow = new ModalArea();

	// Create the window
	pSampleModalWindow->Create(NULL,
    		NULL,
            WS_BORDER,
			CFrameWnd::rectDefault,                         
			pWndDeskTop,
			CHILD_WND_ID);	//defined above

		// Turn the parent window off
   ::EnableWindow( AfxGetApp()->m_pMainWnd->m_hWnd, FALSE );

   // Position the modal window on the screen
   pSampleModalWindow->SetWindowPos( &wndTopMost, 		  
		-1, -1, 
		rectDeskTop.Width()+1, 
		rectDeskTop.Height()+1, 
		SWP_SHOWWINDOW);

   // Get a pointer to the application window
	pSampleModalWindow->SetpAppWnd((CFrameWnd *)AfxGetApp()->m_pMainWnd);

   // Start the modal loop
   pSampleModalWindow->RunModalLoop( MLF_SHOWONIDLE );

   // destroy the frame
   pSampleModalWindow->DestroyWindow();

}

⌨️ 快捷键说明

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