- // handle to bitmap
- HBITMAP hwndToHbitmap(HWND hwnd)
- {
- // get the DC of the handle
- HDC hDC = GetDC(hwnd);
- // the rect struct
- RECT rect;
- // get the rect of the handle
- GetClientRect(hwnd, &rect);
- // create a compatible dc for the hDC
- HDC hDCMem = CreateCompatibleDC(hDC);
win32下handle转化为HBITMAP
最新推荐文章于 2019-08-13 21:36:39 发布
这段代码展示了如何将Windows窗口句柄(hwnd)转换为HBITMAP。通过获取窗口的设备上下文(hDC),定义矩形结构(rect),创建兼容的内存设备上下文(hDCMem)以及与之兼容的位图(hBitMap),然后使用BitBlt函数将窗口内容复制到位图上,最后返回HBITMAP。
摘要由CSDN通过智能技术生成