Copying content from a hidden or clipped window in XP?

前端 未结 10 2029
傲寒
傲寒 2020-12-01 11:52

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 painte

相关标签:
10条回答
  • 2020-12-01 12:11

    http://msdn.microsoft.com/en-us/library/dd144909.aspx (getPixel) might help...

    0 讨论(0)
  • 2020-12-01 12:15

    Copy the source bitmap to a memory bitmap before closing/hiding the window.

    0 讨论(0)
  • 2020-12-01 12:20

    Unfortunately, I think you're going to have real problems getting this to work reliably. You don't say exactly what you're doing, but I assume that, given the window handle, you're grabbing the device context associated with the window by calling GetWindowDC(), and then using the resulting device context.

    This will work okay on XP when the window is visible. However, on Vista, if desktop compositing is enabled, it won't even work properly then: you'll get 0 back from GetWindowDC(). Fundamentally, grabbing window device contexts isn't going to work reliably.

    If the window you're trying to copy from is part of your own application, I'd suggest modifying your code to support the WM___PRINT message: this acts like WM_PAINT, but allows you to supply a device context to draw into.

    If the window isn't from your application, you're basically out of luck: if the window is hidden, the image of what it would show if it were visible doesn't exist anywhere.

    0 讨论(0)
  • 2020-12-01 12:21

    Approaching things from a different perspective, are you sure that's really what you want to be doing? You don't, for example, want to be using CreateCompatibleDC and CreateCompatibleBitmap to create your invisible drawing surface, drawing on that and then using BitBlt?

    Some more information about the background to what you're up to might enable someone to come up with either a solution or some lateral thinking...

    0 讨论(0)
提交回复
热议问题