截屏软件代码
代码说明:
【核心代码】//********************************************************************************//文件: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);}
下载说明:请别用迅雷下载,失败请重下,重下不扣分!