karouri
asked on
Control handles user-defined message?
I made a component inherited from TControl and I need to make this component catches a user defined message (WM_USER+1) that is currently being caught by the form. Is this possible and how?
ASKER
That is exactly what I am doing, however it didn't 'do what I want'.
When I define the same definition as above for the form (i.e. TForm1.WMOwndef(var msg:TMessage);message WM_USER+2;) I am able to respond from within TForm1.WMOwndef, but the component isn't able to do it ..
When I define the same definition as above for the form (i.e. TForm1.WMOwndef(var msg:TMessage);message WM_USER+2;) I am able to respond from within TForm1.WMOwndef, but the component isn't able to do it ..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or you can use
postmessage(hwnd_broadcast ,wm_user+1 ,0,0);
to sendmessage .
postmessage(hwnd_broadcast
to sendmessage .
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TMyControl = class(TControl)
private
{ Private declarations }
protected
{ Protected declarations }
procedure WMOwndefine(var Msg:TMessage);message wm_user+1;
public
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample
end;
{ TMyControl }
procedure TMyControl.WMOwndefine(var
begin
//do what you want
end;
end.