HTMLViewer History Clearing Or Instantiation In DesktopPagePanel

Hi, I have a dilemma. I have a window that has a DesktopPagePanel with 4 panels. The 4th panel contains a HTMLViewer that is use to load different sites.

The issue is that a person can select 1 from 3 options to view (a url) and that gets loaded to the HTMLViewer but the current implementation using the same HTMLViewer keeps the history from the previous url loaded which defeats the purpose of only selecting 1 option from 3.

First question… Is there a way to clear the history (with no plugin)?

So I searched online (limited) and could not find anything to clear the history. I then decided to implement the HTMLViewer in a different way. The new way is to subclassed the HTMLViewer and instantiated programmatically and place it in the window. My idea was to place it inside the DesktopPagePanel but I could not find a way to do it so i added the control to the window. This is causing other issues.

Second question, Is there a way to add a control to a DesktopPagePanel programmatically?

TIA

In your DeskopPagePanel.PanelChanged Event handler add code to set the url of the HTML Viewer to “about:blank” if it is <> to the panel index of the control.

To add a control to a panel you need to set the parent (to the control) & panelindex (to the panel) properties.

Hi @Wayne_Golding,

I am trying to understand… so do i need to do the following. Thank you so much for your response Sir.

Sub PanelChanged()
    Var WebViewer as New HTMLViewer
    
    WebViewer.Width = Window.Width
    WebViewer.Height = Window.Height - 135
    WebViewer.top = 135
    
    WebViewer.LockTop = True
    WebViewer.LockBottom = True
    WebViewer.LockRight = True
    WebViewer.LockLeft = True
    
    WebViewer.Parent = Me // This is the DesktopPagePanel Instance

   // here is where i am a bit confused.  It sounds what you say is to add PanelIndex to the panel
    Me.PanelIndex = 4 // is this what you meant?

   // or 
    WebViewer.PanelIndex = 4 // This is to set up the control in panel 4?
    
    WebViewer.LoadURL(Self.CurrentUrl)
    
   // I assumed i need to add the control to the window?  Otherwise without this line the control does not show
    Window.AddControl(WebViewer) // Here i am adding the control to the window
End Sub

Let me know if I am missing anything.

I would add the control to your window at the top (after Var Webviewer As…). Also you mention there are 4 panels - there are numbered 0-3 to you’d want to set the panelindex to 3 not 4.

But why not go with option 1 which is to set the URL to “about:blank” if the panel index is < 3?

Have a look at this project to see how I answer your first question.

Doing the first option you provided adds a blank page but still keeps the history. I tested it, loaded a page (page1) then added the code to set the HTMLViewer to about:blank whenever the panel moves away from panel 4 (actually i have 5 panels sorry) and then loaded a new page. The history is: page1 > about:blank > new page.

For this reason i prefer to instantiate the HTMLViewer programmatically. The only problem i am facing now is that when the selected panel index changes, the HTMLViewer loads the original page again. If the user clicked a link to go to a different page then they lose their position and have to start all over again.

You could try adding a unique parameter onto the end of the URL.

For example, if the URL was: http://www.awebsite.com, you could change it to http://www.awebsite.com/?version=nnnn

(version is a parameter that doesn’t already exist on the url and nnnn is something that changes such as the current Ticks value).