* Fixed most parts of bug #16997

git-svn-id: trunk@26913 -
This commit is contained in:
andrew 2010-07-30 19:40:09 +00:00
parent ee2a4b6481
commit c426de02a7
5 changed files with 55 additions and 7 deletions

View File

@ -303,7 +303,7 @@ begin
exit;
end;
fFillingToc := True;
fContentsTree.Visible := False;
//fContentsTree.Visible := False;
fContentsPanel.Caption := 'Table of Contents Loading. Please Wait...';
Application.ProcessMessages;
fChm := TChmReader(Data);
@ -705,7 +705,7 @@ begin
if (Length(DocURL) > 0) and (DocURL[1] <> '/') then
Insert('/', DocURL, 1);
if DocTitle = '' then
Doctitle := 'untitled';
DocTitle := 'untitled';
ListItem := fSearchResults.Items.Add;
ListItem.Caption := DocTitle;
ListItem.Data := fChms.Chm[i];

View File

@ -97,6 +97,7 @@
<PathDelim Value="\"/>
<SearchPaths>
<Libraries Value="\emul\linux\x86\lib\;\emul\linux\x86\usr\lib32\"/>
<OtherUnitFiles Value="..\..\..\..\fpc\packages\chm\src\"/>
<SrcPath Value="$(LazarusDir)\lcl\;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)\"/>
</SearchPaths>
<Parsing>

View File

@ -26,7 +26,7 @@ uses
Controls,
Dialogs,
Forms
{ add your units here }, TurboPowerIPro, chmpopup, lhelpcontrolpkg, lhelpcore;
{ add your units here }, SimpleIPC, TurboPowerIPro, chmpopup, lhelpcontrolpkg, lhelpcore;
var
X: Integer;
@ -60,6 +60,15 @@ begin
end;
Application.CreateForm(THelpForm, HelpForm);
Application.CreateForm(THelpPopupForm, HelpPopupForm);
try
Application.Run;
except
// try to remove stale names pipes so that a new instance can use them
if IPCServer <> nil then
try
FreeAndNil(IPCServer);
except
end;
end;
end.

View File

@ -5,7 +5,7 @@ object HelpForm: THelpForm
Width = 758
ActiveControl = Panel1
Caption = 'LHelp'
ClientHeight = 515
ClientHeight = 512
ClientWidth = 758
Icon.Data = {
7E04000000000100010010100000010020006804000016000000280000001000
@ -49,9 +49,11 @@ object HelpForm: THelpForm
Menu = MainMenu1
OnClose = FormClose
OnCreate = FormCreate
OnKeyUp = FormKeyUp
Position = poScreenCenter
ShowInTaskBar = stAlways
LCLVersion = '0.9.29'
Visible = True
object Panel1: TPanel
Left = 0
Height = 32
@ -242,7 +244,7 @@ object HelpForm: THelpForm
end
object PageControl: TPageControl
Left = 0
Height = 483
Height = 503
Top = 32
Width = 758
Align = alClient

View File

@ -30,7 +30,7 @@ interface
uses
Classes, SysUtils, SimpleIPC,
FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
Buttons, LCLProc, StdCtrls, IpHtml, ComCtrls, ExtCtrls, Menus,
Buttons, LCLProc, StdCtrls, IpHtml, ComCtrls, ExtCtrls, Menus, LCLType,
BaseContentProvider, FileContentProvider, ChmContentProvider{$IFDEF USE_LNET}, HTTPContentProvider{$ENDIF};
type
@ -78,6 +78,7 @@ type
procedure FileMenuOpenURLItemClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ForwardToolBtnClick(Sender: TObject);
procedure HomeToolBtnClick(Sender: TObject);
procedure PageControlChange(Sender: TObject);
@ -101,6 +102,7 @@ type
function ActivePage: TContentTab;
procedure RefreshState;
procedure ShowError(AError: String);
procedure SetKeyUp(AControl: TControl);
public
{ public declarations }
end;
@ -108,6 +110,7 @@ type
var
HelpForm: THelpForm;
IPCServer: TSimpleIPCServer;
const INVALID_FILE_TYPE = 1;
implementation
@ -188,6 +191,8 @@ end;
procedure THelpForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
Visible:= False;
Application.ProcessMessages;
FileMenuCloseItemClick(Sender);
StopServer;
end;
@ -200,6 +205,15 @@ begin
StartServer(fServerName);
end;
RefreshState;
SetKeyUp(Self);
end;
procedure THelpForm.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
);
begin
if Key = VK_ESCAPE then
Close;
end;
procedure THelpForm.ForwardToolBtnClick(Sender: TObject);
@ -344,6 +358,8 @@ begin
fInputIPC.ServerID := ServerName;
fInputIPC.Global := True;
fInputIPC.Active := True;
IPCServer := fInputIPC;
fServerTimer := TTimer.Create(nil);
fServerTimer.OnTimer := @ServerMessage;
fServerTimer.Interval := 200;
@ -362,6 +378,7 @@ begin
fInputIPC.Active := False;
FreeAndNil(fInputIPC);
IPCServer := nil;
FreeAndNil(fServerTimer);
end;
@ -415,7 +432,7 @@ begin
fNewPage := TContentTab.Create(PageControl);
fNewPage.ContentProvider := fRealContentProvider.Create(fNewPage, ImageList1);
fNewPage.Parent := PageControl;
SetKeyUp(fNewPage);
ShowOnTop;
if fNewPage.ContentProvider.LoadURL(AURL, AContext) then
@ -463,6 +480,18 @@ begin
ShowMessage(AError);
end;
procedure THelpForm.SetKeyUp(AControl: TControl);
var
WCont: TWinControl absolute AControl;
i: Integer;
begin
if (AControl = nil) or not (AControl.InheritsFrom(TWinControl)) then
Exit;
for i := 0 to WCont.ControlCount-1 do
SetKeyUp(WCont.Controls[i]);
WCont.OnKeyUp:=@FormKeyUp;
end;
{ TContentTab }
constructor TContentTab.Create(AOwner: TComponent);
@ -476,5 +505,12 @@ begin
inherited Destroy;
end;
finalization
if IPCServer <> nil then
try
FreeAndNil(IPCServer);
except
end;
end.