Application crashing

  • 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:

    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

    • Offizieller Beitrag

    Hi,

    You should not use 'Get' inside of the OnGetSpecialText event. The Get function creates a text if it is not there. Please use 'Find'.
    The event is triggered during the format procedure and that is too late to modify the text.

    Also get the latest release V5.18.8

    The code looks fine otherwise.

    Juliuan