I'm working on an editor with a TWPRichText component. I have buttons for bold, italics, and underline. The code I have for underlining is:
with Page.CurrAttr do begin if (afsUnderline in Style) then Style := Style - [afsUnderline] else Style := Style + [afsUnderline]; end;
The bold and italics buttons' codes are identical, substituting afsBold and afsItalic where appropriate. The selelected text will show bold or italics immediately. Selected text will not show the underline during the current editing session. The underline attribute has been applied, as I'm prompted to save the file when exiting, and the Undo button is activated. When I close the file and then reopen it, the underline is there. On that second edit, if I remove the underline and reapply it, the underline will show immediately.
I'm using WPTools Standard 5.303, BDS 2006 with Update 2 (Win32 Personality), Windows XP SP2. The same problem occurred with the previous version as well. I looked at some archived project files from about 2005, and I seem to have had a similar problem with underlining then, too.
In unit WPCTRRich, the procedure TWPCustomRichText.DoUpdateCharAttr has the following code for underlining:
a := CurrAttr.UnderlineMode; UpdateIconCheck(WPI_GR_STYLE, WPI_CO_UNDER, (afsUnderline in NewStyle) or ((a > 0) and (a < WPUND_NoLine)));
This is completely different than the code for any other attributes- they don't have anything corresponding to
or ((a > 0) and (a < WPUND_NoLine)))
at the ends of their lines. I experimented by making the underline code the same for the other attributes, but it didn't help. When I right-click on afsUnderline in my pas file and try to Find Declaration, an error box states that WPRTEDefs.pas cannot be located, but the dcu file is located in the WPTools directory. The search path includes that directory.
I've tried adding Page.ReformatAll and Page.Refresh without success, and bold and italics don't require those lines after them.
Any ideas?
Thanks in advance for your time.