Aleq
asked on
How to handle parental messages
Now when one expert answered my question about hooking parental messages, I need help again. I need to handle and MODIFY a result of WM_NCHITTEST message. And I need to do this from hook. The idea was: user places component onto the form and the component takes the form's WM_NCHITTEST do decide what's caption, what's resizable border etc...
listening..
I think it's easier to do what you want using subclassing instead of hooks.
I would do this with SetWindowLong with GWL_WNDPROC parameter.
You steel need that MakeHookInstance function to get an address for new window procedure :)
Roman.
I would do this with SetWindowLong with GWL_WNDPROC parameter.
You steel need that MakeHookInstance function to get an address for new window procedure :)
Roman.
ASKER
rwilson: I know this solution, but I need to handle WM_NCHITTEST from component placed on that form.
Can I just ask, so I get it straight in my head.....are you saying you wish to write a component that handles the form's windows messages? If so, I've got code for that. Let me know.
John.
John.
Aleq: The point is that you do just the same thing in your component (the handling of the message, that is).
Cheers,
Raymond.
Cheers,
Raymond.
ASKER
rwilson - I tried it. Handling WM_NCHITTEST in component was very interesting - it allowed me to resize the component itself, not parental form .....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can you give me the whole TEnhancedForm ? I've tried this code, but It made some problems....
This should show you all you need...
Cheers,
Raymond.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure WMNCHitTest(var M: TWMNCHitTest); message WM_NCHITTEST;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
begin
inherited;
{If the client has been clicked, make Windows believe}
{it was the caption bar that was clicked on}
if M.Result = htClient then
M.Result := htCaption;
end;
end.