Einzelnen Beitrag anzeigen

Deven

Registriert seit: 27. Jun 2003
49 Beiträge
 
Delphi 7 Enterprise
 
#1

Form2.Showmodal = mrok oder sowas :) HILFE!

  Alt 22. Sep 2003, 19:21
Hallo zusammen!

Ich habe wieder ein problem!

warum läuft dieses programm nicht?


Unit1
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Menus;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Beenden1: TMenuItem;
    Neu1: TMenuItem;
    Button2: TButton;
    procedure Beenden1Click(Sender: TObject);
    procedure Neu1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  x:integer;

implementation

uses Unit2;

{$R *.DFM}

//Menü Beenden-Button
procedure TForm1.Beenden1Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Neu1Click(Sender: TObject);
   var
   y,i,a: Integer;
const
   NamePrefix = 'Panel';
begin
Form2.showmodal;

if (Form2.ShowModal = mrOK) then
  begin

x := Form2.ComboBox1.ItemIndex;

Case x Of

    1: begin
        a := 10;

        for i := 1 to 2 do begin
        TPanel.Create(Self).Name := NamePrefix + IntToStr(i);
        with TPanel(FindComponent(NamePrefix + IntToStr(i))) do
         begin
          width := 120;
          height := 120;
          Left := 10;
          Top := a;
          a := a +130;
          Parent := self;
         end;
        end;

        a := 10;
        for i := 1 to 2 do begin
        TPanel.Create(Self).Name := NamePrefix + IntToStr(i);
        with TPanel(FindComponent(NamePrefix + IntToStr(i))) do
         begin
          width := 120;
          height := 120;
          Left := 140;
          Top := a;
          a := a +130;
          Parent := self;
         end;
        end;
       end;

    2: begin
       ShowMessage('Hallo 2');
       end;
    3: begin
       ShowMessage('Hallo 3');
       end;
    4: begin
       ShowMessage('Hallo 4');
       end;
 end;


  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var a,i :integer;
const
   NamePrefix = 'Panel';
begin
a := 10;

        for i := 1 to 2 do begin
        TPanel.Create(Self).Name := NamePrefix + IntToStr(i);
        with TPanel(FindComponent(NamePrefix + IntToStr(i))) do
         begin
          width := 120;
          height := 120;
          Left := 10;
          Top := a;
          a := a +130;
          Parent := self;
         end;
        end;

        a := 10;
        for i := 3 to 4 do begin
        TPanel.Create(Self).Name := NamePrefix + IntToStr(i);
        with TPanel(FindComponent(NamePrefix + IntToStr(i))) do
         begin
          width := 120;
          height := 120;
          Left := 140;
          Top := a;
          a := a +130;
          Parent := self;
         end;
        end;
end;

end.
Unit2
Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Menus, ExtCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    ComboBox1: TComboBox;
    Panel1: TPanel;
    Image1: TImage;
    procedure ComboBox1Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);


  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.DFM}

procedure TForm2.ComboBox1Change(Sender: TObject);
var x:integer;
begin
x := ComboBox1.ItemIndex;

Case x of
  0: begin
      Image1.Picture.LoadFromFile ('bilder/leer karten.bmp');
     end;
  1: begin
      Image1.Picture.LoadFromFile ('bilder/4 karten.bmp');
     end;
  2: begin
      Image1.Picture.LoadFromFile ('bilder/16 karten.bmp');
     end;
  3: begin
      Image1.Picture.LoadFromFile ('bilder/36 karten.bmp');
     end;
  4: begin
      Image1.Picture.LoadFromFile ('bilder/64 karten.bmp');
     end;
end;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
ModalResult := mrOK;
end;

end.
Habs auch noch unten dran gebackt

Bitte helft mich *snief*
Angehängte Dateien
Dateityp: zip test2.zip (244,2 KB, 8x aufgerufen)
  Mit Zitat antworten Zitat