CPCharAttr property

Applies to
TWPCustomRtfEdit

Declaration
property CPCharAttr: Cardinal;

Description
This property retrieves the number of the character attribute at the cursor position. Usually you cannot do much with this number since it is used internally by the RTF engine, but it 2 cases it makes sense to read this property: a) if you want to detect if a character has no character attribute you can compare the value with 0: This example assigns a font and a color to the text which does not have a character attribute.
  WPRichText1.CPPosition := 0;
  repeat
      if (WPRichText1.CPCharAttr and cafsALL)=0 then
      begin
         WPRichText1.CPAttr.BeginUpdate;
         WPRichText1.CPAttr.FontName := 'Courier New';
         WPRichText1.CPAttr.Color := WPRichText1.GetColorNr(clRed);
         WPRichText1.CPAttr.EndUpdate;
      end;
  until not WPRichText1.CPMoveNext;
  WPRichText1.Refresh;

b) You can assign and delete the special flags which can be attached to any character. They are stored in the highest byte of the CharAttr value. The possible values are:
cafsHyphen = $01000000; // assigned by reader or Ctrl+minus, break here
cafsWasChecked = $02000000; // used by spellcheck routine - don't check again
cafsMisSpelled = $04000000; // used by spellcheck routine - red line
cafsMisSpelled2 = $08000000; // used by spellcheck routine - green line
cafsInsertedText = $10000000; // reserved for WPTOOLS PREMIUM
cafsDeletedText = $20000000; // reserved for WPTOOLS PREMIUM
cafsWordHighlight = $40000000; // highlighted
cafsDelete = $80000000; // Text is marked for deletion
cafsALL = $FF000000;
cafsNONE = $00FFFFFF;

Category
CP-Props


Copyright (C) by WPCUBED GmbH - Munich
http://www.wpcubed.com