WIN32 API Problem

Hello All

I am trying to do some animation using WIN32.

I have a form and I want first copy the form to bitmap in the memory,then hide the form and then show the bitmap that was in the memory on the same location as the form

I have shown the code which basically does copy the forms image to bitmap in memory.However but it does Bitblts the image to the screen.

I think this is a refresh problem or am I doing anything wrong

IntPtr hwd = f.Handle;

IntPtr hdc = Win32.GetWindowDC(hwd);

IntPtr memDC = Win32.CreateCompatibleDC(hdc);

IntPtr memBit = Win32.CreateCompatibleBitmap(hdc, f.Width, f.Height);

Win32.SelectObject(memDC, memBit);

Win32.BitBlt(memDC, 0, 0, f.Width, f.Height, hdc, 0, 0, Win32.TernaryRasterOperations.SRCCOPY);

IntPtr screenDc = Win32.GetWindowDC(IntPtr.Zero);

IntPtr hMemdc = Win32.GetDC(memDC);

f.Hide();

Win32.BitBlt(screenDc, f.Left, f.Top, f.Width, f.Height, hMemdc, 0, 0, Win32.TernaryRasterOperations.SRCCOPY);

Win32.ReleaseDC(IntPtr.Zero, screenDc);

Win32.DeleteObject(memBit);

Win32.DeleteDC(memDC);

Win32.ReleaseDC(hwd, hdc);

Any Help is highly appreciated




Answer this question

WIN32 API Problem

  • Daniel B.

    I think you should create another memDC2 for screenDC . Then bitblt

    memDC to memDC2, and finally from memDC2 to screenDC.

     



  • Behnam_acc

    Thanks a lot that worked.I am not that comfortable with Win32 but that worked.You made my day.



  • WIN32 API Problem