www.pudn.com > BitmapExample.rar > ShowDibDlg.cpp


// ShowDibDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "BitmapExample.h" 
#include "ShowDibDlg.h" 
#include "Dib.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CShowDibDlg dialog 
extern CString dibpath; 
extern int dibwidth; 
extern int dibheight; 
 
 
CShowDibDlg::CShowDibDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CShowDibDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CShowDibDlg) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CShowDibDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CShowDibDlg) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CShowDibDlg, CDialog) 
	//{{AFX_MSG_MAP(CShowDibDlg) 
	ON_WM_PAINT() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CShowDibDlg message handlers 
 
//DEL void CShowDibDlg::OnShowWindow(BOOL bShow, UINT nStatus)  
//DEL { 
//DEL 	CDialog::OnShowWindow(bShow, nStatus); 
//DEL 	 
//DEL 	// TODO: Add your message handler code here 
//DEL 	 
//DEL } 
 
void CShowDibDlg::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	 
	// TODO: Add your message handler code here 
	CDC *pDc=this->GetDC(); 
	 
	//加载位图并显示之 
	CDib dib; 
 
	if (dib.Load(dibpath)) 
		{ 
			dib.SetPalette(pDc); 
			dib.Draw(pDc); 
		 
			MoveWindow(0,0,dibwidth+GetSystemMetrics(SM_CXSIZEFRAME), 
				GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYSIZEFRAME)+dibheight,TRUE); 
 
		} 
	 
	// Do not call CDialog::OnPaint() for painting messages 
} 
 
BOOL CShowDibDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	Invalidate(); 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
//DEL BOOL CShowDibDlg::PreCreateWindow(CREATESTRUCT& cs)  
//DEL { 
//DEL 	// TODO: Add your specialized code here and/or call the base class 
//DEL 	if( !CShowDibDlg::PreCreateWindow(cs) ) 
//DEL 		return FALSE; 
//DEL 	cs.style = WS_OVERLAPPEDWINDOW   ; 
//DEL 	cs.cx=nWidth; 
//DEL 	cs.cy=nHeight; 
//DEL  
//DEL  
//DEL 	return CDialog::PreCreateWindow(cs); 
//DEL }