You've already forked lazarus-ccr
TvPlanIt: Avoid windows-like messages in printing routines (fixes crashes in cocoa related to PrintPreview).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8888 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -95,7 +95,7 @@ uses
|
||||
{$ELSE}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
Classes, Dialogs, SysUtils, Graphics, Forms, Printers,
|
||||
Classes, Controls, Dialogs, SysUtils, Graphics, Forms, Printers,
|
||||
VpBase, VpData, VpXParsr, VpCanvasUtils, VpSR, VpException;
|
||||
|
||||
type
|
||||
@ -108,10 +108,12 @@ type
|
||||
ustTLToBRLine, ustBLToTRLine, ustEllipse
|
||||
);
|
||||
|
||||
{
|
||||
TVpWatcher = record
|
||||
Handle: THandle;
|
||||
end;
|
||||
PVpWatcher = ^TVpWatcher;
|
||||
}
|
||||
|
||||
{ TVpAttributes and TVpAttributeItem
|
||||
a collection of attributes collected when parsing the xml file.
|
||||
@ -406,7 +408,7 @@ type
|
||||
procedure ClearVariables;
|
||||
function DeleteVariable(VarName: string): Boolean;
|
||||
procedure DeregisterAllWatchers;
|
||||
procedure DeregisterWatcher(Watcher: THandle);
|
||||
procedure DeregisterWatcher(Watcher: {$IFDEF LCL}TControl{$ELSE}THandle{$ENDIF});
|
||||
function Find(const v: string): Integer;
|
||||
function HaveVariable(VarName: string): Boolean;
|
||||
procedure LoadFromFile(FileName: string; Append: Boolean);
|
||||
@ -414,7 +416,7 @@ type
|
||||
procedure NotifyLinked;
|
||||
procedure PaintToCanvasRect(ACanvas: TCanvas; ARect: TRect; ADate: TDateTime);
|
||||
procedure Print(APrinter: TPrinter; StartDate: TDateTime; EndDate: TDateTime);
|
||||
procedure RegisterWatcher(Watcher: THandle);
|
||||
procedure RegisterWatcher(Watcher: {$IFDEF LCL}TControl{$ELSE}THandle{$ENDIF});
|
||||
procedure RenderPage(ACanvas: TCanvas; ARect: TRect; PageNum: Integer;
|
||||
var ADate: TDateTime; EndDate: TDateTime; var StartContact: Integer;
|
||||
var StartTask: Integer; var LastPage: Boolean);
|
||||
@ -1374,24 +1376,37 @@ procedure TVpPrinter.DeregisterAllWatchers;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := FNotifiers.Count - 1 downto 0 do
|
||||
if Assigned(FNotifiers[i]) then begin
|
||||
FreeMem(FNotifiers[i]);
|
||||
FNotifiers.Delete (i);
|
||||
end;
|
||||
if FNotifiers <> nil then
|
||||
for i := FNotifiers.Count - 1 downto 0 do
|
||||
if Assigned(FNotifiers[i]) then
|
||||
begin
|
||||
{$IFDEF DELPHI}
|
||||
FreeMem(FNotifiers[i]);
|
||||
{$ENDIF}
|
||||
FNotifiers.Delete(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpPrinter.DeregisterWatcher(Watcher: THandle);
|
||||
procedure TVpPrinter.DeregisterWatcher(Watcher: {$IFDEF LCL}TControl{$ELSE}THandle{$ENDIF});
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := FNotifiers.Count - 1 downto 0 do
|
||||
if Assigned(FNotifiers[i]) then
|
||||
if PVpWatcher (FNotifiers[i]).Handle = Watcher then begin
|
||||
FreeMem(FNotifiers[i]);
|
||||
FNotifiers.Delete (i);
|
||||
Exit;
|
||||
end;
|
||||
if FNotifiers <> nil then
|
||||
begin
|
||||
{$IFDEF LCL}
|
||||
i := FNotifiers.IndexOf(Watcher);
|
||||
if i <> -1 then
|
||||
FNotifiers.Delete(i);
|
||||
{$ELSE}
|
||||
for i := FNotifiers.Count - 1 downto 0 do
|
||||
if Assigned(FNotifiers[i]) then
|
||||
if PVpWatcher(FNotifiers[i]).Handle = Watcher then begin
|
||||
FreeMem(FNotifiers[i]);
|
||||
FNotifiers.Delete(i);
|
||||
Exit;
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
function TVpPrinter.HaveVariable(VarName: string): Boolean;
|
||||
@ -1463,10 +1478,22 @@ end;
|
||||
procedure TVpPrinter.NotifyLinked;
|
||||
var
|
||||
i: Integer;
|
||||
{$IFDEF LCL}
|
||||
intf: IVpWatcher;
|
||||
C: TControl;
|
||||
{$ENDIF}
|
||||
begin
|
||||
for i := 0 to FNotifiers.Count - 1 do
|
||||
begin
|
||||
{$IFDEF LCL}
|
||||
C := TControl(FNotifiers[i]);
|
||||
if Assigned(C) and C.GetInterface(GUID_VpWatcher, intf) then
|
||||
intf.VpDatastoreChanged;
|
||||
{$ELSE}
|
||||
if Assigned(FNotifiers[i]) then
|
||||
PostMessage(PVpWatcher(FNotifiers[i]).Handle, Vp_PrintFormatChanged, 0, 0);
|
||||
PostMessage(PVpWatcher(FNotifiers[i]).Handle, Vp_DataStoreChanged, 0, 0);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpPrinter.PaintToCanvasRect(ACanvas: TCanvas; ARect: TRect;
|
||||
@ -1927,18 +1954,29 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TVpPrinter.RegisterWatcher(Watcher: THandle);
|
||||
procedure TVpPrinter.RegisterWatcher(Watcher: {$IFDEF LCL}TControl{$ELSE}THandle{$ENDIF});
|
||||
var
|
||||
i: Integer;
|
||||
{$IFDEF DELPHI}
|
||||
NewHandle: PVpWatcher;
|
||||
{$ENDIF}
|
||||
begin
|
||||
for i := 0 to FNotifiers.Count - 1 do
|
||||
if Assigned(FNotifiers[i]) then
|
||||
if PVpWatcher(FNotifiers[i]).Handle = Watcher then
|
||||
Exit;
|
||||
GetMem(NewHandle, SizeOf(TVpWatcher));
|
||||
NewHandle.Handle := Watcher;
|
||||
FNotifiers.Add(NewHandle);
|
||||
if FNotifiers <> nil then
|
||||
begin
|
||||
{$IFDEF LCL}
|
||||
i := FNotifiers.IndexOf(Watcher);
|
||||
if i = -1 then
|
||||
FNotifiers.Add(Watcher);
|
||||
{$ELSE}
|
||||
for i := 0 to FNotifiers.Count - 1 do
|
||||
if Assigned (FNotifiers[i]) then
|
||||
if PVpWatcher(FNotifiers[i]).Handle = Watcher then
|
||||
Exit;
|
||||
GetMem(NewHandle, SizeOf(TVpWatcher));
|
||||
NewHandle.Handle := Watcher;
|
||||
FNotifiers.Add(NewHandle);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpPrinter.RenderPage(ACanvas: TCanvas; ARect: TRect; PageNum: Integer;
|
||||
|
Reference in New Issue
Block a user