资源简介
MFC截图程序(完整).7z
代码片段和文件信息
// CoverDlg.cpp : implementation file
//
#include “stdafx.h“
#include “CutScreen.h“
#include “CoverDlg.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//
// 定义全局变量和全局函数
//
POINT startPoint; // 画矩形的左上角坐标
POINT endPoint; // 画矩形的右下角坐标
bool IsLBtnUp; // 鼠标左键是否弹起
bool IsRBtnUp; // 鼠标右键是否弹起
bool IsLBtnDown; // 鼠标左键是否按下
#define WH_MOUSE_LL 14
HHOOK hhookMs = NULL;
LRESULT CALLBACK LowLevelMouseProc (INT nCode WPARAM wParam LPARAM lParam);
BOOL UninstallKbHook();
BOOL InstallKbHook();
DWORD clickInterval = 0;
/////////////////////////////////////////////////////////////////////////////
// CCoverDlg dialog
CCoverDlg::CCoverDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCoverDlg::IDD pParent)
{
//{{AFX_DATA_INIT(CCoverDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CCoverDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCoverDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCoverDlg CDialog)
//{{AFX_MSG_MAP(CCoverDlg)
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCoverDlg message handlers
BOOL CCoverDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// 变量初始化
IsLBtnUp = false;
IsLBtnDown = false;
IsRBtnUp = false;
ShowWindow(SW_MAXIMIZE); // 窗口最大化
SetWindowPos(&wndTopMost0000 SWP_NOMOVE | SWP_NOSIZE); // 窗口置顶
// 设置窗体透明
COLORREF maskColor = GetSysColor(COLOR_3DFACE); // 获取窗体颜色
SetWindowLong(GetSafeHwnd()GWL_EXstyleGetWindowLong(GetSafeHwnd()GWL_EXstyle)|0x00080000);
HINSTANCE hInst = LoadLibrary(_T(“User32.dll“));
if (hInst)
{
typedef BOOL (WINAPI *MyFun)(HWNDCOLORREFBYTEDWORD);
MyFun myfun = NULL;
myfun = (MyFun)GetProcAddress(hInst “SetlayeredWindowAttributes“);
if (myfun) myfun(GetSafeHwnd()maskColor1001); // 100是透明度(范围0-255)
FreeLibrary(hInst);
}
// 设置计时器
SetTimer(1 100 NULL);
// 启动钩子
InstallKbHook();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCoverDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//绘制背景
CRect rect;
GetClientRect(&rect);
CBrush bruDB(GetSysColor(COLOR_3DFACE));//背景颜色
dc.FillRect(&rect &bruDB);
//绘制拖动矩形
if (IsLBtnDown)
{
CPen pen(PS_SOLID3RGB(2342353));
CPen *pOldPen=dc.Selectobject(&pen);
CBrush *pBrush=CBrush::FromHandle((HBRUSH)
GetStockobject(NULL_BRUSH));
CBrush *pOldBrush=dc.Selectobject(pBrush);
d
- 上一篇:SQL+C++学生信息管理系统
- 下一篇:MFC透明Edit
评论
共有 条评论