Thema: Delphi Arbeit mit Units

Einzelnen Beitrag anzeigen

Popov
(Gast)

n/a Beiträge
 
#11

Re: Arbeit mit Units

  Alt 14. Jun 2009, 11:31
Was aber ohne Probleme geht ist das:

Unit1:

Delphi-Quellcode:
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  MyDrawListBox(Control, Index, Rect, State);
end;
Unit2:

Delphi-Quellcode:
procedure MyDrawListBox(Control: TWinControl; Index: Integer; Rect: TRect;
  State: TOwnerDrawState);
const
  Col1: array [Boolean] of TColor = (clSilver, clWindow);
  Col2: array [Boolean] of TColor = (clInactiveCaptionText, clWindowText);
begin
  with (Control as TListbox) do
  begin
    if odSelected in State then Canvas.Font.Color := clCaptionText else begin
      Canvas.Brush.Color := Col1[Odd(Index)];
      Canvas.Font.Color := Col2[(Control as TListbox).Enabled];
    end;
    Canvas.TextRect(Rect, Rect.Left, Rect.Top, Items[Index]);
  end;
end;
Hier verbleibt die Prozedur in Unit1, aber der eigentliche Code wird in Unit2 ausgeführt. Die Prozedur in Unit1 dient somit lediglich dazu die zweite Prozedur aufzurufen.
  Mit Zitat antworten Zitat