我的程序如下
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Unit2, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FPluginRegistry : TPluginRegistry;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
FPluginRegistry := TPluginRegistry.Create;
RegisterWindowMessage('WM_DESERIALIZATION');
end;procedure TForm1.Button1Click(Sender: TObject);
begin
//如果我用这句就可以接收到自定义的消息
// PostMessage(FPluginRegistry.WindowHandle,WM_DESERIALIZATION,0,0);
//如果用这句就不行,怎么样才能实现广播呢?
PostMessage(HWND_BROADCAST,WM_DESERIALIZATION,0,0);
end;end.
unit Unit2;interfaceuses Classes, Windows, Messages,Dialogs;const
WM_DESERIALIZATION = WM_USER + 100; type
TPluginRegistry = class(TPersistent)
private
FWindowHandle: HWND;
procedure WndProc(var Msg: TMessage);
protected
procedure ProcessSaveProperty; virtual;
public
constructor Create;
destructor Destroy; override;
property WindowHandle : HWND read FWindowHandle;
end;implementationuses Forms;
{ TPluginRegistry }constructor TPluginRegistry.Create;
begin
inherited Create;
FWindowHandle := Classes.AllocateHWnd(WndProc);
end;destructor TPluginRegistry.Destroy;
begin
Classes.DeallocateHWnd(FWindowHandle);
inherited;
end;
procedure TPluginRegistry.ProcessSaveProperty;
begin
Showmessage('Received');
end;procedure TPluginRegistry.WndProc(var Msg: TMessage);
begin
with Msg do
if Msg = WM_DESERIALIZATION then
try
ProcessSaveProperty;
except
Application.HandleException(Self);
end
else
Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Unit2, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FPluginRegistry : TPluginRegistry;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
FPluginRegistry := TPluginRegistry.Create;
RegisterWindowMessage('WM_DESERIALIZATION');
end;procedure TForm1.Button1Click(Sender: TObject);
begin
//如果我用这句就可以接收到自定义的消息
// PostMessage(FPluginRegistry.WindowHandle,WM_DESERIALIZATION,0,0);
//如果用这句就不行,怎么样才能实现广播呢?
PostMessage(HWND_BROADCAST,WM_DESERIALIZATION,0,0);
end;end.
unit Unit2;interfaceuses Classes, Windows, Messages,Dialogs;const
WM_DESERIALIZATION = WM_USER + 100; type
TPluginRegistry = class(TPersistent)
private
FWindowHandle: HWND;
procedure WndProc(var Msg: TMessage);
protected
procedure ProcessSaveProperty; virtual;
public
constructor Create;
destructor Destroy; override;
property WindowHandle : HWND read FWindowHandle;
end;implementationuses Forms;
{ TPluginRegistry }constructor TPluginRegistry.Create;
begin
inherited Create;
FWindowHandle := Classes.AllocateHWnd(WndProc);
end;destructor TPluginRegistry.Destroy;
begin
Classes.DeallocateHWnd(FWindowHandle);
inherited;
end;
procedure TPluginRegistry.ProcessSaveProperty;
begin
Showmessage('Received');
end;procedure TPluginRegistry.WndProc(var Msg: TMessage);
begin
with Msg do
if Msg = WM_DESERIALIZATION then
try
ProcessSaveProperty;
except
Application.HandleException(Self);
end
else
Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
end;end.
解决方案 »
- 请问一个问题,滚动条如何设置为平滑一点?
- 请教下面这段程序的意思,是关于在图上选了一些点,需要拟合出一条曲线,谢谢,最好说的具体些
- 为什么程序连接ORACLE正常, 但是查询不到任何记录, 表中是有信息的,用PLUS就可以;
- <<怎样开发工资管理系统>>给你编程开发提供参考
- DELPHI6的ADO连接ORACLE ADOStoredProc的parameters为什么不返回参数的,
- 我们常常看到的__象在输入框(edit)点击"客户代码"就相应的弹出"客户代码"的界面,是怎么做的?
- 关于DBLookupComboboxEh的一个问题。很急的。
- 同一局域网两服务器的数据库相互导入数据
- 请教!急!!如何在bdgrid中放置checkbox控件
- 请问李维Delphi5.xADO?MTS?COM+一书的源代码在那个网站有下载的?
- DBGrid启动显示怎么做?
- 请问,在Delphi中如何调用Lingo进行运筹学计算?
var
WM_DESERIALIZATION: integer;procedure TForm1.Button1Click(Sender: TObject);
begin
PostMessage(HWND_BROADCAST, WM_DESERIALIZATION, 0, 0 );end;procedure TForm1.FormCreate(Sender: TObject);
begin
WM_DESERIALIZATION := RegisterWindowMessage('WM_DESERIALIZATION'); FClass := TPluginRegistry.Create;
end;