AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Problem mit "Programm" für die Schule
Thema durchsuchen
Ansicht
Themen-Optionen

Problem mit "Programm" für die Schule

Ein Thema von just.cause · begonnen am 28. Apr 2009 · letzter Beitrag vom 5. Mai 2009
Antwort Antwort
just.cause

Registriert seit: 28. Apr 2009
8 Beiträge
 
#1

Re: Problem mit "Programm" für die Schule

  Alt 3. Mai 2009, 13:51
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Shape1: TShape;
    Shape2: TShape;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Image1: TImage;
    procedure keypress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);

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

  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



procedure TForm1.keypress(Sender: TObject; var Key: Char);
var d:real;
begin
d:=sqrt((shape1.Left - shape2.Left)*(shape1.Left - shape2.Left)+(shape1.Top - shape2.top)*(shape1.Top - shape2.top));
if (key ='s') and (d>=shape1.width) then shape1.top:=shape1.top +10;
if (key ='w') and (d>=shape1.Width) then shape1.top:=shape1.top -10;
if (key ='d') and (d>=shape1.Height) then shape1.Left:=shape1.Left +10;
if (key ='a') and (d>=shape1.Height) then shape1.left:=shape1.left -10;

label1.Caption:=inttostr(shape1.top);
label2.Caption:=inttostr(shape1.Left);

if (key ='k') and (d>=shape1.width)then shape2.top:=shape2.top +10;
if (key ='i') and (d>=shape1.width)then shape2.top:=shape2.top -10;
if (key ='l') and (d>=shape1.Height)then shape2.Left:=shape2.Left +10;
if (key ='j') and (d>=shape1.Height)then shape2.left:=shape2.left -10;

label3.Caption:=inttostr(shape2.top);
label4.Caption:=inttostr(shape2.Left);

end;



procedure TForm1.FormCreate(Sender: TObject);
var d:real;
begin
d:=sqrt((shape1.Left - shape2.Left)*(shape1.Left - shape2.Left)+(shape1.Top - shape2.top)*(shape1.Top - shape2.top));
if (d>=shape1.width) or (d>=shape1.height) then showmessage ('tagged!');
end;

end.
[edit=mkinzler]Delphi-Tag ergänzt. das nächste Mal bitte selber machen. Mfg, mkinzler[/edit]
  Mit Zitat antworten Zitat
Antwort Antwort


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 06:39 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