![]() |
AW: Fremdes Fenster unverschiebbar (Wie erhalte ich die Events?)
Ja Ein Hook auf die WndProc sollte dich da ein wenig weiter bringen. Hab mal ebend gesucht, aber nirgends was vernünftiges in Delphi gefunden!
![]() Dann gibs zu Hooks allgemein noch das: ![]() Vllt reicht dir das schon um weiter zu kommen. Zitat:
|
AW: Fremdes Fenster unverschiebbar (Wie erhalte ich die Events?)
Das mit dem globalen Hook (WH_CALLWNDPROC) würde mich ja mal brennend interessieren, allerdings werden nur die Nachrichten vom aufrufenden Programm abgefangen, alle Nachrichten an fremde Fenster kommen nicht an.
Weiß jemand warum? :gruebel: Hook-DLL
Delphi-Quellcode:
GUI:
library HookCallWndProc;
uses Windows, Messages; {$R *.res} type TMyCallBack = procedure( nCode : Integer; WPARAM : WPARAM; LPARAM : LPARAM ); stdcall; var HookHandle : Cardinal = 0; FCallBack : TMyCallBack = nil; function CallWndProcHookProc( nCode : Integer; WPARAM : WPARAM; LPARAM : LPARAM ) : LRESULT; stdcall; begin Result := CallNextHookEx( HookHandle, nCode, WPARAM, LPARAM ); if nCode = HC_ACTION then if Assigned( FCallBack ) then FCallBack( nCode, WPARAM, LPARAM ); end; function InstallHook( aCallBack : TMyCallBack ) : Boolean; stdcall; begin Result := False; if HookHandle = 0 then begin HookHandle := SetWindowsHookEx( WH_CALLWNDPROC, @CallWndProcHookProc, HInstance, 0 ); FCallBack := aCallBack; Result := True; end; end; function UninstallHook : Boolean; stdcall; begin Result := UnhookWindowsHookEx( HookHandle ); FCallBack := nil; HookHandle := 0; end; exports InstallHook, UninstallHook; end.
Delphi-Quellcode:
unit Main.View;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class( TForm ) ListBox1 : TListBox; procedure FormDestroy( Sender : TObject ); procedure FormCreate( Sender : TObject ); private public end; var Form1 : TForm1; implementation type TMyCallBack = procedure( nCode : Integer; WPARAM : WPARAM; LPARAM : LPARAM ); stdcall; function InstallHook( CallBack : TMyCallBack ) : Boolean; stdcall; external 'HookCallWndProc.dll'; function UninstallHook( ) : Boolean; stdcall; external 'HookCallWndProc.dll'; {$R *.dfm} procedure HookCallWndProc( nCode : Integer; WPARAM : WPARAM; LPARAM : LPARAM ); stdcall; var cwps : TCWPStruct; szClass : array [0 .. 80] of Char; begin if nCode = HC_ACTION then begin CopyMemory( @cwps, Pointer( LPARAM ), SizeOf( CWPSTRUCT ) ); GetClassName( cwps.hwnd, szClass, Length( szClass ) - 1 ); case cwps.message of WM_WINDOWPOSCHANGING : begin Form1.ListBox1.ItemIndex := Form1.ListBox1.Items.Add( 'WINDOWSPOSCHANGING ' + szClass ); end; end; end; end; procedure TForm1.FormCreate( Sender : TObject ); begin InstallHook( HookCallWndProc ); end; procedure TForm1.FormDestroy( Sender : TObject ); begin UninstallHook; end; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:56 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz