Thema: Delphi TEdit in Klasse ?

Einzelnen Beitrag anzeigen

Benutzerbild von richard_boderich
richard_boderich

Registriert seit: 21. Jun 2004
Ort: Berlin
1.067 Beiträge
 
Delphi 7 Architect
 
#24

Re: TEdit in Klasse ?

  Alt 8. Mai 2005, 23:38
Moin Hansa,

Also ich habe deinen Beitrag nicht übersehen. ich kann nur nichts mit deinem Vorschlag anfangen. Ich
verstehe nicht wie mir ein Stringgrid bei meinem Problem helfen kann, bzw. ich denke einfach anders als du.

Ich wollte weiter nicht als ein object , das folgende bedingungen und funktionen kapselt:


1. enthaelt 1 Timage
2. enthaelt 2 Tedit
3. enthaelt 1 TStatictext
4. deklariert Variable Mapx,Mapy ->Integer;
5. deklariert Variable Einheitentyp ->String;


4. object ist zur laufzeit verschiebbar
object soll selbst image.left und image.top berechnen aus mapx und mapy (das object soll das selber tun)
5. object soll loeschbar sein

Ich bin kanpp davor aufzugeben. es kostet einfach zu viel zeit und nerven, zu viel neues der ganze Klassenkram , aber ich habs wenigstens versucht

Hau rein,

Richard

//EDIT das war mein code ohne die object implementierung

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, jpeg, XPMan, StdCtrls, ComCtrls, Menus, ToolWin,
  Buttons, JvHtControls, JvGIF;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Timer1: TTimer;
    Panel2: TPanel;
    CoolBar1: TCoolBar;
    ComboBox1: TComboBox;
    BitBtn1: TBitBtn;
    StaticText1: TStaticText;
    XPManifest1: TXPManifest;
    Image2: TImage;
    StaticText2: TStaticText;
    Edit1: TEdit;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);


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

var
  Form1: TForm1;
  dra,helper:boolean;
  terrorspeicherx,terrorspeichery,xx,yy,terrorx,terrory:Integer;
implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Dra=false then statictext1.Caption:='Map X: = '+inttostr(xx)+' '+'Map Y: = '+inttostr(yy);
if (mouse.cursorpos.x > form1.Left) and (mouse.cursorpos.x < form1.Left+form1.width) and
   (mouse.CursorPos.y>form1.Top) and (mouse.CursorPos.y < form1.top+form1.height) And (helper=true) then
   begin
   image1.left:=-terrorx+mouse.cursorpos.x-form1.left;
   image1.top:=-terrory+mouse.cursorpos.y-form1.top;
 // image2.left:=image1.Left+terrorx;
 // image2.top:=image1.Top+terrory;

   end
   else
   begin
    //exit;
   end;


if helper=false then
begin

if (mouse.cursorpos.x<form1.Left) and (image1.left<=30) then image1.left:=image1.left+15;
if (mouse.cursorpos.x>form1.Left+form1.width) and (image1.Left+image1.width>=form1.width-30) then image1.left:=image1.left-15;
if (mouse.cursorpos.y<form1.top) and (image1.top<=30) then image1.top:=image1.top+15;
if (mouse.cursorpos.y>form1.top+form1.height) and (image1.top+image1.height>=form1.height-59)then image1.top:=image1.top-15;
end;

   image2.left:=image1.left+terrorspeicherx;
   image2.top:= image1.top+terrorspeichery; //with map move funktion
   statictext2.Left:= image1.left+terrorspeicherx+50;
   statictext2.top:= image1.top+terrorspeichery+18;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.DoubleBuffered:=true;
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if ssright in shift then
  begin
  terrorx:=+x+4;
  terrory:=+y+30;
  helper:=true;
  dra:=true;
  end;

  if ssleft in shift then
  begin
  terrorspeicherx:=xx-5-image2.width div 2;
  terrorspeichery:=yy-image2.height-5;
   image2.left:=image1.left+terrorspeicherx;
   image2.top:=image1.top+terrorspeichery;
   edit1.Left:=image1.left+terrorspeicherx+50;
   edit1.Top:=image1.top+terrorspeichery+18;
   edit1.Visible:=true;
   edit1.setfocus;
  end;

end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
helper:=false;
dra:=false;
end;


procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
xx:=x+4;
yy:=y+30;
end;

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=VK_RETURN then
begin
edit1.hide;
statictext2.Left:= image1.left+terrorspeicherx+50;
statictext2.top:= image1.top+terrorspeichery+18;
statictext2.caption:=' '+edit1.Text+' ';
statictext2.show;
end;
end;

end.
mfG Richard

Cimmams schrieb "das einzige was an ArmA gut ist, ist die Grafik bis 100m und der Rest ist so unreal wie unsere Demokratie."
  Mit Zitat antworten Zitat