Hi! I have an application that uses a table do format the look of my header. There is a image, the company logo. I'm using version 5.R15, and the code is that:
Here I create the header and footer:
Code
var img: TWPOImage; obj: TWPTextObj; tbl: TParagraph;begin {cabeçalho} wpAuxiliar.Clear; wpAuxiliar.ClearHeaderFooter; wpAuxiliar.CheckHasBody; img := TWPOImage.Create(wpAuxiliar); img.LoadFromFile(DirRelatorios+'\ima\logomarca.bmp'); tbl := wpAuxiliar.TableAdd(2, 1, [], nil, nil); tbl.Cols[0].ASetFontName('Arial'); tbl.Cols[0].ASet(WPAT_CharFontSize, 1200); tbl.Cols[0].ASet(WPAT_COLWIDTH, 7500); tbl.Cols[0].ASetAddCharStyle(WPSTY_BOLD); tbl.Cols[0].Align := paralLeft; tbl.Cols[1].ASetFontName('Arial'); tbl.Cols[1].ASet(WPAT_CharFontSize, 1200); tbl.Cols[1].ASet(WPAT_COLWIDTH, 3000); tbl.Cols[1].ASetAddCharStyle(WPSTY_BOLD); tbl.Cols[1].Align := paralRight; tbl.Rows[0].Cols[0].SetText('PACIENTE: ' + nome_paciente.Text+#13+#10+ 'MÉDICO: ' + BuscaMedicoSolicitante +#13+#10+ 'EXAME: ' + descexame_resultado.Text+#13+#10+ 'DATA: ' + data_resultado.Text); obj := tbl.Rows[0].Cols[1].AppendNewObject(wpobjImage, false, false, 0); obj.ObjRef := img; wpAuxiliar.CurrAttr.FontName := 'Arial'; wpAuxiliar.CurrAttr.Size := 12; wpAuxiliar.CurrAttr.Color := clBlack; wpAuxiliar.CurrAttr.Alignment := paralCenter; wpAuxiliar.CurrAttr.SetFontStyle([fsBold]); wpAuxiliar.InputString(#13); wpAuxiliar.InputString('Laudo'+#13); laudo_resultado.HeaderFooter.Get(wpIsHeader, wpraOnFirstPage,'').RTFText.AsString := wpAuxiliar.AsString; laudo_resultado.HeaderFooter.Get(wpIsHeader, wpraOnAllPages,'').RTFText.AsString := wpAuxiliar.AsString; {Rodapé} wpAuxiliar.Clear; wpAuxiliar.ClearHeaderFooter; wpAuxiliar.CheckHasBody; wpAuxiliar.CurrAttr.FontName := 'Arial'; wpAuxiliar.CurrAttr.Size := 12; wpAuxiliar.CurrAttr.Alignment := paralLeft; wpAuxiliar.CurrAttr.SetFontStyle([fsBold]); wpAuxiliar.InputString(nome_profissional.Text+#13); wpAuxiliar.InputString(Crm+#13); laudo_resultado.HeaderFooter.Get(wpIsFooter, wpraOnLastPage,'').RTFText.AsString := wpAuxiliar.AsString; laudo_resultado.HeaderFooter.Get(wpIsFooter, wpraOnAllPages,'').RTFText.AsString := '';
And here I choose the apropriate header and footer on the fly:
Code
procedure Tf_imaresultado2.laudo_resultadoGetSpecialText(Sender: TObject;
par: TParagraph; PosInPar, PageNr: Integer; Kind: TWPPagePropertyKind;
var IsLastPage, UseThis: Boolean; var SpecialText: TWPRTFDataBlock);
begin
inherited;
case Kind of
wpIsHeader:
begin
if PageNr = 1 then
SpecialText := laudo_resultado.HeaderFooter.Get(wpIsHeader, wpraOnFirstPage,'')
else SpecialText := laudo_resultado.HeaderFooter.Get(wpIsHeader, wpraOnAllPages,'');
end;
wpIsFooter:
begin
if IsLastPage then
SpecialText := laudo_resultado.HeaderFooter.Get(wpIsFooter, wpraOnLastPage,'')
else SpecialText := laudo_resultado.HeaderFooter.Get(wpIsFooter, wpraOnAllPages,'');
end;
end;
UseThis := True;
end;
Alles anzeigen
In my form I have a control page, with 2 tabs. The second tab hold the WPRichText component. So, when I change to the second tab, the screem turns blank and the application crashs. Someone can help me??
Thanks