www.pudn.com > vcframe.rar > DlgZoom.cpp
// DlgZoom.cpp : implementation file
//
#include "stdafx.h"
#include "match.h"
#include "DlgZoom.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgZoom dialog
CDlgZoom::CDlgZoom(CWnd* pParent /*=NULL*/)
: CDialog(CDlgZoom::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgZoom)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDlgZoom::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgZoom)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgZoom, CDialog)
//{{AFX_MSG_MAP(CDlgZoom)
ON_BN_CLICKED(IDOK, OnOk)
ON_BN_CLICKED(IDCANCEL, OnCancle)
ON_WM_LBUTTONDOWN()
ON_WM_PAINT()
ON_WM_SETCURSOR()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgZoom message handlers
BOOL CDlgZoom::OnInitDialog()
{
CDialog::OnInitDialog();
m_bIsUseSelectCursor=FALSE;
// TODO: Add extra initialization here
// pWnd->Invalidate();
// pWnd->UpdateWindow();
hSelectPoint=AfxGetApp()->LoadCursor(IDC_SELECT);
CWnd* pWnd=GetDlgItem(IDC_STATICL1);
pWnd->GetWindowRect(&m_ClientRect);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgZoom::OnOk()
{
CDialog::OnOK();
}
void CDlgZoom::OnCancle()
{
CDialog::OnCancel();
}
void CDlgZoom::OnLButtonDown(UINT nFlags, CPoint point)
{
// paint();
CDialog::OnLButtonDown(nFlags, point);
}
void CDlgZoom::paint()
{
if (hdib==NULL)
return;
LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) hdib);
CWnd* pWnd=GetDlgItem(IDC_STATICL1);
CDC* pDC=pWnd->GetDC();
// pWnd->Invalidate();
// pWnd->UpdateWindow();
CRect rcDest;
pWnd->GetClientRect(&rcDest);
CRect rcDIB;
rcDIB.top = m_CursorPoint.y-rcDest.Height()/6;
rcDIB.left = m_CursorPoint.x-rcDest.Width()/6;
rcDIB.right = m_CursorPoint.x+rcDest.Width()/6;
rcDIB.bottom =m_CursorPoint.y+rcDest.Height()/6;
// rcDest.bottom*=2;
// rcDest.right*=2;
::GlobalUnlock((HGLOBAL) hdib);
::PaintDIB(pDC->m_hDC,&rcDest,hdib,&rcDIB,NULL);
}
void CDlgZoom::OnPaint()
{
CPaintDC dc(this); // device context for painting
paint();
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
BOOL CDlgZoom::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if(pWnd==this&&nHitTest == HTCLIENT&&m_bIsUseSelectCursor)
{
SetCursor(hSelectPoint);
return FALSE;
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}
void CDlgZoom::OnMouseMove(UINT nFlags, CPoint point)
{
CWnd* pWnd=GetDlgItem(IDC_STATICL1);
CRect rect;
pWnd->GetClientRect(&rect);
pWnd->ClientToScreen(&rect);
ClientToScreen(&point);
if(rect.PtInRect(point))
m_bIsUseSelectCursor=TRUE;
else
m_bIsUseSelectCursor=FALSE;
CDialog::OnMouseMove(nFlags, point);
}