client area is moving to screen (0,0) position


I am creating one parent window, inside that one child window.Now i am displaying an image inside child window client area.

when i launch it first time , image is displaying in correct position (In child client area).But in second launch onwards( with out closing the first instance),image is moving to screen (0,0) position.

Please suggest any solution for this problem.

Thanks in advance.
Only thing I can think of is you have bad memory or a bad handle somewhere. I'm not sure, but if you blit to a null HDC it will blit to the desktop.... so maybe that's what happening here? Put some checks in your drawing code and make sure all the handles you're using are valid.
I confirm blitting to HDC taken from HWND Null is the Desktop HDC.

HWND Window = 0;
HDC hDC = GetDC(Window); // -> HDC of Desktop!
// Drawing to hDC now goes to the desktop!
Thanks Disch and EssGeEich,

I solved the issue.

Last edited on
Topic archived. No new replies allowed.