Fixes WriteLn crashes in Windows and changes the pageControl to be visually added instead of in code

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2153 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2011-11-17 12:47:17 +00:00
parent 6086315b5d
commit f974ea84b7
4 changed files with 79 additions and 69 deletions

View File

@ -3,7 +3,7 @@ object formBrowser: TformBrowser
Height = 439
Top = 186
Width = 621
ClientHeight = 412
ClientHeight = 419
ClientWidth = 621
Color = clBtnFace
Font.Color = clWindowText
@ -18,7 +18,7 @@ object formBrowser: TformBrowser
object panelBottom: TPanel
Left = 0
Height = 18
Top = 394
Top = 401
Width = 621
Align = alBottom
Alignment = taLeftJustify
@ -37,13 +37,26 @@ object formBrowser: TformBrowser
end
object labelProgress: TLabel
Left = 319
Height = 16
Height = 17
Top = 3
Width = 21
Caption = 'Idle'
ParentColor = False
end
end
object pageBrowser: TCDPageControl
Left = 0
Height = 401
Top = 0
Width = 621
Align = alClient
DrawStyle = dsCommon
Caption = 'pageBrowser'
PageIndex = 0
Options = [nboShowCloseButtons, nboHidePageListPopup, nboKeyboardTabSwitch, nboShowAddTabButton]
TabIndex = 0
OnUserAddedPage = HandleUserAddedPage
end
object OpenDialog: TOpenDialog
DefaultExt = '.htm'
Filter = 'html files|*.htm;*.html|all files|*.*'

View File

