问题
I am drawing to a regular HwndRengerTarget
but other windows, which have nothing to do with Direct2D, overlap it.
The problem is that these windows get painted over when I draw to the HwndRengerTarget
.
I would like to tell Direct2D not to touch a specific region of the HwndRengerTarget
(i.e. don't touch the pixels that are already on the screen), so that these windows remain correctly visible.
Is that possible?
If I draw normally then call RedrawWindow
on the windows, it flickers a lot.
Thanks.
回答1:
Why not arrange the windows (HWNDs) so that the Direct2D one is at the bottom of the z-index? It should be the first child of its parent. Then clipping will be automatic. You may need the WS_CLIPSIBLINGS window style.
回答2:
If you want to manually restrict your rendering to a certain region you can use layers (ID2D1Layer
objects).
More info here Layers Overview
If the visible region is rectangular it may be simpler to use axis aligned clips via methods PushAxisAlignedClip
and PopAxisAlignedClip
.
ID2D1RenderTarget::PushAxisAlignedClip
Another method of restricting drawing to a certain shape is to render it to a bitmap and then use this bitmap via a bitmap brush in the FillGeomtry
method.
ID2D1RenderTarget::FillGeometry
回答3:
I had the same problem.
Fixed by calling CreateWindowEx LAST for the D2D child HWND. So AFTER all the other child windows are created.
来源:https://stackoverflow.com/questions/11309768/direct2d-leave-a-region-of-a-window-render-target-untouched