Page 1 of 1

TWebView setparent TPanel

Posted: Wed Oct 01, 2025 12:57 pm
by Natter
Hi,

There is a control (TPanel) I need to use it as a window for a TWebView object. Making an oWebView:SetParent(oPanel). There is no error, but oWebView does not become a control.
len(oPanel:AControls) will return 0
Is this how it should be or am I wrong ?

Re: TWebView setparent TPanel

Posted: Wed Oct 01, 2025 1:19 pm
by ertan
Hi,

Please check this variable TPanel:New() in tpanel.prg

::nExStyle = WS_EX_CONTROLPARENT

and use oPanel:Show() after DEFINE PANEL oPanel

Re: TWebView setparent TPanel

Posted: Wed Oct 01, 2025 1:56 pm
by Natter
Actually, in the TPanel:New() method, this value is specified by default
::nExStyle = WS_EX_CONTROLPARENT

? oPanel:nExStyle returns 65536

So what ?

Re: TWebView setparent TPanel

Posted: Wed Oct 01, 2025 4:34 pm
by Horizon
Natter wrote: Wed Oct 01, 2025 12:57 pm Hi,

There is a control (TPanel) I need to use it as a window for a TWebView object. Making an oWebView:SetParent(oPanel). There is no error, but oWebView does not become a control.
len(oPanel:AControls) will return 0
Is this how it should be or am I wrong ?
Can you try to set oWebView:SetParent(oPanel) command in on init of panel.

Re: TWebView setparent TPanel

Posted: Wed Oct 01, 2025 4:55 pm
by Antonio Linares
Dear Yuri,

You should do:

oWebView := TWebView2():New( oPanel )

If the panel is on a dialog box, then you have to do it from ACTIVATE DIALOG ... ON INIT ...

Re: TWebView setparent TPanel

Posted: Wed Oct 01, 2025 5:25 pm
by Natter
I'm using FW 23.7, there's only the TWebView() class()

Of course, I create all the controls in the ini function :D
ACTIVATE DIALOG i ON INIT My_Ini()

function My_Ini
oPn:=TPanel():New()
oWebView:=TWybWiew():New()
oWebView:SetParent(oPn)
? len(oPn:aControls) -> 0
return

Re: TWebView setparent TPanel

Posted: Wed Oct 01, 2025 5:30 pm
by Antonio Linares
Dear Yuri,

WebView has a special working behavior designed by Microsoft:

When we provide a parent to it, webview creates a child window of the provided window where webview places itself (in the "ghost" child).

Parent --> Ghost child --> webview

This may help you to better understand it :)