@ -2,57 +2,62 @@
LazarusResources.Add('TformBrowser','FORMDATA',[
'TPF0'#12'TformBrowser'#11'formBrowser'#4'Left'#3'G'#1#6'Height'#3#183#1#3'To'
+'p'#3#186#0#5'Width'#3'm'#2#12'ClientHeight'#3#156#1#11'ClientWidth'#3'm'#2#5
+'p'#3#186#0#5'Width'#3'm'#2#12'ClientHeight'#3#163#1#11'ClientWidth'#3'm'#2#5
+'Color'#7#9'clBtnFace'#10'Font.Color'#7#12'clWindowText'#11'Font.Height'#2
+#243#9'Font.Name'#6#5'Arial'#4'Menu'#7#8'MainMenu'#8'OnCreate'#7#10'FormCrea'
+'te'#9'OnDestroy'#7#11'FormDestroy'#6'OnShow'#7#8'FormShow'#8'Position'#7#14
+'poScreenCenter'#10'LCLVersion'#6#6'0.9.31'#0#6'TPanel'#11'panelBottom'#4'Le'
+'ft'#2#0#6'Height'#2#18#3'Top'#3#138#1#5'Width'#3'm'#2#5'Align'#7#8'alBottom'
+'ft'#2#0#6'Height'#2#18#3'Top'#3#145#1#5'Width'#3'm'#2#5'Align'#7#8'alBottom'
+#9'Alignment'#7#13'taLeftJustify'#10'BevelInner'#7#9'bvLowered'#10'BevelOute'
+'r'#7#6'bvNone'#12'ClientHeight'#2#18#11'ClientWidth'#3'm'#2#8'TabOrder'#2#0
+#0#12'TProgressBar'#11'ProgressBar'#4'Left'#3#214#1#6'Height'#2#16#3'Top'#2#1
+#5'Width'#3#150#0#5'Align'#7#7'alRight'#8'TabOrder'#2#0#0#0#6'TLabel'#13'lab'
+'elProgress'#4'Left'#3'?'#1#6'Height'#2#16#3'Top'#2#3#5'Width'#2#21#7'Captio'
+'n'#6#4'Idle'#11'ParentColor'#8#0#0#0#11'TOpenDialog'#10'OpenDialog'#10'Defa'
+'ultExt'#6#4'.htm'#6'Filter'#6'%html files|*.htm;*.html|all files|*.*'#7'Opt'
+'ions'#11#14'ofHideReadOnly'#15'ofPathMustExist'#15'ofFileMustExist'#0#4'lef'
+'t'#3'I'#1#3'top'#2#2#0#0#9'TMainMenu'#8'MainMenu'#4'left'#3'#'#1#3'top'#2#4
+#0#9'TMenuItem'#5'File1'#7'Caption'#6#5'&File'#0#9'TMenuItem'#4'Open'#7'Capt'
+'ion'#6#5'&Open'#8'ShortCut'#2'r'#7'OnClick'#7#13'OpenFileClick'#0#0#9'TMenu'
+'Item'#12'OpenTextFile'#7'Caption'#6#15'Open &Text File'#7'OnClick'#7#17'Ope'
+'nTextFileClick'#0#0#9'TMenuItem'#13'OpenImageFile'#7'Caption'#6#16'Open &Im'
+'age File'#7'OnClick'#7#18'OpenImageFileClick'#0#0#9'TMenuItem'#13'PrinterSe'
+'tup1'#7'Caption'#6#16'Printer Setup...'#7'OnClick'#7#18'PrinterSetup1Click'
+#0#0#9'TMenuItem'#12'Printpreview'#7'Caption'#6#14'Print pre&view'#7'Enabled'
+#8#7'OnClick'#7#17'PrintpreviewClick'#0#0#9'TMenuItem'#6'Print1'#7'Caption'#6
+#9'&Print...'#7'Enabled'#8#7'OnClick'#7#11'Print1Click'#0#0#9'TMenuItem'#2'N'
+'1'#7'Caption'#6#1'-'#0#0#9'TMenuItem'#5'Exit1'#7'Caption'#6#5'E&xit'#7'OnCl'
+'ick'#7#10'Exit1Click'#0#0#0#9'TMenuItem'#5'Edit2'#7'Caption'#6#5'&Edit'#7'O'
+'nClick'#7#10'Edit2Click'#0#9'TMenuItem'#5'Find1'#7'Caption'#6#5'&Find'#7'En'
+'abled'#8#7'OnClick'#7#10'Find1Click'#0#0#9'TMenuItem'#8'CopyItem'#7'Caption'
+#6#5'&Copy'#8'ShortCut'#3'C@'#7'OnClick'#7#13'CopyItemClick'#0#0#9'TMenuItem'
+#2'N2'#7'Caption'#6#1'-'#0#0#9'TMenuItem'#13'SelectAllItem'#7'Caption'#6#11
+'Select &All'#7'Enabled'#8#7'OnClick'#7#18'SelectAllItemClick'#0#0#0#9'TMenu'
+'Item'#11'menuOptions'#7'Caption'#6#6'&Tools'#0#9'TMenuItem'#10'ShowImages'#7
+'Caption'#6#12'&Show images'#7'OnClick'#7#15'ShowImagesClick'#0#0#9'TMenuIte'
+'m'#5'Fonts'#7'Caption'#6#23'Default &Font/Colors...'#7'OnClick'#7#15'FontCo'
+'lorsClick'#0#0#9'TMenuItem'#13'menuViewDebug'#7'Caption'#6#26'View Source a'
+'nd Debug info'#7'OnClick'#7#18'menuViewDebugClick'#0#0#9'TMenuItem'#16'menu'
+'ToolsModules'#7'Caption'#6#7'Modules'#0#0#0#9'TMenuItem'#15'HistoryMenuItem'
+#7'Caption'#6#8'&History'#7'Visible'#8#0#0#9'TMenuItem'#6'About1'#7'Caption'
+#6#6'&About'#7'OnClick'#7#11'About1Click'#0#0#0#12'TPrintDialog'#11'PrintDia'
+'log'#8'FromPage'#2#1#7'MinPage'#2#1#7'MaxPage'#3#15''''#7'Options'#11#10'po'
+'PageNums'#0#6'ToPage'#2#1#4'left'#3'j'#1#3'top'#2#1#0#0#11'TFindDialog'#10
+'FindDialog'#7'Options'#11#6'frDown'#15'frHideWholeWord'#18'frDisableWholeWo'
+'rd'#0#6'OnFind'#7#14'FindDialogFind'#4'left'#3#248#0#3'top'#2#4#0#0#10'TPop'
+'upMenu'#9'PopupMenu'#4'left'#3#144#1#3'top'#2#1#0#9'TMenuItem'#9'Viewimage'
+#7'Caption'#6#11'&View image'#7'OnClick'#7#14'ViewimageClick'#0#0#9'TMenuIte'
+'m'#20'CopyImageToClipboard'#7'Caption'#6#24'&Copy image to clipboard'#7'OnC'
+'lick'#7#25'CopyImageToClipboardClick'#0#0#9'TMenuItem'#2'N3'#7'Caption'#6#1
+'-'#0#0#9'TMenuItem'#15'OpenInNewWindow'#7'Caption'#6#19'&Open in new window'
+#7'OnClick'#7#20'OpenInNewWindowClick'#0#0#0#6'TTimer'#9'MetaTimer'#7'Enable'
+'d'#8#7'OnTimer'#7#14'MetaTimerTimer'#4'left'#3#242#0#3'top'#2'K'#0#0#6'TTim'
+'er'#6'Timer1'#8'Interval'#3#200#0#7'OnTimer'#7#11'Timer1Timer'#4'left'#3'0'
+#1#3'top'#2'G'#0#0#19'TPrinterSetupDialog'#18'PrinterSetupDialog'#4'left'#3
+#192#1#0#0#0
+'elProgress'#4'Left'#3'?'#1#6'Height'#2#17#3'Top'#2#3#5'Width'#2#21#7'Captio'
+'n'#6#4'Idle'#11'ParentColor'#8#0#0#0#14'TCDPageControl'#11'pageBrowser'#4'L'
+'eft'#2#0#6'Height'#3#145#1#3'Top'#2#0#5'Width'#3'm'#2#5'Align'#7#8'alClient'
+#9'DrawStyle'#7#8'dsCommon'#7'Caption'#6#11'pageBrowser'#9'PageIndex'#2#0#7
+'Options'#11#19'nboShowCloseButtons'#20'nboHidePageListPopup'#20'nboKeyboard'
+'TabSwitch'#19'nboShowAddTabButton'#0#8'TabIndex'#2#0#15'OnUserAddedPage'#7
+#19'HandleUserAddedPage'#0#0#11'TOpenDialog'#10'OpenDialog'#10'DefaultExt'#6
+#4'.htm'#6'Filter'#6'%html files|*.htm;*.html|all files|*.*'#7'Options'#11#14
+'ofHideReadOnly'#15'ofPathMustExist'#15'ofFileMustExist'#0#4'left'#3'I'#1#3
+'top'#2#2#0#0#9'TMainMenu'#8'MainMenu'#4'left'#3'#'#1#3'top'#2#4#0#9'TMenuIt'
+'em'#5'File1'#7'Caption'#6#5'&File'#0#9'TMenuItem'#4'Open'#7'Caption'#6#5'&O'
+'pen'#8'ShortCut'#2'r'#7'OnClick'#7#13'OpenFileClick'#0#0#9'TMenuItem'#12'Op'
+'enTextFile'#7'Caption'#6#15'Open &Text File'#7'OnClick'#7#17'OpenTextFileCl'
+'ick'#0#0#9'TMenuItem'#13'OpenImageFile'#7'Caption'#6#16'Open &Image File'#7
+'OnClick'#7#18'OpenImageFileClick'#0#0#9'TMenuItem'#13'PrinterSetup1'#7'Capt'
+'ion'#6#16'Printer Setup...'#7'OnClick'#7#18'PrinterSetup1Click'#0#0#9'TMenu'
+'Item'#12'Printpreview'#7'Caption'#6#14'Print pre&view'#7'Enabled'#8#7'OnCli'
+'ck'#7#17'PrintpreviewClick'#0#0#9'TMenuItem'#6'Print1'#7'Caption'#6#9'&Prin'
+'t...'#7'Enabled'#8#7'OnClick'#7#11'Print1Click'#0#0#9'TMenuItem'#2'N1'#7'Ca'
+'ption'#6#1'-'#0#0#9'TMenuItem'#5'Exit1'#7'Caption'#6#5'E&xit'#7'OnClick'#7
+#10'Exit1Click'#0#0#0#9'TMenuItem'#5'Edit2'#7'Caption'#6#5'&Edit'#7'OnClick'
+#7#10'Edit2Click'#0#9'TMenuItem'#5'Find1'#7'Caption'#6#5'&Find'#7'Enabled'#8
+#7'OnClick'#7#10'Find1Click'#0#0#9'TMenuItem'#8'CopyItem'#7'Caption'#6#5'&Co'
+'py'#8'ShortCut'#3'C@'#7'OnClick'#7#13'CopyItemClick'#0#0#9'TMenuItem'#2'N2'
+#7'Caption'#6#1'-'#0#0#9'TMenuItem'#13'SelectAllItem'#7'Caption'#6#11'Select'
+' &All'#7'Enabled'#8#7'OnClick'#7#18'SelectAllItemClick'#0#0#0#9'TMenuItem'
+#11'menuOptions'#7'Caption'#6#6'&Tools'#0#9'TMenuItem'#10'ShowImages'#7'Capt'
+'ion'#6#12'&Show images'#7'OnClick'#7#15'ShowImagesClick'#0#0#9'TMenuItem'#5
+'Fonts'#7'Caption'#6#23'Default &Font/Colors...'#7'OnClick'#7#15'FontColorsC'
+'lick'#0#0#9'TMenuItem'#13'menuViewDebug'#7'Caption'#6#26'View Source and De'
+'bug info'#7'OnClick'#7#18'menuViewDebugClick'#0#0#9'TMenuItem'#16'menuTools'
+'Modules'#7'Caption'#6#7'Modules'#0#0#0#9'TMenuItem'#15'HistoryMenuItem'#7'C'
+'aption'#6#8'&History'#7'Visible'#8#0#0#9'TMenuItem'#6'About1'#7'Caption'#6#6
+'&About'#7'OnClick'#7#11'About1Click'#0#0#0#12'TPrintDialog'#11'PrintDialog'
+#8'FromPage'#2#1#7'MinPage'#2#1#7'MaxPage'#3#15''''#7'Options'#11#10'poPageN'
+'ums'#0#6'ToPage'#2#1#4'left'#3'j'#1#3'top'#2#1#0#0#11'TFindDialog'#10'FindD'
+'ialog'#7'Options'#11#6'frDown'#15'frHideWholeWord'#18'frDisableWholeWord'#0
+#6'OnFind'#7#14'FindDialogFind'#4'left'#3#248#0#3'top'#2#4#0#0#10'TPopupMenu'
+#9'PopupMenu'#4'left'#3#144#1#3'top'#2#1#0#9'TMenuItem'#9'Viewimage'#7'Capti'
+'on'#6#11'&View image'#7'OnClick'#7#14'ViewimageClick'#0#0#9'TMenuItem'#20'C'
+'opyImageToClipboard'#7'Caption'#6#24'&Copy image to clipboard'#7'OnClick'#7
+#25'CopyImageToClipboardClick'#0#0#9'TMenuItem'#2'N3'#7'Caption'#6#1'-'#0#0#9
+'TMenuItem'#15'OpenInNewWindow'#7'Caption'#6#19'&Open in new window'#7'OnCli'
+'ck'#7#20'OpenInNewWindowClick'#0#0#0#6'TTimer'#9'MetaTimer'#7'Enabled'#8#7
+'OnTimer'#7#14'MetaTimerTimer'#4'left'#3#242#0#3'top'#2'K'#0#0#6'TTimer'#6'T'
+'imer1'#8'Interval'#3#200#0#7'OnTimer'#7#11'Timer1Timer'#4'left'#3'0'#1#3'to'
+'p'#2'G'#0#0#19'TPrinterSetupDialog'#18'PrinterSetupDialog'#4'left'#3#192#1#0
+#0#0
]);

