Search code examples
gdistretchdibits

how to set GDI HDC's drawable region?


I want to draw a HBITMAP onto HDC,

I used StretchDIBits. It works fine. ::StretchDIBits.

however, I only want a window to watch the drawing result, beside the window, I wish the stretchDIBits do not take any effect(It can not draw on other area), how can I do this?


Solution

  • When a child window is created, make sure the WS_CLIPSIBLINGS style is set to disallow painting outside the client area in WM_PAINT.

    Other than that, SelectClipRegion is probably what you want.