WM_PAINT using a custom update region?

Win32 Programming


  • 1. Writing a bitmap to a file
    Hi All, How to write a bitmap to file to which I have got the handle by using GetClipboardData(CF_BITMAP) ? Thanks Krishna Monian
  • 2. can i clip a region of an external window ( outprocess )
    hi, i writing a app that that will give an external foreign application some new functions. For perfect integration it will be nice to draw some data in windows of the external application. That i have realized with the BitBlt , so fare so good. But no there is a little problem i want to fix if it possible. The other application redraw the window very often, so my Data is erased too and i must redraw it again. By that way my data will flickering often and that is the point i want change. Is there a solution to draw my data in that foreign window and to protect it from erasing by the owner of the window with normal API/GDI stuff. I dont want to hooking or subclassing. I have tried a little bit i have not experience with that GDI stuff. suggestions all very welcome best regards juergen
  • 3. SetDIBBits() problems
    Hi, I have an array of bitmap pixels. As per the need I would like to stretch this array(bitmap). I tried following code : HDC kdc, kmemdc, kmemdc1; HBITMAP hbm; int i; BITMAPINFO bmi; // image of 'A' int aSetbytes[8] = { 0xFF, 0xF7, 0xEB, 0xDD, 0xBE, 0x7F, 0xFF, 0xFF }; bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biBitCount = 1; bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biHeight = 8; bmi.bmiHeader.biWidth = 8; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biSizeImage = 0; bmi.bmiHeader.biXPelsPerMeter = 0; bmi.bmiHeader.biYPelsPerMeter = 0; bmi.bmiHeader.biClrImportant = 0; bmi.bmiHeader.biClrUsed = 0; kdc = GetDC(hWnd); hbm = CreateCompatibleBitmap(kdc, 8, 8); kmemdc = CreateCompatibleDC(kdc); kmemdc1 = CreateCompatibleDC(kdc); i = SetDIBits(kdc, hbm, 0, 8, (VOID*)aSetbytes, &bmi, DIB_RGB_COLORS); SelectObject(kmemdc, hbm); StretchBlt(kmemdc1, 0, 0, 16, 16, kmemdc, 0, 0, 8, 8, SRCCOPY); BitBlt(kdc, 300, 50, 16, 16, kmemdc1, 0, 0, SRCCOPY); On screen the BitBlt() produces a small dot. But I expect an stretched image of the array. I trying all these things for the first time. Can somebody tell me where did I went wrong? or any other alternative ways of doing this. thanks
  • 4. 3D cube with GDI+ and C#
    Hi! Why don't use DirectX instead? "Dan" wrote: > I would like to draw a 10X10X10 cube with GDI+ and C#. I would like to color > certain cubes in this rendering. Any sample code or easier way would be most > appreciated. > > Thanks in advance - Dan

WM_PAINT using a custom update region?

Postby Gili » Sat, 21 Aug 2004 13:30:12 GMT


 I need to able to draw parts of a window into a targetDC. Currently I do 
this by calling InvalidateRgn() and invoking WM_PAINT directly with my DC as 
wParam. The problem is that I don't want to clobber the update region of the 
window. That is, if another thread has called InvalidateRgn() on this window 
already, I don't want my painting to interfer with that.

    As far as I know, there is no way to:

1) Lock the window update region
2) Save the window update region
3) Set the window update region to what I want
4) Call WM_PAINT on the update region I just set so the window paints into 
my DC
5) Reset the update region to its saved state
6) Unlock the window update region
7) Furthermore, if any other thread modifies the Window update region in 
between steps 1 and 6 it should modify the *saved* update region, not the 
one I am using for my personal painting.

    Any ideas on how to accomplish this?

    This brings up the question. When WM_PAINT is invoked with wParam=0 it 
calls BeginPaint() which returns a DC having the system clipping region 
derived from the window update region. The question is, if WM_PAINT is 
invoked with wParam!=0, does it use the system clipping region of the DC 
that is passed in or does it still make use of the window update region 
somehow? Is the update region reset if BeginPaint() is never invoked?


Return to Win32 Programming


Who is online

Users browsing this forum: No registered users and 84 guest