View File

@ -23,6 +23,7 @@ type
{ TformBrowser }
TformBrowser = class(TForm)
pageBrowser: TCDPageControl;
labelProgress: TLabel;
menuToolsModules: TMenuItem;
menuViewDebug: TMenuItem;
@ -95,6 +96,7 @@ type
procedure PrintpreviewClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure PrinterSetup1Click(Sender: TObject);
procedure HandleUserAddedPage(Sender: TObject; APage: TCDTabSheet);
private
{ Private declarations }
{$IFDEF LCLCarbon}
@ -122,7 +124,6 @@ type
procedure HandlePageChanged(Sender: TObject);
public
{ Public declarations }
pageBrowser: TCDPageControl;
CurrentTab: Integer;
procedure LoadURL(AURL: string);
procedure AddBrowserTab(AURL: string; AGoToTab: Boolean);
@ -131,7 +132,6 @@ type
procedure AddURLToHistory(AURL: string);
procedure HandlePageLoaderProgress(APercent: Integer);
procedure HandlePageLoaderTerminated(Sender: TObject);
procedure HandleUserAddedPage(Sender: TObject; APage: TCDTabSheet);
end;
var
@ -144,14 +144,6 @@ uses
procedure TformBrowser.FormCreate(Sender: TObject);
begin
pageBrowser := TCDPageControl.Create(Self);
pageBrowser.Parent := Self;
pageBrowser.Align := alClient;
pageBrowser.DrawStyle := dsKDE;
pageBrowser.Options := [nboShowCloseButtons, nboHidePageListPopup,
nboKeyboardTabSwitch, nboShowAddTabButton];
pageBrowser.OnUserAddedPage := HandleUserAddedPage;
InitializeForm();
end;
@ -255,7 +247,6 @@ begin
History := TStringList.Create;
AddBrowserTab('', True);
pageBrowser.OnChange := HandlePageChanged;
Position := poScreenCenter;

