简体   繁体   中英

Blt'ing through memoryDC does not work

HDC hdcScreen = GetDC(NULL);
HDC hdcWindow = GetDC(mWin);
HDC hdcMem = CreateCompatibleDC(hdcScreen);
if (!hdcScreen || !hdcWindow || !hdcMem){
    MessageBox(NULL, "could not locate hdc's", "Viewer", MB_ICONERROR);
}

if (!StretchBlt(hdcMem, 0, 0, 300, 300, hdcScreen, 0, 0, 300, 300, SRCCOPY)){
    MessageBox(NULL, "stretchblt failed", "Viewer", MB_ICONERROR);
}
else if (!BitBlt(hdcWindow, 0, 0, 300, 300, hdcMem, 0, 0, SRCCOPY)){
    // error
    MessageBox(NULL, "stretchblt failed", "Viewer", MB_ICONERROR);
}

ReleaseDC(NULL, hdcScreen);
ReleaseDC(mWin, hdcWindow);
ReleaseDC(mWin, hdcMem);

A single call to StretchBlt from Screen to Window works fine, but the above does not. Any helpful tips?

[Edit] No errors are triggered, so everything seems to work fine, however the window associated with mWin is blank.

您需要创建一个位图,然后使用SelectObject将其选择到内存DC中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM