Eger Program çalışıyorsa Form2.show olayı

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
carsoft
Üye
Mesajlar: 138
Kayıt: 01 Ağu 2014 12:27

Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen carsoft »

Anaform ve form2 var program sadece bir defa çalışıyor MUTEX kullandım.

ama sorunum windows sağ menüye ekledim oradan çağırıyorum programı ama anaform ile açılıyor ben
anaform'daki buton1 'e nasıl tıklatabilirim.
Kullanıcı avatarı
brs
Üye
Mesajlar: 626
Kayıt: 04 Eki 2012 03:52

Re: Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen brs »

Kod: Tümünü seç

procedure TForm2.Button1Click(Sender: TObject);
begin
AnaForm.Button2.Click;
end;
İşi bilen yardım eder, az bilen akıl verir, bilmeyen eleştirir, yapamayan ise çamur atar...
carsoft
Üye
Mesajlar: 138
Kayıt: 01 Ağu 2014 12:27

Re: Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen carsoft »

ben exe den diger exe deki butana tıklamak istiyorum ama olmuyor problem nerede anlamadım

Kod: Tümünü seç

procedure TForm1.Button1Click(Sender: TObject); 
var 
  h: HWND; 
begin 
  h := FindWindowEx(0, 0, nil, 'Project1'); // a parent window 
  h := FindWindowEx(h, 0, 'Button', 'Kapat'); 
  SendMessage(h, BM_CLICK, 0, 0);  
end; 
anonymousdelphicoder
Üye
Mesajlar: 152
Kayıt: 16 May 2014 11:23

Re: Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen anonymousdelphicoder »

Kardesim cok basit ana formunda bir mesaj hazirla
Const
PM_MYMESSAGE = 1000 + 1;
Procedure PMMyMessage(var Message:Tmessage); message PM_MYMESSAGE;

Bunu ana formda tanimla ve mutex ile calisan uygulaman var ise yukarida findwindow ile arat ana formu ve SendMessage ile formun handlesine PM_MYMESSAGE yani 1000 + 1 gonder otomatik olarak ana formundaki bu prosedur calisacaktir ve istedigin islemi yaptir. Mobilim aciklayici yazamadim kusura bakma.
anonymousdelphicoder
Üye
Mesajlar: 152
Kayıt: 16 May 2014 11:23

Re: Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen anonymousdelphicoder »

Ayrica FindWindowsEx deki class ismi Button degil TButton dur dikkat et ;)

Delphide ki butun hiyerarsi (classlar icin soyluyorum) Interface ler ve pointerlar haric T prefix ile baslar buda Type anlamina gelir.
carsoft
Üye
Mesajlar: 138
Kayıt: 01 Ağu 2014 12:27

Re: Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen carsoft »

teşekkürler bir örnek verebilirmisin
carsoft
Üye
Mesajlar: 138
Kayıt: 01 Ağu 2014 12:27

Re: Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen carsoft »

tamam dedigin gibi yaptım ama olmadı

1- exe

Kod: Tümünü seç

const
  WM_MY_MESSAGE = WM_USER + 1;

Kod: Tümünü seç

procedure TForm1.Button1Click(Sender: TObject);
var
  h: HWND;
begin
  h := FindWindow(nil, 'Project1');
  h := FindWindowEx(h, 0, 'TButton', 'Button2'); 
  if IsWindow(h) then
    SendMessage(h, WM_MBUTTONDBLCLK, 0, 0);
end;

Ana exe

Kod: Tümünü seç

const
  WM_MY_MESSAGE = WM_USER + 1;

Kod: Tümünü seç

protected
    procedure WndProc(var Message: TMessage); override;

Kod: Tümünü seç

procedure TForm1.WndProc(var Message: TMessage);
begin
  inherited;
  case Message.Msg of
    WM_MBUTTONDBLCLK:
     Button2.click;
  end;
end;
carsoft
Üye
Mesajlar: 138
Kayıt: 01 Ağu 2014 12:27

Re: Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen carsoft »

Çok teşşekürler iyi fikir çalıştı
anonymousdelphicoder
Üye
Mesajlar: 152
Kayıt: 16 May 2014 11:23

Re: Eger Program çalışıyorsa Form2.show olayı

Mesaj gönderen anonymousdelphicoder »

Programda Form1 in içinde control farketmeksizin Double Click yaptıgında button2 tetiklenir pek doğru bir kullanım değil wndproc yerine verdiğim message prosedürünü kullansaydınız daha doğru olabilirdi.
Cevapla