here is a workbook demo:


Ok. Let me explain.

I have an Excel worksheet with a Source Cell and a Target Cell.

Via GDI API functions, I draw a temporary gradient fill over the source cell which happens to be cell "D6".

then, I make a transparent copy of the temp gradient fill drawn over the source cell and place the copy (ie the transparent gradient fill) over the target cell which happens to be cell "D9".

Ultimatly, my goal is to have only the target cell with its transparent gradient and get rid of the source gradient.

I am using the InValidateRect to erase the temp fill located over the source cell by passing to the function the application hwnd and the exact Rect value of the source cell (measured in screen pixels) .This is according to the API tutorial. YET ,when called, InValidateRect either doesn't do anything at all or redraw the entire screen instead of redrawing the source cell rect only as expected.

Any help would be much appreciated.


7 Years
Discussion Span
Last Post by hkdani

I am using the InValidateRect to erase the temp fill

InvalidateRect just defines the coordinates of one Rect Structure. The next API you should use is the BeginPaint API which should reference that rectangle.

The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs or until the region is validated by using the ValidateRect or ValidateRgn function. (Win32SDK)

A call to the BeginPaint API should generate a WM_PAINT message.

And you also have to be aware that there is an update Region for any particular window. There may be other Rect Structures that have been passed by InvalidateRect to that window. And if those other calls have set the Erase Flag to TRUE in their InvalidateRect call, then irrregardless of your request to not erase the other areas, all areas of the update region will be erased anyway.

If the bErase parameter is TRUE for any part of the update region, the background is erased in the entire region, not just in the given part. (WIN32SDK)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.