如何拦截滚动条消息

shandong1 2002-10-14 10:39:49
各位大虾,我是用c++ builder开发的一个程序,应当和Delphi差不多吧!我如何拦截一个scrollbox控件的滚动消息呢?求救呀!
...全文
58 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxblue 2002-10-14
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

TMyScrollBar = class(TScrollBar)
private
i : Integer;
procedure CNHScroll(var Message: TWMHScroll); message CN_HSCROLL;
public
constructor Create(AOwner: TComponent); override;
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

{ TMyScrollBar }

procedure TMyScrollBar.CNHScroll(var Message: TWMHScroll);
begin
TForm1(parent).Memo1.Lines.Append(IntToStr(i));
i := i + 1;
inherited;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
myScrollBar :TMyScrollBar;
begin
myScrollBar := TMyScrollBar.Create(Self);
myScrollBar.Parent := Self;
myScrollBar.Show;
end;

constructor TMyScrollBar.Create(AOwner: TComponent);
begin
inherited;
i := 1;
Max := 10;
end;

end.

5,931

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