> To send messages to a data module, there needs to be a window
available.
> You can use the AllocateHWnd function to create a window for
receiving
> messages. That function expects a method pointer, which the new
window
> will call whenever a message arrives. Implement the method in the
> data-module object. There are a couple of examples of using
AllocateHWnd
> in the VCL source code.
>
> --
> Rob
>
Thank you, worked, here is the code (snipped):
type
TMyDataModule = class(TDataModule)
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
private
FHWnd: HWND;
protected
procedure ProcessWndMessages(var aMsg: TMessage); virtual;
public
property Handle:HWND read FHWnd;
......
procedure TMyDataModule.DataModuleCreate(Sender: TObject);
begin
FHWnd := AllocateHWnd(ProcessWndMessages);
......
procedure TMyDataModule.DataModuleDestroy(Sender: TObject);
begin
DeallocateHWnd(FHWnd);
......
procedure TMyDataModule.ProcessWndMessages(var aMsg: TMessage);
var done:boolean;
UserInfo:TUserInfo;
begin
done := False;
case aMsg.Msg of
wm_MyMessage: begin
done := True;
code for this message
end;
end;
if done
then aMsg.Result := 0
else aMsg.Result := DefWindowProc(FHWnd, aMsg.Msg, aMsg.WParam,
aMsg.LParam);
end;
Finally, to post message to MyDataModule I use this code:
PostMeassage( MyDataModule.Handle, WM_MyMessage, 0, 0);
Thank you again
Yours,
Monir
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
SPONSORED LINKS
| C programming language | Computer programming languages | Java programming language |
| The c programming language | C programming language | Concept of programming language |
YAHOO! GROUPS LINKS
- Visit your group "delphi-en" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

