复制从XP隐藏或夹窗口中的内容? [英] Copying content from a hidden or clipped window in XP?

查看:109
本文介绍了复制从XP隐藏或夹窗口中的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个窗口(BitBlt的),这是隐藏的内容复制到另一个窗口。问题是,一旦我隐藏源窗口,我得到的设备上下文不再被涂。

I need to copy the content of a window (BitBlt) which is hidden, to another window. The problem is that once I hide the source window, the device context I got isn't painted anymore.

推荐答案

您需要的是 PrintWindow 函数,在Win32 API的使用,因为Windows XP。如果你需要用它来旧版本的Windows的工作,你可以尝试 WM_PRINT ,虽然我从来没有能够使它发挥作用。

What you need is the PrintWindow function that's available in Win32 API since Windows XP. If you need it to work with older versions of Windows, you can try WM_PRINT, although I've never been able to make it work.

这里有一个很好的文章 说明如何在使用PrintWindow,这里的相关$从C条$ C片断:

There's a nice article here that shows how to use PrintWindow, and here's the relevant code snippet from that article:

// Takes a snapshot of the window hwnd, stored in the memory device context hdcMem
HDC hdc = GetWindowDC(hwnd);
if (hdc)
{
    HDC hdcMem = CreateCompatibleDC(hdc);
    if (hdcMem)
    {
        RECT rc;
        GetWindowRect(hwnd, &rc);

        HBITMAP hbitmap = CreateCompatibleBitmap(hdc, RECTWIDTH(rc), RECTHEIGHT(rc));
        if (hbitmap)
        {
            SelectObject(hdcMem, hbitmap);

            PrintWindow(hwnd, hdcMem, 0);

            DeleteObject(hbitmap);
        }
        DeleteObject(hdcMem);
    }
    ReleaseDC(hwnd, hdc);
}

我应该有一个使用wxPython的实现同样的事情,一些Python code。如果你想让它,请给我。

I should have some Python code that uses wxPython to achieve the same thing. Drop me a note if you want it.

这篇关于复制从XP隐藏或夹窗口中的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