博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VC获取当前鼠标图片
阅读量:7084 次
发布时间:2019-06-28

本文共 2654 字,大约阅读时间需要 8 分钟。

对于warning C4005: 'WINVER' : macro redefinition的处理 在Windows.h中有如下定义:     #ifndef   WINVER     #define   WINVER   0x0400     #endif     如果你把#define   WINVER   0x500置于#include   
之前,就不会出现警告.

需要包含的文件:#include "Winuser.h"

HCURSOR GetCur(){    CURSORINFO hCur;//	HCURSOR hCur;    ZeroMemory(&hCur,sizeof(hCur));    hCur.cbSize=sizeof(hCur);    GetCursorInfo(&hCur);    return hCur.hCursor;}void CMy123Dlg::OnButton1() {	Sleep(2000);	//warning:   this   code   snippet   is   not   bullet   proof. 	HCURSOR   hcur   =   GetCur();//::GetCursor(); 		if(hcur==NULL) 		return; 	ICONINFO     icon; 	::GetIconInfo(hcur,&icon); 	HBITMAP   hbmp; 	BITMAP   bm; 	::GetObject(icon.hbmMask,sizeof(BITMAP),&bm); 		HDC   hGlobal,hDCMask,hDCColor; 	hGlobal   =   ::GetDC(NULL); 	hDCMask   =   ::CreateCompatibleDC(hGlobal); 	hDCColor  =   ::CreateCompatibleDC(hGlobal); 	hbmp	  =   ::CreateCompatibleBitmap(hGlobal,bm.bmWidth,bm.bmWidth); 	::SelectObject(hDCColor,hbmp); 		::FloodFill(hDCColor,0,0,RGB(255,255,255));//背景色 	::SelectObject(hDCMask,icon.hbmMask); 	::BitBlt(hDCColor,0,0,bm.bmWidth,bm.bmWidth,hDCMask,0,0,SRCAND); 	if   (icon.hbmColor   ==   NULL) 		::BitBlt(hDCColor,0,0,bm.bmWidth,bm.bmWidth,hDCMask,0,bm.bmWidth,SRCINVERT); 	else 	{ 		::SelectObject(hDCMask,icon.hbmColor); 		::BitBlt(hDCColor,0,0,bm.bmWidth,bm.bmWidth,hDCMask,0,0,SRCINVERT); 	} 		PICTDESC   picdesc; 	picdesc.cbSizeofstruct   =   sizeof(PICTDESC); 	picdesc.picType   =   PICTYPE_BITMAP   ;                         	picdesc.bmp.hbitmap   =   hbmp; 	IPicture*   pPicture=NULL; 	OleCreatePictureIndirect(&picdesc,   IID_IPicture,   TRUE,(VOID**)&pPicture); 	LPSTREAM   pStream; 	CreateStreamOnHGlobal(NULL,TRUE,&pStream); 	LONG   size; 	HRESULT   hr=pPicture-> SaveAsFile(pStream,TRUE,&size); 	char   pathbuf[1024]; 	strcpy(pathbuf, "c:\\myarrow.bmp "); 		FILE   *stream; 	stream   =   fopen(   pathbuf,   "w "   ); 	LARGE_INTEGER   li; 	li.HighPart   =0; 	li.LowPart   =0; 	ULARGE_INTEGER   ulnewpos; 	pStream-> Seek(   li,STREAM_SEEK_SET,&ulnewpos); 	ULONG   uReadCount   =   1; 	while(uReadCount> 0) 	{ 				pStream-> Read(pathbuf,sizeof(pathbuf),&uReadCount); 		if(uReadCount> 0) 			fwrite(   pathbuf,sizeof(char),uReadCount,stream); 	} 	pStream-> Release(); 	fclose(   stream   ); 		::DeleteObject(icon.hbmMask); 	if   (icon.hbmColor   !=   NULL) 		::DeleteObject(icon.hbmColor); 	::DeleteObject(hbmp); 	::ReleaseDC(NULL,hDCMask); 	::ReleaseDC(NULL,hDCColor); 	::ReleaseDC(NULL,hGlobal);	AfxMessageBox(_T("OK"));}

CBitmap   bmp; CDC   memDC; memDC.CreateCompa... memDC.SelectObiect(bmp) memDC.GetPixel(x,   y)

转载于:https://www.cnblogs.com/rogee/archive/2011/03/26/1996573.html

你可能感兴趣的文章
集群架构-用keepalived配置高可用集群
查看>>
10 种最常见的 Javascript 错误(频率最高)
查看>>
获取websocket数据,C#小窗口程序,FTP上传,一切皆配置
查看>>
0025-CENTOS6.5安装CDH5.12.1(二)
查看>>
保险资管需求多元化 壹资管平台赋能行业智能化转型
查看>>
Velocity模板概念及简单使用
查看>>
Java 基础语法
查看>>
css实现强制不换行/自动换行/强制换行
查看>>
使用awk的二维数组解决一个日志统计的实际问题
查看>>
OSChina 周一乱弹 —— 薯哥儿,你约吗?
查看>>
OSChina 国庆节乱弹 ——祝大家节日快乐。
查看>>
OSChina 周二乱弹 ——首届码云女神
查看>>
OSChina 周六乱弹 —— 我都想和他们组成一个家庭了
查看>>
为什么项目报Invalid bound statement (not found)
查看>>
前端那些事之移动端常用方法
查看>>
mysql数据库操作
查看>>
gitlab上无法clone
查看>>
Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)
查看>>
Git查看、删除、重命名远程分支和tag的命令
查看>>
Myeclipse10.7 汉化,汉化全面!
查看>>