Zitat von mphilbrick(1) In the HyperlinkEvent I would like to change the color of the hyperlink text to indicate to the user that this hyperlink has already been selected. This behavior is consistent with web-browser behavior.
How do I do this in the Hyperlink event code?]
Since there was no function for this I added one to unit WPRich.PAS. (Will be in V4.20a and later) If you paste the following code you can use it in the HyperlinkEvent:
procedure TWPCustomRichText.ModifyThisHyperlinkColor(const NewColor: TColor);
var
pa: PTAttr;
lin: PTLine;
col, i: Integer;
DisableIt: Boolean;
begin
if FHyperPar = nil then
begin
FHyperPar := Memo.active_paragraph;
FHyperLin := Memo.active_line;
FHyperCP := Memo.cursor_pos;
DisableIt := TRUE;
end else DisableIt := FALSE;
if (FHyperPar <> nil) and (FHyperLin <> nil) and (FHyperLin^.pa <> nil) then
begin
lin := FHyperLin;
pa := lin^.pa;
inc(pa, FHyperCP);
i := FHyperCP;
if (NewColor=clWindow) or (NewColor=clNone) then
col := 0
else col := CurrAttr.ColorToNr(NewColor, true);
while (afsHyperlink in pa^.style) and
not (afsHidden in pa^.style) do
begin
if i >= lin^.plen then
begin
i := 0;
lin := lin^.next;
if lin = nil then break;
pa := lin^.pa;
end;
pa^.Color := col;
inc(pa);
inc(i);
end;
RePaint;
end;
if DisableIt then FHyperPar := nil;
end;
Alles anzeigen
Zitat von mphilbrick(2) I want to prevent the user from being able to select the same hyperlink twice. What is the best way to mark the hyperlink so I can check to see if it was already selected? If the color is changed as indicated above, what code could I use to determine the current color of the clicked hyperlink in the HyperlinkEvent code?
You can modify the code above to remove the afsHyperlink style. That would solve the problem, too : exclude(pa^.style, afsHyperlink)
Julian