Q:

Change color of ListBox Item when Clicked on this Item

So I have a ListBox on form, which consists of different links, all of them are blue and underlined (like html links, you know). When user clicks one of the Items(links), it opens in a default browser, but I also want that particular link to change color to purple. Here's what I have in OnClick procedure now:
procedure TForm1.ListBox1Click(Sender: TObject);

begin
ShellExecute(Handle, 'open', PAnsiChar(ListBox1.Items[ListBox1.ItemIndex]), nil, nil, SW_SHOWNORMAL);
end;

A:

Your problem boils down to how to draw the list with different fonts settings for each item. You need to do the following:

Set the Style property of the list box to lbOwnerDrawFixed.
Handle the OnDrawItem event of the list box to draw each item.

Your OnDrawItem event will draw the item in a font to indicate whether or not the item has been clicked already. You can manage that logic I presume. I will show a simple example that draws items differently depending on the Index of the item.
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  ListBox: TListBox;
  Canvas: TCanvas;
begin
  ListBox := Control as TListBox;
  Canvas := ListBox.Canvas;

  // clear the destination rectangle
  Canvas.FillRect(Rect);

  // prepare the font style and color
  Canvas.Font.Style := [fsUnderline];
  if Odd(Index) then
    Canvas.Font.Color := clBlue
  else
    Canvas.Font.Color := clPurple;

  // draw the text
  Canvas.TextOut(Rect.Left, Rect.Top, ListBox.Items[Index]);

  // and the focus rect
  if odFocused in State then
    Canvas.DrawFocusRect(Rect);
end;

