B
bells
Unregistered / Unconfirmed
GUEST, unregistred user!
问题是这样的:我要继承F1Book做一个控件,在其中自定义一个消息,
当应用程序(用户)向对象实例发送此消息时(例如点击button按钮时)
此对象实例执行的动作是将book中的数据存盘.我该在控件中如何写代码,在应用程序中又该如何发送消息?请指教.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtrls, vcf1, Db, DBTables;
const
WM_Mymessage=WM_USER+200;
type
TSaveEvent=procedure(Sender:TObject;bc:string) of Object;
TMyBook = class(TF1Book)
private
{ Private declarations }
FOnSave:TSaveEvent;
FWindowHandle:HWND;
procedure WndProc(var msg : TMessage);
protected
{ Protected declarations }
procedure dosave;dynamic;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property OnSave:TSaveEvent read FOnSave write FOnSave;
end;
procedure Register;
implementation
procedure TMyBook.WndProc(var msg:tmessage);
begin
with msg do
if msg=WM_Mymessage then
dosave
else
result:=defwindowproc(fwindowhandle,msg,wparam,lparam);
end;
procedure TMyBook.dosave;
begin
//数据存盘
end;
end.
当应用程序(用户)向对象实例发送此消息时(例如点击button按钮时)
此对象实例执行的动作是将book中的数据存盘.我该在控件中如何写代码,在应用程序中又该如何发送消息?请指教.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtrls, vcf1, Db, DBTables;
const
WM_Mymessage=WM_USER+200;
type
TSaveEvent=procedure(Sender:TObject;bc:string) of Object;
TMyBook = class(TF1Book)
private
{ Private declarations }
FOnSave:TSaveEvent;
FWindowHandle:HWND;
procedure WndProc(var msg : TMessage);
protected
{ Protected declarations }
procedure dosave;dynamic;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property OnSave:TSaveEvent read FOnSave write FOnSave;
end;
procedure Register;
implementation
procedure TMyBook.WndProc(var msg:tmessage);
begin
with msg do
if msg=WM_Mymessage then
dosave
else
result:=defwindowproc(fwindowhandle,msg,wparam,lparam);
end;
procedure TMyBook.dosave;
begin
//数据存盘
end;
end.