C
cornermoss
Unregistered / Unconfirmed
GUEST, unregistred user!
//********添加事件
unit MyDBMemo_f;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,DBCtrls,
ExtCtrls;
type
TMyDBMemo = class(TDBMemo)
private
FOnScrollUp: TNotifyEvent;
FOnScrollDown:TNotifyEvent;
procedure CMOnScrollDown(var Message: TMessage);
procedure CMOnScrollUp(var Message: TMessage);
message WM_VScroll;
protected
public
published
property OnScrollUp: TNotifyEvent read FOnScrollUp write FOnScrollUp;
property OnScrollDown: TNotifyEvent read FOnScrollDown write FOnScrollDown;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyDBMemo]);
end;
procedure TMyDBMemo.CMOnScrollUp(var Message: TMessage);
begin
inherited;
if Assigned(FOnScrollUp) then FOnScrollUp(Self);
end;
procedure TMyDBMemo.CMOnScrollDown(var Message: TMessage);
begin
inherited;
if Assigned(FOnScrollDown) then FOnScrollDown(Self);
end;
end.
//*******主程序
unit main_f;
interface
uses
Windows, Messages, SysUtils,Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, Buttons, ComCtrls, DBCtrls,registry,ShellAPI,DB,
Mask, Grids, DBGrids,MyDBMemo_f;
type
Tmain = class(TForm)
MainMenu1: TMainMenu;
DBMemo1: TDBMemo;
DBMemo2: TMyDBMemo;
procedure DBMemo2ScrollUp(Sender: TObject);
procedure DBMemo2ScrollDown(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
procedure Tmain.DBMemo2ScrollUp(Sender: TObject);
begin
postmessage(DBMemo1.Handle, WM_VScroll, sb_lineup,0);
end;
procedure Tmain.DBMemo2ScrollDown(Sender: TObject);
begin
postmessage(DBMemo1.Handle, WM_VScroll, sb_linedown,0);
end;
end.
我给DBMemo添加了两个事件:OnScollUp和OnScollDown,想要点击DBMemo1的滚动条,
DBMemo2的滚动条也相应地滚动。现在已经给DBMemo添加了这两个事件;但是点击滚动条
的时候,DBMemo2的滚动行数和DBMemo1的不一致呢?~~或者是不是我添加事件的时候用的Message不对呢~
请哪位高手指点一下呀??谢谢了先^_*
unit MyDBMemo_f;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,DBCtrls,
ExtCtrls;
type
TMyDBMemo = class(TDBMemo)
private
FOnScrollUp: TNotifyEvent;
FOnScrollDown:TNotifyEvent;
procedure CMOnScrollDown(var Message: TMessage);
procedure CMOnScrollUp(var Message: TMessage);
message WM_VScroll;
protected
public
published
property OnScrollUp: TNotifyEvent read FOnScrollUp write FOnScrollUp;
property OnScrollDown: TNotifyEvent read FOnScrollDown write FOnScrollDown;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyDBMemo]);
end;
procedure TMyDBMemo.CMOnScrollUp(var Message: TMessage);
begin
inherited;
if Assigned(FOnScrollUp) then FOnScrollUp(Self);
end;
procedure TMyDBMemo.CMOnScrollDown(var Message: TMessage);
begin
inherited;
if Assigned(FOnScrollDown) then FOnScrollDown(Self);
end;
end.
//*******主程序
unit main_f;
interface
uses
Windows, Messages, SysUtils,Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls, Buttons, ComCtrls, DBCtrls,registry,ShellAPI,DB,
Mask, Grids, DBGrids,MyDBMemo_f;
type
Tmain = class(TForm)
MainMenu1: TMainMenu;
DBMemo1: TDBMemo;
DBMemo2: TMyDBMemo;
procedure DBMemo2ScrollUp(Sender: TObject);
procedure DBMemo2ScrollDown(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
procedure Tmain.DBMemo2ScrollUp(Sender: TObject);
begin
postmessage(DBMemo1.Handle, WM_VScroll, sb_lineup,0);
end;
procedure Tmain.DBMemo2ScrollDown(Sender: TObject);
begin
postmessage(DBMemo1.Handle, WM_VScroll, sb_linedown,0);
end;
end.
我给DBMemo添加了两个事件:OnScollUp和OnScollDown,想要点击DBMemo1的滚动条,
DBMemo2的滚动条也相应地滚动。现在已经给DBMemo添加了这两个事件;但是点击滚动条
的时候,DBMemo2的滚动行数和DBMemo1的不一致呢?~~或者是不是我添加事件的时候用的Message不对呢~
请哪位高手指点一下呀??谢谢了先^_*