資源簡介
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
//
//?定義全局變量和全局函數(shù)
//
POINT?startPoint;??//?畫矩形的左上角坐標(biāo)
POINT?endPoint;????//?畫矩形的右下角坐標(biāo)
bool?IsLBtnUp;?????//?鼠標(biāo)左鍵是否彈起
bool?IsRBtnUp;?????//?鼠標(biāo)右鍵是否彈起
bool?IsLBtnDown;???//?鼠標(biāo)左鍵是否按下
#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);?//?窗口置頂
//?設(shè)置窗體透明
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);??
????}??
//?設(shè)置計時器
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++學(xué)生信息管理系統(tǒng)
- 下一篇:MFC透明Edit
評論
共有 條評論