Access violation on calling: FieldGetList()

  • Delphi 2007, WPTools [V5.51], Windows Vista

    The one page document has plain text (nothing fancy) and Hyperlink objects that were created using: WPEditor.InputHyperlink() at runtime. There are no other text objects in the document that I am aware of. Document starts as plain text (e.g., text copied from Notepad - so, there is no HTML or RTF markup when text is loaded into WPEditor).

    Code
    procedure TForm1.TestClick(Sender: TObject);var    aTextObjList : TWPTextObjList ;    i, nObjCount : Integer ;begin   WPEditor.FieldGetList(aTextObjList, True, '') ; // [b]<-- Access Violation[/b]   // Other code intended to loop through objects - Never reached.end ;

    Eurekalog points the error to this line:
    List._StringParam := NameStartWith;

    Code
    procedure TWPCustomRtfEdit.FieldGetList(
      list: TWPTextObjList; FromAllBlock: Boolean = FALSE;
      NameStartWith: string = '');
    begin
      List.Clear;
      List._StringParam := NameStartWith;  
      if FromAllBlock then Memo.RTFData.LoopAllObj(List, LoopFieldsB, nil)
      else Memo.RTFData.LoopAllObj(List, LoopFieldsB, Memo.DisplayedText);
    end;

    What am I doing wrong? Even if there are zero objects, I should get a blank list, and not an Access Violation.

    I need to get list of ALL Hyperlink objects and be able to loop through to conditionally change Source text and changes Source text's color. Any help to accomplish that will be appreciated.

    Thank you

    JayM (occasional WPTools user)

  • Though I can get list of Hyperlink objects and loop through them, I still can't figure out how to conditionally change Font color of each hyperlink, i.e., some hyperlinks need to be shown with Font Color clBlue while others may be shown with font color clRed.

    TWPTextObj.Style and TWPTextObj.StyleName properties are read-only - so, I can't assign font attributes using TextStyle to these properties.

    May be I am approaching this in a totally wrong way and there is a simpler answer that is escaping me because I don't use WP Tools all the time.

    Please help. Thank You.

    JayM

    • Offizieller Beitrag

    Hi,

    Usually a TWPTextObj does not have a style element. But if you create MakeStyle one will be created.

    property Style: TWPTextStyle is readonly, but you can all the TWPTextStyle element procedures, such as ASet to define color or font properties.

    Julian