mause kordinatları

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
abdulkadir
Kıdemli Üye
Mesajlar: 489
Kayıt: 13 Eyl 2003 09:10
Konum: istanbul
İletişim:

mause kordinatları

Mesaj gönderen abdulkadir »

herkese selam

Arkadaslar bir form üzerinde 10 edit ve 10 button var
ben edit1 e cift tıklayınca ve button 1 tek tıklayınca o anki kordinatları almaya calısıyorum

hemen tıklanan yerde bir ufak form gösterecegim
önce global var bloguna

Kod: Tümünü seç

var
  Form1: TForm1;
    AKL_ListX, AKL_ListY: Integer;//formun acılacagı yer
ve sonra ApplicationEvents1Message olayına

Kod: Tümünü seç

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
 var
  Component : TComponent ;
  i : integer ;
begin
   Case Msg.message Of
WM_LBUTTONDOWN:// tek tıklama
 begin
    for i := 0 to ComponentCount - 1 do begin
     Component:= Components[i] ;
      if Component is TButton then begin
       if TButton(Component).Name='Button2' then //lazım
        if PtInRect(TButton(Component).BoundsRect, ScreenToClient(Msg.pt))  then
         begin
     AKL_ListX:=Msg.pt.x; //kordinatları gönder
     AKL_ListY:=Msg.pt.y;
     ShowMessage(' y : '+IntToStr(AKL_ListX) +' x : ' +IntToStr(AKL_ListY) );
      end;
     end;
   end;
  end;
 WM_LBUTTONDBLCLK:
 begin
    for i := 0 to ComponentCount - 1 do begin
     Component:= Components[i] ;
      if Component is TEdit then begin
       if TEdit(Component).Name='Edit1' then // lazım
        if PtInRect(TEdit(Component).BoundsRect, ScreenToClient(Msg.pt))  then
         begin
     AKL_ListX:=Msg.pt.x; //kordinatları gönder
     AKL_ListY:=Msg.pt.y;
     ShowMessage(' yeee : '+IntToStr(AKL_ListX) +' xeee : ' +IntToStr(AKL_ListY) );
      end;
     end;
   end;
  end;
end;
end;
bir ara yine bu sistemle yapmıstım ama simdi yapamadım
ne eksik hatırlamıyorum veya ve yanlıs

hayırlı işler
Kullanıcı avatarı
gkimirti
Admin
Mesajlar: 1956
Kayıt: 02 Eyl 2003 04:44
Konum: İstanbul

Mesaj gönderen gkimirti »

butonlara ortak bir click yordamı yaz icine
ShowMessage('x:'+IntToStr(Mouse.CursorPos.x)+','+'y:'+IntToStr(Mouse.CursorPos.y))
aynı seyi editlerin dblclick yordamı icin yaz
ÜŞENME,ERTELEME,VAZGEÇME
mcihad
Üye
Mesajlar: 283
Kayıt: 18 Tem 2003 03:28
Konum: Sivas

Mesaj gönderen mcihad »

private kısmında

Kod: Tümünü seç

procedure tikla(Sender:TObject);
//CTRL+SHIFT+C ile kodu oluşturun

Kod: Tümünü seç

procedure  TForm1.tikla(Sender:TObject);
var Nokta:TPoint
begin
  GetCursorPos(Nokta);{Nokta Adlı Değişkene Mouse Pozisyonu Atanır Nokta.X Eksen Xcoordinatı Nokta.Y Eksen Y Kordinatı}
end;

for a:=0 to form1.componentcount-1 do
begin
  if ((form1.components[a] is TEdit) or (form1.components[a] is TButton)) then
    begin
      (form1.components[a] as TEdit).OnClick=Tikla;
      (form1.components[a] as TButton).OnClick=Tikla;
    end;
end;
//Sanırım Bu Kod İşini Görür Yalnız GetCursorPos() Fonksiyonu Ekranın sol ve üst kısmını referans alır formu değil
Bize iyilik yaraşır.
abdulkadir
Kıdemli Üye
Mesajlar: 489
Kayıt: 13 Eyl 2003 09:10
Konum: istanbul
İletişim:

Mesaj gönderen abdulkadir »

tesekkür ederim
gökmen hocamın yazdıgı işimi görecek sanırım

kolay gelsin
Cevapla