What are the methods that are called when we invoke UpdateWindows() in MSDN?


Keywords:c++ 


Question: 

I have an application where I am passing a handle ID of a window and calling UpdateWindow() method on that.The Problem is for small applications like notepad it takes hardly some 100 ms to finish updating the window,where as for my application it takes 1 min to finish updating the window.

Hence,I wanted to know what are the methods which are being called in the background ,so that I can identify where is the time lag for my application.


1 Answer: 

The main thing that UpdateWindow does is sends a WM_PAINT message, which likely results in WM_ERASEBKNGD and WM_NCPAINT messages (it is possible to paint without these messages but you have to avoid BeginPaint/EndPaint and use a HDC from GetDC() and call ValidateRect or ValidateRegion instead).

Your WM_PAINT handler should not need to calculate whatever it needs to draw (doing so is the likely reason for painting being as slow as you describe), that work should already have been accomplished before painting begins. If your window is a view into a much larger virtual space only draw the area that is actually visible.