-3

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.

Srikant Barik
  • 133
  • 2
  • 12
  • I am newbie to C++,so pardon the technical language used. – Srikant Barik Feb 27 '18 at 06:06
  • Did you not read the [documentation](https://msdn.microsoft.com/en-us/library/dd145167.aspx): *"The UpdateWindow function updates the client area of the specified window by sending a [WM_PAINT](https://msdn.microsoft.com/en-us/library/dd145213.aspx) message to the window"*. – IInspectable Feb 27 '18 at 13:14

1 Answers1

1

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.

SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23
  • I think this input is helpful for me .I want to avoid painting in the view,as my view is larger and it has more components.My objective of invoking UpdateWindows() method is to redirect some system call back methods to my custom methods.I want to invoke the system methods without painting the components. – Srikant Barik Feb 27 '18 at 09:44
  • I am contemplating of using RedrawWindow() method.How is it different from UpdateWindow()? – Srikant Barik Feb 27 '18 at 10:05
  • The problem is in your painting code. Hoping for a magic solution is futile. Fix your painting code. – David Heffernan Feb 27 '18 at 13:10