View File

@ -5,12 +5,13 @@ unit viewer_ipro;
interface
uses
Classes, SysUtils, Graphics, Forms, Controls,
Classes, SysUtils,
//
fpreadgif, fpimage, fpwritebmp,
// LCL
Graphics, Forms, Controls, LCLProc,
//
browserviewer,
//
IPHtml, Ipfilebroker, IpMsg;
type
@ -55,7 +56,7 @@ var
ms: TMemoryStream;
begin
Result:=nil;
WriteLn('TMyIpHtmlDataProvider.DoGetStream '+URL);
DebugLn('TMyIpHtmlDataProvider.DoGetStream '+URL);
if URL='fpdoc.css' then begin
//debugln(['TMyIpHtmlDataProvider.DoGetStream ',FileExists(URL)]);
@ -73,14 +74,14 @@ end;
function TiProViewer.DataProvider1CanHandle(Sender: TObject; const URL: string
): Boolean;
begin
WriteLn('TformBrowser.DataProvider1CanHandle ',URL);
DebugLn('TformBrowser.DataProvider1CanHandle ',URL);
Result:=True;
end;
procedure TiProViewer.DataProvider1CheckURL(Sender: TObject; const URL: string;
var Available: Boolean; var ContentType: string);
begin
WriteLn('TformBrowser.DataProvider1CheckURL ',URL);
DebugLn('TformBrowser.DataProvider1CheckURL ',URL);
Available:=True;
ContentType:='text/html';
end;
@ -90,7 +91,7 @@ procedure TiProViewer.DataProvider1GetHtml(Sender: TObject; const URL: string;
var
lStream: TMemoryStream;
begin
WriteLn('TformBrowser.DataProvider1GetHtml ',URL);
DebugLn('TformBrowser.DataProvider1GetHtml ',URL);
{ MyPageLoader.LoadBinaryResource(URL, lStream);
Stream := lStream;
lStream.Position := 0;}
@ -110,12 +111,12 @@ var
writer: TFPCustomImageWriter;
lAbsURL: String;
begin
WriteLn('TformBrowser.DataProvider1GetImage URL=', URL);
DebugLn('TformBrowser.DataProvider1GetImage URL=', URL);
// Corrections of the URL
if (URL[1] = '/') and (URL[2] = '/') then lAbsURL := 'http:' + URL;
WriteLn('TformBrowser.DataProvider1GetImage Corrected URL=', lAbsURL);
DebugLn('TformBrowser.DataProvider1GetImage Corrected URL=', lAbsURL);
lStr := ExtractFileExt(lAbsURL);
if (lStr = '.jpeg') or (lStr = '.jpg') then
@ -131,7 +132,7 @@ begin
end
else if (lStr = '.gif') then
begin
WriteLn('TformBrowser.DataProvider1GetImage Processing GIF');
DebugLn('TformBrowser.DataProvider1GetImage Processing GIF');
try
MyPageLoader.LoadBinaryResource(lAbsURL, lStream);
lStream.Position := 0;
@ -154,7 +155,7 @@ begin
end
else
begin
WriteLn('TformBrowser.DataProvider1GetImage Unsupported format: ', lStr);
DebugLn('TformBrowser.DataProvider1GetImage Unsupported format: ', lStr);
Picture := nil;
Exit;
end;