增强printscreen按键-显示光标
来源:互联网 发布:淘宝开店类目怎么选 编辑:程序博客网 时间:2024/06/05 17:05
如果仅仅是想屏蔽printscreen按键
那么直接在你的程序重新registered即可
RegisterHotKey(m_hWnd, IDHOT_SNAPDESKTOP, 0, VK_SNAPSHOT);
RegisterHotKey(m_hWnd, IDHOT_SNAPWINDOW, MOD_ALT, VK_SNAPSHOT);更详细说明:http://www.vckbase.com/document/viewdoc/?id=1566
//--------------------------------------------------------------------------------------------------------------------
键盘printscreen按键默认情况
printscreen 截屏(不截光标)
printscreen+alt 截当前窗口(不截光标)
本文增强printscreen按键功能,使之
printscreen 截屏(显示光标)
printscreen+alt 截当前窗口(显示光标)
主要处理过程:
registered printscreen按键的hotkey,见本文头,
在WNDPROC中处理WM_HOTKEY,判断printscreen按键事件,截图并画光标,保存截图内容到剪切板。
关键代码:
截图
void TmainForm::SaveScreenBmpToClipboard(){ HDC hdc=GetDC(NULL); if(hdc) { HDC memDC=CreateCompatibleDC(hdc); assert(memDC); HBITMAP hBmp=CreateCompatibleBitmap(hdc,Screen->Width,Screen->Height); assert(hBmp); SelectObject(memDC,hBmp); ::BitBlt(memDC,0,0,Screen->Width,Screen->Height,hdc,0,0,SRCCOPY); DrawCursor(memDC); if(OpenClipboard(Handle)) { assert(EmptyClipboard()); assert(SetClipboardData(CF_BITMAP,hBmp)); assert(CloseClipboard()); } else { MessageBoxA(NULL,"无法打开剪切板!","提示",MB_ICONERROR); } DeleteObject(hBmp); DeleteObject(memDC); ReleaseDC(NULL,hdc); } }
画出光标
void TmainForm::DrawCursor(HDC hdc,bool bScreen){ HCURSOR hCursor=GetCursor(); POINT ptCursor; GetCursorPos(&ptCursor); if(!bScreen) { ::ScreenToClient(GetForegroundWindow(),&ptCursor); } //获取光标的图标数据 ICONINFO IconInfo; if (GetIconInfo(hCursor, &IconInfo)) { ptCursor.x -= ((int) IconInfo.xHotspot); ptCursor.y -= ((int) IconInfo.yHotspot); if (IconInfo.hbmMask != NULL) DeleteObject(IconInfo.hbmMask); if (IconInfo.hbmColor != NULL) DeleteObject(IconInfo.hbmColor); } //在兼容设备描述表上画出该光标 DrawIconEx( hdc, // handle to device context ptCursor.x, ptCursor.y, nCursorType==0?hCursor:LoadCursor(NULL,MAKEINTRESOURCE(nCursorType)), // handle to icon to draw 0,0, // width of the icon 0, // index of frame in animated cursor NULL, DI_NORMAL | DI_COMPAT // icon-drawing flags ); }
下载地址:http://download.csdn.net/detail/qq752923276/4270836
- 增强printscreen按键-显示光标
- 黑光标按键问题
- richtextbox显示光标所在位置
- 设置光标显示图标
- textbox不显示光标
- 隐藏系统盘,显示光标
- EditText显示光标
- UITextView 光标置顶显示
- 屏蔽输入法、显示光标
- 通过键盘按键改变 光标形状
- 通过键盘按键改变 光标形状
- securecrt 光标不显示,光标丢失
- shell 隐藏光标和显示光标
- EditText 不显示光标 光标消失
- C# 模拟PrintScreen 和 Alt+PrintScreen
- 按键控制数码管显示
- 按键控制数码管显示
- 按键显示数码管
- Android Bluetooth使用详解
- How a .NET application determines what channel definition to use
- 纵横中“初品”Boost程序库探秘
- MQ Intercommunication
- Visual Studio 2010: Build/Rebuild/Clean (01)
- 增强printscreen按键-显示光标
- Objective-c 枚举类型
- 游戏中使用LUA脚本语言的简介
- style和theme小用法
- 一个点击添加button的例子
- 一个Toast例子
- IE 和Firefox的js兼容性总结
- java.lang.NumberFormatException: For input string: "imei"
- JAVA判断字符串数组中是否包含某字符串元素