Merhaba arkadaşlar, aşağıdaki kod ile form açıldığında tablo1 de yer alan bilgilere göre form üzerine tablo1 de kaç tane kayıt varsa o kadar panel oluşturuyor. bunlar benim grafik masa düzeninde restaurantta ki masalarım. eğer bu masalar tablo2 de açıksa kırmızı olarak yanıyor. ben bu haliyle kullanıyorum.
bu paneller oluştuktan sonra istediğim paneli tutup form üzerinde herhangi bir yere bırakmak yani yerini değiştirebilmek istiyorum.uğraşıyorum ama bir sonuç alamadım. hareket ettiremedim yani:))
yardımcı olabilirmisiniz nasıl yapabilirim?
procedure TForm19.Button1Click(Sender: TObject);
var
BMrk:String;
y: Variant;
begin
BMrk:=Table1.BookMark;
with table1 do
begin
First;
while not EOF do
begin
table1.Refresh;
table2.Refresh;
x:=TPanel.Create(form19);
x.left:=StrToInt(dbedit2.text);
x.Top:=StrToInt(dbedit3.text);
x.Width:= StrToInt(dbedit4.text);
x.Height:= StrToInt(dbedit5.text);
x.ParentColor:=False;
x.ParentBackground:=False;
x.ParentBiDiMode:=False;
X.Cursor:=crHandPoint;
x.Color:=StrToInt(DBedit20.text);
x.font.size:=StrToInt('10');
x.font.name:='Arial';
x.parent:=PageControl1.Pages[StrToInt(dbedit7.Text)];
x.caption:=dbedit1.text;
x.OnClick:=DugmeClick;
x.ShowHint:=True;
x.OnMouseMove:=xMouseMove;
y :=Table2.Lookup('Masano;Cins;Durum', VarArrayOf ([ x.caption,edit3.text,True]), 'Masano');
if VarIsNull (y)then
begin
end
else
begin
x.color:=StrToInt(edit2.text);
x.Font.Color:=clwhite;
x.Font.Style:=[fsBold,fsunderline];
end;
next;
end;
Table1.Bookmark:=BMrk;
end;
end;
---------------------------------------
alttaki kodla ayrı bir deneme yaptım. paneli form üzerinde istediğim gibi sürükleyebiliyorum ama çalışma anında oluşturduklarım üzerinde (yukarıdaki kodda) bir gelişme sağlayamadım.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Move: Boolean;
P1: Tpoint;
implementation
{$R *.dfm}
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Move :=True;
P1.X := X;
P1.Y := Y;
end;
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if (Move =true) then
begin
if (X > P1.x) then
Panel1.Left := Panel1.Left + (X - P1.x);
if (X < P1.x) then
Panel1.Left := Panel1.Left - (P1.x - X);
if (Y > P1.y) then
Panel1.Top := Panel1.Top + (Y - P1.y);
if (Y < P1.y) then
Panel1.Top := Panel1.Top - (P1.y - Y);
end;
end;
procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Move:=false;
end;
Çalışma anında FORM üzerinde oluşturduğum panellerde drag drop yapılabilir mi?
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
Re: Çalışma anında FORM üzerinde oluşturduğum panellerde drag drop yapılabilir mi?
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure PanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure PanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
public
end;
var
Form1: TForm1;
Move: Boolean;
P1: Tpoint;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x:Tpanel;
begin
x:=TPanel.Create(form1);
x.left:=15;
x.Top:=15;
x.Width:= 250;
x.Height:= 250;
x.ParentColor:=False;
x.ParentBackground:=False;
x.ParentBiDiMode:=False;
X.Cursor:=crHandPoint;
//x.Color:=StrToInt(DBedit20.text);
x.font.size:=StrToInt('10');
x.font.name:='Arial';
x.parent:=form1;
//x.caption:=dbedit1.text;
//x.OnClick:=DugmeClick;
x.ShowHint:=True;
x.OnMouseMove:=PanelMouseMove;
x.OnMouseDown:=PanelMouseDown;
x.OnMouseUp:=PanelMouseUp;
end;
procedure TForm1.PanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Move :=True;
P1.X := X;
P1.Y := Y;
end;
procedure TForm1.PanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if (Move =true) then
begin
if (X > P1.x) then
Tpanel(Sender).Left := Tpanel(Sender).Left + (X - P1.x);
if (X < P1.x) then
Tpanel(Sender).Left := Tpanel(Sender).Left - (P1.x - X);
if (Y > P1.y) then
Tpanel(Sender).Top := Tpanel(Sender).Top + (Y - P1.y);
if (Y < P1.y) then
Tpanel(Sender).Top := Tpanel(Sender).Top - (P1.y - Y);
end;
end;
procedure TForm1.PanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Move:=false;
end;
end.
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure PanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure PanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
public
end;
var
Form1: TForm1;
Move: Boolean;
P1: Tpoint;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x:Tpanel;
begin
x:=TPanel.Create(form1);
x.left:=15;
x.Top:=15;
x.Width:= 250;
x.Height:= 250;
x.ParentColor:=False;
x.ParentBackground:=False;
x.ParentBiDiMode:=False;
X.Cursor:=crHandPoint;
//x.Color:=StrToInt(DBedit20.text);
x.font.size:=StrToInt('10');
x.font.name:='Arial';
x.parent:=form1;
//x.caption:=dbedit1.text;
//x.OnClick:=DugmeClick;
x.ShowHint:=True;
x.OnMouseMove:=PanelMouseMove;
x.OnMouseDown:=PanelMouseDown;
x.OnMouseUp:=PanelMouseUp;
end;
procedure TForm1.PanelMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Move :=True;
P1.X := X;
P1.Y := Y;
end;
procedure TForm1.PanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if (Move =true) then
begin
if (X > P1.x) then
Tpanel(Sender).Left := Tpanel(Sender).Left + (X - P1.x);
if (X < P1.x) then
Tpanel(Sender).Left := Tpanel(Sender).Left - (P1.x - X);
if (Y > P1.y) then
Tpanel(Sender).Top := Tpanel(Sender).Top + (Y - P1.y);
if (Y < P1.y) then
Tpanel(Sender).Top := Tpanel(Sender).Top - (P1.y - Y);
end;
end;
procedure TForm1.PanelMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Move:=false;
end;
end.
Re: Çalışma anında FORM üzerinde oluşturduğum panellerde drag drop yapılabilir mi?
Mesaj yazarken "tag" ları kullanırsanız, yazdıklarınız daha anlaşılır olur. Sorunuz başkalarına da yardımcı olur. Google aramalarında sonuçlarda görüneceğini unutmayın.
ZAGOR TENAY TÜRK'tür... TÜRK kalacak...
Zoru başarırım, İmkansız zaman alır
FreeMan 35.5
Soru sormaya üşenmiyorsan, sorunun çözümünü yazmaya da üşenme !!!
Zoru başarırım, İmkansız zaman alır
FreeMan 35.5
Soru sormaya üşenmiyorsan, sorunun çözümünü yazmaya da üşenme !!!
Re: Çalışma anında FORM üzerinde oluşturduğum panellerde drag drop yapılabilir mi?
JVCL bileşenlerinde Tjvpanel vardı yanlış hatırlamıyorsam. Form üzerinde istediğiniz yere taşınıyordu. Bi deneyin isterseniz.
Erbab-ı kemâli çekemez nakıs olan, rencide olur Dide-i Huffaş ziyadan....
Re: Çalışma anında FORM üzerinde oluşturduğum panellerde drag drop yapılabilir mi?
Merhaba, buradaki çözüm, dinamik oluşturulan panelin adının statik olarak panel1 şeklinde aranması yerine joker tanımlama yapmaktır.
@onurx zaten çözümü sunmuş. Panel1 yazan yerlere TPanel(sender) yazarak sorun giderilmiş.
Burada soruyu soranın konunun çözüldüğünü deklere etmemiş olmasından kaynaklı önerilerin gelmesi doğal ancak buna da dikkat edilirse başlıklar gereksiz yere uzamaz diye değerlendiriyorum.
Üçüncü parti bileşenler gerek sürüm güncellik takibinde yavaşlık, gerekse platform uyumu konusunda olası kısıtlar nedeniyle çözümsüzlük durumunda başvurulan kaynaklardır.
@onurx zaten çözümü sunmuş. Panel1 yazan yerlere TPanel(sender) yazarak sorun giderilmiş.
Burada soruyu soranın konunun çözüldüğünü deklere etmemiş olmasından kaynaklı önerilerin gelmesi doğal ancak buna da dikkat edilirse başlıklar gereksiz yere uzamaz diye değerlendiriyorum.
Üçüncü parti bileşenler gerek sürüm güncellik takibinde yavaşlık, gerekse platform uyumu konusunda olası kısıtlar nedeniyle çözümsüzlük durumunda başvurulan kaynaklardır.