Is there anyway to stop TWebBrowser from clearing when I set Self.Parent := nil;?
When it gets to that line (which is necessary for a maximizing function), all the TWebBrowsers in my form clears. Why does it do that and what can I do to avoid this?
EDIT:
‘Self’ is the current form (in this case AnsForm) being shown on the MainForm.
Previous value of Parent is a Tab in MainForm.
I tried setting Self.Parent to something else but the same thing happens.
Reassigning the
TWinControl.Parentproperty causes that control (in this case, yourTFormobject) to destroy itsHWND(as a childHWNDcannot exist without a parentHWND), and a newHWNDis not created until the next time that control’sHandleproperty is accessed (if noParentis available by then, an exception is raised). When a control destroys itsHWND, all of its child controls, and their child controls, and so on, destroy their ownHWNDs as well. Without anHWND, there is nothing for a control to display, and any content stored in thoseHWNDs is lost. That is why yourTWebBrowserobjects get cleared.Some components cache their current content in memory when their
HWNDis destroyed and then restore that content when a newHWNDbecomes available, butTWebBrowserdoes not (and cannot) do that. Your only option in this situation is to manually reload the current URL again. Otherwise, re-design your UI so theTWebBrowserobjects do not reside on a parent control whoseParentproperty changes.