Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Detekcija WM_CLICK na drugom prozoru

[es] :: Pascal / Delphi / Kylix :: Detekcija WM_CLICK na drugom prozoru

[ Pregleda: 1616 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

gajo2
Budapest

Član broj: 62614
Poruke: 518
*.ptt.yu.

Sajt: b.flyingoranges.com


+117 Profil

icon Detekcija WM_CLICK na drugom prozoru16.11.2006. u 20:47 - pre 212 meseci
Pozdrav,

Zanima me da li je moguce neko presresti poruku WM_CLICK upucen jednom dugmetu koji nije na mom prozoru? Takodje, da li bi bilo moguce da, nakon sto detektujem tu poruku, da uradim da je dugme uopste ne dobije?

Evo konkretan primer: otvorim Run dijalog i kliknem na dugme OK. Moja aplikacija presrece poruku za click, i recimo prikaze neku poruku. Nakon toga nece proslediti poruku dugmetu, tj. kao da dugme nije ni pritisnuto.. Pretpostavimo da znam handle i prozora i dugmeta.
 
Odgovor na temu

gajo2
Budapest

Član broj: 62614
Poruke: 518
*.ptt.yu.

Sajt: b.flyingoranges.com


+117 Profil

icon Re: Detekcija WM_CLICK na drugom prozoru16.11.2006. u 21:25 - pre 212 meseci
Hmm nasao sam neki primer kako se ovo radi, postovacu i ceo kod, medjutim mislim da sam stigao do neresivog problema. Naime na nekom forumu sam procitao sledece:
Citat:
I have also found out that GWL_WNDPROC in Windows NT/2000: You cannot change
this attribute if the window does not belong to the same process as the calling
thread.

Znaci pod XP-om je nemoguce presretati poruke zbog security-ja

Ili mozda neko ipak zna nacin?

Evo koda koji sam nasao. Uzima handle od nekog prozora i instalira novu hook funkciju za taj prozor. Onda ti mozes obraditi koje god poruke zelis:
Code:
unit WinProc1;

interface

uses
{$IFDEF WIN32}
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DB, DBTables;
{$ELSE}
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,
  Controls, Forms, Dialogs, DB, DBTables, Grids, DBGrids;
{$ENDIF}

type
  TForm1 = class(TForm)
    DBGrid1: TDBGrid;
    Table1: TTable;
    DataSource1: TDataSource;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

type
{$IFDEF WIN32}
  WParameter = LongInt;
{$ELSE}
  WParameter = Word;
{$ENDIF}
  LParameter = LongInt;

{Declare a variable to hold the window procedure we are replacing}
var
  OldWindowProc : Pointer;

function NewWindowProc(WindowHandle : hWnd;
                       TheMessage   : WParameter;
                       ParamW       : WParameter;
                       ParamL       : LParameter) : LongInt
{$IFDEF WIN32} stdcall; {$ELSE} ; export; {$ENDIF}
begin

{ Process the message of your choice here }
  if TheMessage = WM_VSCROLL then begin
    ShowMessage('The vertical scrollbar is scrolling!');
  end;

{ Exit here and return zero if you want     }
{ to stop further processing of the message }

{ Call the old Window procedure to }
{ allow processing of the message. }
  NewWindowProc := CallWindowProc(OldWindowProc,
                                  WindowHandle,
                                  TheMessage,
                                  ParamW,
                                  ParamL);
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
{ Set the new window procedure for the control }
{ and remember the old window procedure.       }
  OldWindowProc := Pointer(SetWindowLong(OtherHandle,
                                         GWL_WNDPROC,
                                         LongInt(
NewWindowProc)));
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
{ Set the window procedure back }
{ to the old window procedure.  }
  SetWindowLong(OtherHandle,
                GWL_WNDPROC,
                LongInt(OldWindowProc));

end;

end.


(*
{ The program's main source file }
program WinProc;

uses
  Forms,
  WinProc1 in 'WinProc1.pas' {Form1};

{$R *.RES}

begin
{$IFDEF WIN32}
  Application.Initialize;
{$ENDIF}
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
*)

{ end of ti }
 
Odgovor na temu

savkic
Igor Savkić

Moderator
Član broj: 92186
Poruke: 2739



+92 Profil

icon Re: Detekcija WM_CLICK na drugom prozoru16.11.2006. u 23:21 - pre 212 meseci
> Zanima me da li je moguce neko presresti poruku WM_CLICK upucen jednom dugmetu koji nije na mom prozoru? Takodje, da li bi bilo moguce da,
> nakon sto detektujem tu poruku, da uradim da je dugme uopste ne dobije?

Moraš hookovati mouse poruke, pogledaj SetWindowsHookEx, posebno WH_MOUSE i WH_MOUSE_LL.
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: Detekcija WM_CLICK na drugom prozoru

[ Pregleda: 1616 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.