From 98c77fabc7c1c246c26d38c90c2121dc73252fb7 Mon Sep 17 00:00:00 2001 From: Joshy Date: Wed, 24 Nov 2010 13:54:27 +0000 Subject: [PATCH] Reintroduced overrides for CreateWnd because the component creation at runtime will not work without it. Refactored the initialization to not be called 2 times, one from Loaded and one from CreateWnd. Tested win32 but it should not affect other widgetsets. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1380 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../geckoport/Components/GeckoBrowser.pas | 52 +++++++++++++++---- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/components/geckoport/Components/GeckoBrowser.pas b/components/geckoport/Components/GeckoBrowser.pas index 41b08cd35..85b5dd626 100755 --- a/components/geckoport/Components/GeckoBrowser.pas +++ b/components/geckoport/Components/GeckoBrowser.pas @@ -183,6 +183,7 @@ type //misc settings FDisableJavaScript: Boolean; + FInitializationStarted: Boolean; FInitialized: Boolean; function GetDisableJavaScript: Boolean; @@ -208,6 +209,7 @@ type //function GetMarkupDocumentViewer: nsIMarkupDocumentViewer; //function GetDocShell: nsIDocShell; //function GetDocumentCharsetInfo: nsIDocumentCharsetInfo; + procedure DoInitializationIfNeeded; protected procedure Paint; override; public @@ -239,6 +241,10 @@ type procedure Resize; override; procedure Loaded; override; + + //TWinControl + procedure CreateWnd; override; + procedure DestroyWnd; override; protected property Chrome: TCustomGeckoBrowserChrome read FChrome write SetChrome; @@ -1054,17 +1060,24 @@ end; procedure TCustomGeckoBrowser.Loaded; begin inherited Loaded; - if not (csDesigning in ComponentState) then - begin - InitWebBrowser; - LoadURI('about:blank'); - FInitialized:=true; - if Assigned(FOnSetupProperties) then begin - FOnSetupProperties(Self); - end; - //Set again the published properties - SetDisableJavascript(FDisableJavaScript); - end; + DoInitializationIfNeeded; +end; + +procedure TCustomGeckoBrowser.CreateWnd; +begin + {$IFDEF DEBUG} + OutputDebugString('TGeckoBrowser.CreateWnd'); + {$ENDIF} + inherited CreateWnd; + DoInitializationIfNeeded; +end; + +procedure TCustomGeckoBrowser.DestroyWnd; +begin + {$IFDEF DEBUG} + OutputDebugString('TGeckoBrowser.DestroyWnd'); + {$ENDIF} + inherited DestroyWnd; end; procedure TCustomGeckoBrowser.GoBack; @@ -1895,6 +1908,23 @@ begin {$ENDIF} end; +procedure TCustomGeckoBrowser.DoInitializationIfNeeded; +begin + if not FInitializationStarted then + if not (csDesigning in ComponentState) then + begin + FInitializationStarted:=true; + InitWebBrowser; + LoadURI('about:blank'); + FInitialized:=true; + if Assigned(FOnSetupProperties) then begin + FOnSetupProperties(Self); + end; + //Set again the published properties + SetDisableJavascript(FDisableJavaScript); + end; +end; + { function TCustomGeckoBrowser.GetMarkupDocumentViewer: nsIMarkupDocumentViewer; var