Delphi 2007, WPTools [V5.51], Windows Vista
This question is [sort of] continuation of: http://wpcubed.com/forum/viewtopic.php?t=6130
Context: In my app, user can select an item from a Popup Menu when he/she clicks on a Hyperlink in WPEditor. The Hyperlink's color is set based on user selection (see Julian's excellent response re: Hyperlink --> Popup Menu:
http://wpcubed.com/forum/viewtopi…hyperlink+popup)
Problem: WPEditor can have hyperlinks in different colors based on user selection (e.g., Unmodified = clBlue, UserModified = clNavy, if Embedded text is "Delete Para" then clRed, etc). Problems is that Hyperlink colors are lost after original text is saved and restored (see code below).
User can "Preview" the output as "PlainText" and on closing Preview, returns to WPEditor. I save WPEditors contents with "AsString", modify contents for preview and finally restore the original contents as shown in the abbreviated code below.
In form initialization code:
With WPEditor.HyperlinkTextAttr do begin TextColor := clBlue ; {Default color } {Following must be false so that we can change font color and underline color in code} UseTextColor := false ; UseUnderlineColor := false ;end;
"Preview" button.OnClick() -- Abbreviated
With WPEditor do begin { Keep a Copy of WPEditor's Text and CPPos, etc because we are about to change it. Reset back to normal when exiting the preview mode } wpPreview_EditorTextAsString := WPEditor.AsString ; wpPreview_CPPos := CPPosition ; wpPreviewTopLineIndex := TopOffset ; ... {modify WPEditor's contents for preview} { Display modified text in TMemo as pain text} aMemo.Text := WPEditor.Text ;end ;
"Close Preview" button.OnClick() -- Abbreviated
With WPItemText do begin
{Restore original contents in WPEditor }
WPEditor.AsString := wpPreview_EditorTextAsString ;
CPPosition := wpPreview_CPPos ;
TopOffset := wpPreviewTopLineIndex ;
{Make no difference to the problem how WPEditor is repainted}
ReformatALL(false, false) ;
// DelayedReformat ;
end;
Alles anzeigen
Interestingly, all text including Hyperlink text and Hyperlink underline color is changed to clBlack (note that default color for Hyperlink is set to clBlue).
How can we preserve the original Hyperlink color after executing code like above? Any work-arounds?
Thank You
JayM