【VC开源代码栏目提醒】:网学会员,鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“CapDlg.cpp”一文,供大家参考学习!
// CapDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MyCap.h"
#include "CapDlg.h"
// CCapDlg dialog
IMPLEMENT_DYNAMIC(CCapDlg, CDialog)
CCapDlg::CCapDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCapDlg::IDD, pParent)
{
}
CCapDlg::~CCapDlg()
{
}
void CCapDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CCapDlg, CDialog)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_PAINT()
END_MESSAGE_MAP()
// CCapDlg message handlers
BOOL CCapDlg::OnInitDialog()
{
CDialog::OnInitDialog();
HDC hdc=::GetDC(NULL);
int cx=GetSystemMetrics(SM_CXSCREEN);
int cy=GetSystemMetrics(SM_CYSCREEN);
m_hScreenDC=CreateCompatibleDC(hdc);
HBITMAP hbmp=CreateCompatibleBitmap(hdc,cx,cy);
SelectObject(m_hScreenDC,hbmp);
BitBlt(m_hScreenDC,0,0,cx,cy,hdc,0,0,SRCCOPY);
::ReleaseDC(NULL,hdc);
::SetWindowPos(m_hWnd,NULL,0,0,cx,cy,
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCapDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptBegin = m_ptEnd = point;
if(m_nCapFlag == 2)
{
m_bDown = true;
m_rcSel.left = m_rcSel.right = m_ptBegin.x;
m_rcSel.top = m_rcSel.bottom = m_ptBegin.y;
}
CDialog::OnLButtonDown(nFlags, point);
}
void CCapDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_nCapFlag == 3)//全屏
{
int cx=GetSystemMetrics(SM_CXSCREEN);
int cy=GetSystemMetrics(SM_CYSCREEN);
CRect rect(0,0,cx,cy);
m_pdib->CaptureDIB(this,rect);
}
if(m_nCapFlag == 2)//区域
{
m_pdib->CaptureDIB(this,m_rcSel);
}
m_bDown = false;
EndDialog(IDOK);
CDialog::OnLButtonUp(nFlags, point);
}
void CCapDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_nCapFlag == 2 && nFlags == MK_LBUTTON)
{
HDC hdc = ::GetDC(m_hWnd);
DrawFocusRect(hdc,&m_rcSel);
m_ptEnd = point;
m_rcSel.left = min(m_ptBegin.x,m_ptEnd.x);
m_rcSel.top = min(m_ptBegin.y,m_ptEnd.y);
m_rcSel.right = max(m_ptBegin.x,m_ptEnd.x);
m_rcSel.bottom = max(m_ptBegin.y,m_ptEnd.y);
DrawFocusRect(hdc,&m_rcSel);
::ReleaseDC(m_hWnd,hdc);
}
CDialog::OnMouseMove(nFlags, point);
}
void CCapDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
HDC hDC = ::GetDC(m_hWnd);
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
BitBlt(hDC,0,0,cx,cy,m_hScreenDC,0,0,SRCCOPY);
::ReleaseDC(m_hWnd,hDC);
}
上一篇:
Cap.cpp
下一篇:
白色姜花,略微开了