怎么做可以把光标资源作为位图显示在一个窗口上?

zhoumingbo 2006-11-04 03:45:52
怎么做可以把光标资源作为位图显示在一个窗口上?我试着用下面的代码,可 SelectObject 返回 NULL,失败。

PAINTSTRUCT ps;
HDC hdc;
HDC memDC;
HBITMAP hOldBmp,m_hBmp;
hdc = BeginPaint(hwnd, &ps);

m_hBmp=(HBITMAP)LoadImage(ghInstance,MAKEINTRESOURCE(IDC_PENCURSOR),IMAGE_CURSOR,32,32,LR_DEFAULTCOLOR);
memDC = CreateCompatibleDC(NULL);
hOldBmp = (HBITMAP)SelectObject(memDC, m_hBmp);
BitBlt(hdc, 0, 0, 32, 32, memDC, 0, 0, SRCCOPY);

SelectObject(memDC, hOldBmp);
DeleteObject(m_hBmp);
DeleteDC(memDC);
EndPaint(hwnd, &ps);
...全文
179 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
leibniz_zsu 2006-11-05
  • 打赏
  • 举报
回复
好像DrawIcon不行,只有DrawIconEx可以绘制cursor
The DrawIconEx function draws an icon or cursor in the client area of the window of the specified device context, performing the specified raster operations, and stretching or compressing the icon or cursor as specified.
zhoumingbo 2006-11-05
  • 打赏
  • 举报
回复
试了一下 DrawIcon DrawIconEx 都可以,非常感谢。
vcmute 2006-11-04
  • 打赏
  • 举报
回复
DrawIcon
DrawIconEx

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