AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Saubere Programmierung mit Delphi

Ein Thema von Christian18 · begonnen am 15. Mär 2008 · letzter Beitrag vom 16. Mär 2008
 
omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#13

Re: Saubere Programmierung mit Delphi

  Alt 15. Mär 2008, 21:19
Hier mal ein Vorschlag...

Delphi-Quellcode:
unit UBackground;

interface

uses
  Forms, Graphics;

type
  TBackground = class
  private
    FForm : TForm;
    FColor : Array[0..1] of TColor;
    FDistance : Byte;
  public
    constructor Create(AForm: TForm; AColor1, AColor2: TColor; ADistance: Byte);
    procedure Horizontal;
    procedure Vertical;
  end;

implementation

constructor TBackground.Create(AForm: TForm; AColor1, AColor2: TColor; ADistance: Byte);
begin
  FForm:=AForm;
  FColor[0]:=AColor1;
  FColor[1]:=AColor2;
  FDistance:=ADistance;
end;

procedure TBackground.Horizontal;
var i : Integer; // Schleifenvariable
begin
  if assigned(FForm) then begin
    FForm.Color:=FColor[0];
    FForm.Canvas.Pen.Color:=FColor[1];
    i:=0;
    while i <= FForm.ClientHeight do begin
      FForm.Canvas.MoveTo(0, i);
      FForm.Canvas.LineTo(FForm.ClientWidth, i);
      Inc(i, FDistance);
    end;
  end;
end;

procedure TBackground.Vertical;
var i : Integer; // Schleifenvariable
begin
  if assigned(FForm) then begin
    FForm.Color:=FColor[0];
    FForm.Canvas.Pen.Color:=FColor[1];
    i:=0;
    while i <= FForm.ClientWidth do begin
      FForm.Canvas.MoveTo(i, 0);
      FForm.Canvas.LineTo(i, FForm.ClientHeight);
      Inc(i, FDistance);
    end;
  end;
end;

end.
Gruss
Thorsten
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:08 Uhr.
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-2025 by Thomas Breitkreuz