www.pudn.com > vcframe.rar > DlgPipei.cpp
// DlgPipei.cpp : implementation file
//
#include "stdafx.h"
#include "match.h"
#include "DlgPipei.h"
#include "dibapi.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgPipei dialog
CDlgPipei::CDlgPipei(CWnd* pParent /*=NULL*/)
: CDialog(CDlgPipei::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgPipei)
m_strRightImage = _T("");
m_strLeftImage = _T("");
//}}AFX_DATA_INIT
}
void CDlgPipei::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgPipei)
DDX_Text(pDX, IDC_EDIT1, m_strRightImage);
DDX_Text(pDX, IDC_EDIT2, m_strLeftImage);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgPipei, CDialog)
//{{AFX_MSG_MAP(CDlgPipei)
ON_BN_CLICKED(IDC_RIGHT, OnRight)
ON_BN_CLICKED(IDC_LEFT, OnLeft)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgPipei message handlers
BOOL CDlgPipei::OnInitDialog()
{
CDialog::OnInitDialog();
hDibL=NULL;
hDibR=NULL;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgPipei::OnRight()
{
CFileDialog m_dlg(TRUE,"*.bmp",NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"位图(*.bmp)|*.bmp|所有文件(*.*)|*.*||",this);
if(m_dlg.DoModal()==IDCANCEL) return;
m_strRightImage=m_dlg.GetPathName();
UpdateData(0);
CFile file;
CFileException fe;
file.Open(m_strRightImage, CFile::modeRead | CFile::shareDenyWrite, &fe);
hDibR = ::ReadDIBFile(file);
pWndR=GetDlgItem(IDC_STATICRIGHT);
Paint(hDibR,pWndR);
/* if(pWndL!=NULL)
{
Paint(hDibL,pWndL);
} */
}
void CDlgPipei::OnLeft()
{
CFileDialog m_dlg(TRUE,"*.bmp",NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"位图(*.bmp)|*.bmp|所有文件(*.*)|*.*||",this);
if(m_dlg.DoModal()==IDCANCEL) return;
m_strLeftImage=m_dlg.GetPathName();
UpdateData(0);
CFile file;
CFileException fe;
file.Open(m_strLeftImage, CFile::modeRead | CFile::shareDenyWrite, &fe);
hDibL = ::ReadDIBFile(file);
pWndR=GetDlgItem(IDC_STATICLEFT);
Paint(hDibL,pWndR);
/* if(pWndL!=NULL)
{
Paint(hDibR,pWndL);
}*/
}
void CDlgPipei::Paint(HDIB hDIB,CWnd* pWnd)
{
if (hDIB==NULL)
return;
LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
CDC* pDC=pWnd->GetDC();
// pWnd->Invalidate();
// pWnd->UpdateWindow();
pWnd->GetClientRect(&rcDest);
CRect rcDIB;
rcDIB.top = rcDIB.left = 0;
rcDIB.right = ::DIBWidth(lpDIB);
rcDIB.bottom =::DIBHeight(lpDIB);
::GlobalUnlock((HGLOBAL) hDIB);
::PaintDIB(pDC->m_hDC,&rcDest,hDIB,&rcDIB,NULL);
}