HTMLViewer invalidate and refresh... how?

Hi,
I am having difficulties cleaning an HTMLViewer control,

After drawing a chart on it, at some point I need to draw another chart.

I experimented with Refresh, RefreshRect and Invalidate,
but it seems I cannot erase the previous content.
The old chart gets in the way of the new one…

Does somebody knows how to wipe the htmlviewer content? In other words, how to make invalidate or refresh work.

Platform desktop Mac/OSX

A few ideas… You could reassign the HTML to the HTMLViewer or you can call javascript events on specific controls within the HTMLViewer to force them to refresh. Or maybe make it invisible then visible again.

[quote=177438:@Lisandro Mulena]Hi,
I am having difficulties cleaning an HTMLViewer control,

After drawing a chart on it, at some point I need to draw another chart.

I experimented with Refresh, RefreshRect and Invalidate,
but it seems I cannot erase the previous content.
The old chart gets in the way of the new one…

Does somebody knows how to wipe the htmlviewer content? In other words, how to make invalidate or refresh work.

Platform desktop Mac/OSX[/quote]

Create a blank HTML page that you load to clear the control, such as :

[code]


[/code]

Yes, I have a workaround, I simply draw an empty chart and start over the process.
But I think it is dirty and messy, I was hoping that somebody would point me in the right direction on how to use Invalidate() or Refresh()…
I don’t know why these methods are not working for me, if is it my code, maybe I’am using them in the wrong place, or something else, thank you

[quote=177478:@Lisandro Mulena]Yes, I have a workaround, I simply draw an empty chart and start over the process.
But I think it is dirty and messy, I was hoping that somebody would point me in the right direction on how to use Invalidate() or Refresh()…
I don’t know why these methods are not working for me, if is it my code, maybe I’am using them in the wrong place, or something else, thank you[/quote]

I think you completely misunderstand. The goal of Invalidate and Refresh is not to erase the content, but to redraw it. If you want to erase the content, that is a completely different function.

Here is another way to clear all content in an HTMLViewer :

Dim f As FolderItem = GetTemporaryFolderItem HTMLViewer1.LoadPage(" ", f)

For what I read in the doc…

“If the optional parameter EraseBackground is True, the background will be erased prior to redrawing the control. The default is True.”

[quote=177512:@Lisandro Mulena]For what I read in the doc…

“If the optional parameter EraseBackground is True, the background will be erased prior to redrawing the control. The default is True.”[/quote]

Sigh…

You got to read very carefully : the background will be erased prior to redrawing the control.

You seem to believe invalidate or refresh erases the background alone. All that means is that if you have changing content, it is necessary to erase before drawing again to avoid persistence of the image before. At any rate, the content will always be drawn. Hence the most important part of the sentence : prior to redrawing the control.

If what you want is to erase the background, period, you need to actually draw a new empty content which will replace the existing one. Otherwise it gets redrawn.

That is exactly what I needed. Erasing the background prior to redrawing.
I never said I wanted to erase it, period. I don’t know if my english is just bad or you jumped to conclusions, sorry.

[quote=177520:@Lisandro Mulena]That is exactly what I needed. Erasing the background prior to redrawing.
I never said I wanted to erase it, period. I don’t know if my english is just bad or you jumped to conclusions, sorry.[/quote]

I am sorry to repeat it, but I do believe you are mistaking what invalidate with the erase background option does, and resetting a control property. I do not think it is the language barrier.

You are dealing here with two notions : the content of the HTMLViewer Document Object Model (DOM) on one hand, and the generation by the system of a screen image on the other. Invalidate and refresh work on the data that the screen uses to show a control. Would that be a button, an HTMLViewer, a Canvas or something else. What it erases is the screen picture. To put it another way, Refresh with the erase option actually renders the control invisible before redrawing it. It does not touch the data represented by a property (HTML, Caption, backdrop, etc.) that the control shows. It is just the same as drawing a mustache on a photo of the Gioconda. It will touch the representation of Da Vinci’s masterpiece. Not the painting itself.

Your chart is the result of data fed into the HTMLViewer that it then represents graphically. Invalidate or Refresh will not change the content of the DOM for you. If you want to wipe the content of the HTMLViewer, you got to do it at the HTML level. I already suggested two ways of loading empty content into it through LoadPage, which effectively wipes out the content of the control. Is it not what you wanted to achieve ?

I understand you, and It is working as expected.

Here is a tiny video showing the redraw

https://vimeo.com/123680891

HTMLViewer.ExecuteJavascript("location.reload()")

by any chance?

[quote=177541:@Tim Parnell]HTMLViewer.ExecuteJavascript("location.reload()")
by any chance?[/quote]

You nailed it.