Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Arbeit mit Units (https://www.delphipraxis.net/135605-arbeit-mit-units.html)

Popov 14. Jun 2009 12:31

Re: Arbeit mit Units
 
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.


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:47 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz