WP Tools v 5.48.5, Delphi 5, Windows XP
In a test project, using a Checkbox, I can set the Footer Shading (BG Color) as expected. However, when I want to UN-DO the shading, I "should" be able to set the footer shading color to Editor.PaperColor so that shading will not be visible. However this part does not work.
So, if Editor.PaperColor is set to clInfoBK, footer shading remains gray. This works fine if I keep PaperColor to clWindow and call "WPT_Set_Footer_Shading()" below.
Code
procedure TForm1.cbx_Do_Footer_ShadingClick(Sender: TObject);
begin
if cbx_Do_Footer_Shading.checked then begin
WPT_Set_Footer_Shading(TheEditor, clGray, 8) ;
end
else begin
{If paper color is not clWindow then following doesn't change shading}
WPT_Set_Footer_Shading(TheEditor, TheEditor.PaperColor, 100) ;
{if paper color is clWindow, then either one of the following lines clears shading as expected}
// WPT_Set_Footer_Shading(TheEditor, clWindow, 100) ;
// WPT_Set_Footer_Shading(TheEditor, TheEditor.PaperColor, 100) ;
end ;
end;
Procedure WPT_Set_Footer_Shading(RTFMemo : TWPCustomRtfEdit;
clShadingColor : TColor; nShadingPercent : Integer);
var
Par : TParagraph ;
nOldCPPos : Integer ;
Begin
nOldCPPos := RTFMemo.CPPosition ;
{First, Make Footer text the active text block to work on }
RTFMemo.HeaderFooter.Get( wpIsFooter, wpraOnAllPages).WorkOnText := true;
par := RTFMemo.HeaderFooter.Get(wpIsFooter, wpraOnAllPages).FirstPar ;
Application.ProcessMessages ;
while(Par <> nil) do begin
Par.ASetColor(WPAT_BGColor, clShadingColor);
Par.ASet(WPAT_ShadingValue, nShadingPercent);
Par := Par.NextPar;
end;
Try
{Make Body Text block the active text and set cursor pos }
RTFMemo.ActiveText := RTFMemo.BodyText ;
RTFMemo.CPPosition := nOldCPPos ;
RTFMemo.SetFocus ;
RTFMemo.ReformatALL ;
except
end ;
end ;
Alles anzeigen
In essense, Footer Shading "UNDO" works ONLY IF Editor.PaperColor = clWindow but NOT if PaperColor is anything else.
Am I missing something here? Is there a better way to approach this?
Thanks
JayM