Einzelnen Beitrag anzeigen

Benutzerbild von TheMiller
TheMiller

Registriert seit: 19. Mai 2003
Ort: Gründau
2.480 Beiträge
 
Delphi XE7 Architect
 
#9

Re: Form überall wiederverwenden? Dafür Unit?

  Alt 27. Jan 2009, 17:32
Hallo,

hier mal meine Unit "ProgUtils". (Sie ist eine Library für Codestücke, die ich im ganzen Programm (mehrere PlugIns (DLLForms)) immer wieder verwende)

Delphi-Quellcode:
unit ProgUtils;

interface

uses
  StdCtrls, ComCtrls, DB, ZAbstractRODataset, ZAbstractDataset, ZDataset,
  ZConnection, Graphics, SysUtils, DumbCrypt, Messages, Dialogs, Forms,
  Classes;

  function AssignConfigFile(filename: String): Boolean;
  function InitDBConnection(ZConnection: TZConnection): Boolean;

type
  TSearchContactForm = class(TForm)
    SearchField: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure SearchFieldKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private

  public

  end;


  TSettings = record
    skin: String[100];
    color: TColor;
    boxcolor: TColor;
    logo: String[255];
    winstart: Boolean;
    host: String[100];
    port: Integer;
    Name: String[30];
    User: String[30];
    Pass: String[50];
  end;

var
  fSettings: file of TSettings;
  dSettings: TSettings;

implementation

function AssignConfigFile(filename: String): Boolean;
begin
  {...}
end;

function InitDBConnection(ZConnection: TZConnection): Boolean;
begin
  {...}
end;

procedure TSearchContactForm.SearchFieldKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  ShowMessage('SD');
end;

procedure TSearchContactForm.FormCreate(Sender: TObject);
var
  Form1: TForm;
  SearchField: TEdit;
begin
  Form1:=TSearchContactForm.Create(nil);
  with Form1 do
  begin
    Left:=202;
    Top:=111;
    BorderStyle:=bsNone;
    Caption := 'Adresssuche';
    ClientHeight := 543;
    ClientWidth := 655;
    Color := clWhite;
    Font.Color := clWindowText;
    Font.Height := -11;
    Font.Name := 'MS Sans Serif';
    Font.Style := [];
    KeyPreview := True;
    OldCreateOrder := False;
    PixelsPerInch := 96;
  end;

  SearchField:=TEdit.Create(nil);
  with SearchField do
  begin
    Left := 64;
    Top := 16;
    Width := 225;
    Height := 21;
    TabOrder := 1;
    //SearchField:=SearchFieldKeyDown(nil);
  end;
end;

end.
  Mit Zitat antworten Zitat