资源简介
【核心代码】//********************************************************************************
//文件:Screenshot.CPP
//作者:feiren
//时间:2014-1-1
//用途:封装截图功能的主窗口实现
//版本:1.0.0.0
//联系:feirench@gmail.com
//********************************************************************************
#include "stdafx.h"
#include "Screenshot.h"
#include "ShotImplement.h"
extern TAppData g_Data;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
bool bClose = false;
int WINAPI ScreenshotWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("AWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
BOOL fMessage;
wndclass.style = CS_CLASSDC | CS_DBLCLKS;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_CROSS) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
g_Data.mResult = 0;
if (!RegisterClass (&wndclass))
{
return 0;
}
hwnd=CreateWindowEx(WS_EX_TOOLWINDOW,szAppName,TEXT ("The SH"),WS_POPUP|WS_VISIBLE,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
bClose = false;
PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
while(msg.message != WM_QUIT) // 消息循环
{
fMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);
if(fMessage) //有消息
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}else
{
if(bClose)break;
else Sleep(1);
}
}
UnregisterClass(szAppName,hInstance);
return g_Data.mResult ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
switch (message)
{
case WM_CREATE:
g_Data.Initialize(hwnd,GetModuleHandle(NULL));
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
//g_Data.OnPain(hdc);
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_MOUSEMOVE:
hdc = GetDC(hwnd);
g_Data.OnMouseMove(hdc,wParam,lParam);
break;
case WM_LBUTTONDBLCLK:
hdc = GetDC(hwnd);
g_Data.OnLButtonDBLClick(hdc,wParam,lParam);
break;
case WM_LBUTTONDOWN:
hdc = GetDC(hwnd);
g_Data.OnLButtonDown(hdc,wParam,lParam);
break;// 鼠标左键按键,射击用
case WM_LBUTTONUP:
hdc = GetDC(hwnd);
g_Data.OnLButtonUp(hdc,wParam,lParam);
break;// 鼠标左键松开
case WM_RBUTTONDOWN:
hdc = GetDC(hwnd);
g_Data.OnRButtonDown(hdc,wParam,lParam);
break;// 鼠标右键按键,拖动对象用
case WM_RBUTTONUP:
hdc = GetDC(hwnd);
g_Data.OnRButtonUp(hdc,wParam,lParam);
break;// 鼠标右键松开
case WM_MOUSEWHEEL:
hdc = GetDC(hwnd);
g_Data.OnMouseWheel(hdc,wParam,lParam);
break;
case WM_KEYDOWN:
hdc = GetDC(hwnd);
g_Data.OnKeyDown(hdc,wParam,lParam);
break;
case WM_KEYUP: // 按ESC退出
hdc = GetDC(hwnd);
g_Data.OnKeyUp(hdc,wParam,lParam);
break;
case WM_SETCURSOR:
g_Data.OnSetCursor();
break;
case WM_DESTROY:
g_Data.Release();
bClose = true;
//PostQuitMessage (0) ;
return 0 ;
default:
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
return 0;
}
SCREENSHOT_API int fnScreenshot(void)
{
return ScreenshotWinMain(GetModuleHandle(NULL),NULL,NULL,SW_SHOWNORMAL|SW_MAXIMIZE);
}
//文件:Screenshot.CPP
//作者:feiren
//时间:2014-1-1
//用途:封装截图功能的主窗口实现
//版本:1.0.0.0
//联系:feirench@gmail.com
//********************************************************************************
#include "stdafx.h"
#include "Screenshot.h"
#include "ShotImplement.h"
extern TAppData g_Data;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
bool bClose = false;
int WINAPI ScreenshotWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("AWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
BOOL fMessage;
wndclass.style = CS_CLASSDC | CS_DBLCLKS;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_CROSS) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
g_Data.mResult = 0;
if (!RegisterClass (&wndclass))
{
return 0;
}
hwnd=CreateWindowEx(WS_EX_TOOLWINDOW,szAppName,TEXT ("The SH"),WS_POPUP|WS_VISIBLE,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
bClose = false;
PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
while(msg.message != WM_QUIT) // 消息循环
{
fMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);
if(fMessage) //有消息
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}else
{
if(bClose)break;
else Sleep(1);
}
}
UnregisterClass(szAppName,hInstance);
return g_Data.mResult ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
switch (message)
{
case WM_CREATE:
g_Data.Initialize(hwnd,GetModuleHandle(NULL));
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
//g_Data.OnPain(hdc);
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_MOUSEMOVE:
hdc = GetDC(hwnd);
g_Data.OnMouseMove(hdc,wParam,lParam);
break;
case WM_LBUTTONDBLCLK:
hdc = GetDC(hwnd);
g_Data.OnLButtonDBLClick(hdc,wParam,lParam);
break;
case WM_LBUTTONDOWN:
hdc = GetDC(hwnd);
g_Data.OnLButtonDown(hdc,wParam,lParam);
break;// 鼠标左键按键,射击用
case WM_LBUTTONUP:
hdc = GetDC(hwnd);
g_Data.OnLButtonUp(hdc,wParam,lParam);
break;// 鼠标左键松开
case WM_RBUTTONDOWN:
hdc = GetDC(hwnd);
g_Data.OnRButtonDown(hdc,wParam,lParam);
break;// 鼠标右键按键,拖动对象用
case WM_RBUTTONUP:
hdc = GetDC(hwnd);
g_Data.OnRButtonUp(hdc,wParam,lParam);
break;// 鼠标右键松开
case WM_MOUSEWHEEL:
hdc = GetDC(hwnd);
g_Data.OnMouseWheel(hdc,wParam,lParam);
break;
case WM_KEYDOWN:
hdc = GetDC(hwnd);
g_Data.OnKeyDown(hdc,wParam,lParam);
break;
case WM_KEYUP: // 按ESC退出
hdc = GetDC(hwnd);
g_Data.OnKeyUp(hdc,wParam,lParam);
break;
case WM_SETCURSOR:
g_Data.OnSetCursor();
break;
case WM_DESTROY:
g_Data.Release();
bClose = true;
//PostQuitMessage (0) ;
return 0 ;
default:
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
return 0;
}
SCREENSHOT_API int fnScreenshot(void)
{
return ScreenshotWinMain(GetModuleHandle(NULL),NULL,NULL,SW_SHOWNORMAL|SW_MAXIMIZE);
}
代码片段和文件信息
//********************************************************************************
//文件:DesktopWindows.CPP
//作者:feiren
//时间:2014-1-1
//用途:获取桌面所有合格窗体的矩形信息
//版本:1.0.0.0
//联系:feirench@gmail.com
//********************************************************************************
#include “StdAfx.h“
#include “DesktopWindows.h“
RECT TWindow::GetRectFromPoint(const POINT& PT)
{
RECT Rect;
if (PtInRect(&mRect PT))
{
for (TWindows::iterator it = mChildWindows.begin();it != mChildWindows.end(); it++)
{
Rect = it->GetRectFromPoint(PT);
if(!Empty(Rect))return Rect;
}
return mRect;
}
Rect.left = Rect.top = Rect.right = Rect.bottom = 0;
return Rect;
}
bool TWindow::Empty( RECT &nRect )
{
return nRect.left==nRect.right||nRect.top==nRect.bottom;
}
Des
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 123392 2014-01-10 11:39 SreenShotApp\Debug\Screenshot.dll
文件 1756 2014-01-10 11:39 SreenShotApp\Debug\Screenshot.lib
文件 87552 2014-01-10 11:40 SreenShotApp\Debug\SreenShotApp.exe
文件 35840 2014-01-10 11:39 SreenShotApp\Release\Screenshot.dll
文件 1756 2014-01-10 11:39 SreenShotApp\Release\Screenshot.lib
文件 2298 2014-01-09 18:26 SreenShotApp\Screenshot\DesktopWindows.cpp
文件 889 2014-01-09 18:18 SreenShotApp\Screenshot\DesktopWindows.h
文件 389 2014-01-04 15:48 SreenShotApp\Screenshot\dllmain.cpp
文件 6725 2014-01-09 18:24 SreenShotApp\Screenshot\PUI.cpp
文件 1075 2014-01-09 18:24 SreenShotApp\Screenshot\PUI.h
文件 1179 2014-01-04 15:48 SreenShotApp\Screenshot\ReadMe.txt
文件 3612 2014-01-09 18:26 SreenShotApp\Screenshot\Screenshot.cpp
文件 561 2014-01-09 18:23 SreenShotApp\Screenshot\Screenshot.h
文件 5592 2014-01-09 10:50 SreenShotApp\Screenshot\Screenshot.vcproj
文件 1457 2014-01-10 11:48 SreenShotApp\Screenshot\Screenshot.vcproj.lenovo-PC.lenovo.user
文件 21573 2014-01-09 18:26 SreenShotApp\Screenshot\ShotImplement.cpp
文件 2886 2014-01-09 18:22 SreenShotApp\Screenshot\ShotImplement.h
文件 215 2014-01-04 15:48 SreenShotApp\Screenshot\stdafx.cpp
文件 313 2014-01-04 15:48 SreenShotApp\Screenshot\stdafx.h
文件 1026 2014-01-04 15:48 SreenShotApp\Screenshot\targetver.h
文件 6698 2014-01-09 18:26 SreenShotApp\Screenshot\Widget.cpp
文件 1873 2014-01-09 18:20 SreenShotApp\Screenshot\Widget.h
文件 5504 2014-01-10 11:40 SreenShotApp\SreenShotApp\Debug\BuildLog.htm
文件 65 2014-01-10 11:40 SreenShotApp\SreenShotApp\Debug\mt.dep
文件 663 2014-01-10 11:36 SreenShotApp\SreenShotApp\Debug\SreenShotApp.exe.em
文件 728 2014-01-10 11:36 SreenShotApp\SreenShotApp\Debug\SreenShotApp.exe.em
文件 621 2014-01-10 11:40 SreenShotApp\SreenShotApp\Debug\SreenShotApp.exe.intermediate.manifest
文件 4042 2014-01-10 11:40 SreenShotApp\SreenShotApp\Debug\SreenShotApp.obj
文件 6750208 2014-01-10 11:35 SreenShotApp\SreenShotApp\Debug\SreenShotApp.pch
文件 48304 2014-01-10 11:35 SreenShotApp\SreenShotApp\Debug\SreenShotApp.res
............此处省略27个文件信息
- 上一篇:c# 调用com组件源码 (ie内核封装)
- 下一篇:OPENCV识别圆心c++代码
评论
共有 条评论