【发布时间】:2014-02-27 17:09:38
【问题描述】:
当我尝试使用下面的代码将应用程序图标复制到客户区的左上角时,我使用了如下代码:
case WM_PAINT:
hdcClient = BeginPaint (hwnd, &ps) ;
hdcWindow = GetWindowDC (hwnd) ;
cxSource = GetSystemMetrics (SM_CXSIZEFRAME) + GetSystemMetrics (SM_CXSIZE) ;
cySource = GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION) ;
BitBlt (hdcClient, 0, 0, cxSource, cySource, hdcWindow, 0, 0, SRCCOPY) ;
ReleaseDC (hwnd, hdcWindow) ;
EndPaint (hwnd, &ps) ;
return 0 ;
......
但是我总是得到的是这样的:
看来 hdcWindow 得到的是它下面窗口的 hdc。我无法弄清楚我的 BitBlt() 调用出了什么问题。
- 我是在 Windows 7 中完成的。
【问题讨论】:
-
这一切都取决于所使用的
hwnd。是可用的客户区吗? -
试试:BitBlt (hdcWindow, 0, 0, cxSource, cySource, hdcWindow, 0, 0, SRCCOPY) ;
-
只需使用 WM_GETICON 和 DrawIcon()。
-
如果您尝试修改 Petzold 的书 Programming Windows 5th edition 中的示例,这对我很有帮助?
-
是的,我正在修改示例。