?? dlgaftreg.cpp
字號(hào):
// DlgAftReg.cpp : implementation file
//
#include "stdafx.h"
#include "ImageProcessing.h"
#include "DlgAftReg.h"
#include "CDib.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgAftReg dialog
CDlgAftReg::CDlgAftReg(CWnd* pParent /*=NULL*/, CDib* pDibShow)
: CDialog(CDlgAftReg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgAftReg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pDib = pDibShow;
m_bCalImgLoc = FALSE;
}
void CDlgAftReg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgAftReg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgAftReg, CDialog)
//{{AFX_MSG_MAP(CDlgAftReg)
ON_WM_PAINT()
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgAftReg message handlers
void CDlgAftReg::OnPaint()
{
CPaintDC dc(this);
if(!m_bCalImgLoc)
CalImgLocation();
CSize sizeDisplay;
CPoint pointDisplay;
if(m_pDib != NULL){
if(!m_pDib->IsEmpty()){
sizeDisplay.cx=m_pDib->m_lpBMIH->biWidth;
sizeDisplay.cy=m_pDib->m_lpBMIH->biHeight;
pointDisplay.x = m_rectImage.left;
pointDisplay.y = m_rectImage.top;
m_pDib->Draw(&dc,pointDisplay,sizeDisplay);
}
}
}
/*************************************************************************
*
* \函數(shù)名稱(chēng):
* CalImageLocation()
*
* \輸入?yún)?shù):
* 無(wú)
*
* \返回值:
* 無(wú)
*
* \說(shuō)明:
* 該函數(shù)設(shè)置對(duì)話框中的控件位置和大小,并設(shè)置顯示圖象的位置。默認(rèn)的圖象大小為352×288,如果圖象小于
*此大小,則控件大小設(shè)置為352×288,并將圖象放置在控件中間。
*
*************************************************************************
*/
void CDlgAftReg::CalImgLocation()
{
// 獲得控件IDC_DlgAftReg_IMAGE的句柄,并獲得控件的初始位置信息
CWnd* pWnd=GetDlgItem(IDC_AFTREG_IMAGE);
WINDOWPLACEMENT *winPlacement;
winPlacement=new WINDOWPLACEMENT;
pWnd->GetWindowPlacement(winPlacement);
// 圖象寬度
int nImageWidth = 0;
// 圖象高度
int nImageHeight = 0;
if(m_pDib != NULL){
nImageWidth = m_pDib->m_lpBMIH->biWidth;
nImageHeight = m_pDib->m_lpBMIH->biHeight;
}
// 調(diào)整控件IDC_REG_INIT_IMAGE的大小位置,并同時(shí)設(shè)置顯示基準(zhǔn)圖象的位置
if(nImageHeight > 352){
winPlacement->rcNormalPosition.bottom = winPlacement->rcNormalPosition.top + nImageHeight;
m_rectImage.bottom = winPlacement->rcNormalPosition.bottom;
m_rectImage.top = winPlacement->rcNormalPosition.top;
}
else{
winPlacement->rcNormalPosition.bottom = winPlacement->rcNormalPosition.top + 352;
m_rectImage.bottom = winPlacement->rcNormalPosition.top + 176 + nImageHeight/2;
m_rectImage.top = winPlacement->rcNormalPosition.top + 176 - nImageHeight/2;
}
if(nImageWidth > 288){
winPlacement->rcNormalPosition.right = winPlacement->rcNormalPosition.left + nImageWidth;
m_rectImage.right = winPlacement->rcNormalPosition.right;
m_rectImage.left = winPlacement->rcNormalPosition.left;
}
else{
winPlacement->rcNormalPosition.right = winPlacement->rcNormalPosition.left + 288;
m_rectImage.right = winPlacement->rcNormalPosition.left + 144 + nImageWidth/2;
m_rectImage.left = winPlacement->rcNormalPosition.left + 144 - nImageWidth/2;
}
// 設(shè)置IDC_DlgAftReg_IMAGE控件的大小位置
pWnd->SetWindowPlacement(winPlacement);
// 獲得IDC_DlgAftReg_IMAGE控件的下邊位置,以便調(diào)整其他控件的位置
int nIniImgBottom, nIniImgRight,nIniImgLeft;
nIniImgBottom = winPlacement->rcNormalPosition.bottom;
nIniImgLeft = winPlacement->rcNormalPosition.left;
nIniImgRight = winPlacement->rcNormalPosition.right;
// 設(shè)置控件IDOK的位置大小
pWnd=GetDlgItem(IDOK);
pWnd->GetWindowPlacement(winPlacement);
winPlacement->rcNormalPosition.top = nIniImgBottom +15;
winPlacement->rcNormalPosition.bottom = nIniImgBottom + 60;
pWnd->SetWindowPlacement(winPlacement);
// 設(shè)置控件IDCANCEL的位置大小
pWnd=GetDlgItem(IDCANCEL);
pWnd->GetWindowPlacement(winPlacement);
winPlacement->rcNormalPosition.top = nIniImgBottom +15;
winPlacement->rcNormalPosition.bottom = nIniImgBottom + 60;
pWnd->SetWindowPlacement(winPlacement);
this->GetWindowPlacement(winPlacement);
winPlacement->rcNormalPosition.bottom = nIniImgBottom + 60+ 70;
winPlacement->rcNormalPosition.left = nIniImgLeft - 20;
winPlacement->rcNormalPosition.right = nIniImgRight + 20;
this->SetWindowPlacement(winPlacement);
m_bCalImgLoc = TRUE;
// 釋放已分配內(nèi)存
delete winPlacement;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -