1,183
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Self.ScrollBox1.WindowProc := Self.FOldWndProc;
end;
object Form1: TForm1
Left = 192
Top = 114
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object ScrollBox1: TScrollBox
Left = 80
Top = 80
Width = 249
Height = 225
TabOrder = 0
object BitBtn1: TBitBtn
Left = 72
Top = 80
Width = 75
Height = 25
Caption = 'BitBtn1'
TabOrder = 0
end
object StringGrid1: TStringGrid
Left = 32
Top = 128
Width = 320
Height = 120
TabOrder = 1
end
end
object ScrollBox2: TScrollBox
Left = 368
Top = 80
Width = 249
Height = 225
TabOrder = 1
object BitBtn2: TBitBtn
Left = 72
Top = 80
Width = 75
Height = 25
Caption = 'BitBtn1'
TabOrder = 0
end
object StringGrid2: TStringGrid
Left = 32
Top = 128
Width = 320
Height = 120
TabOrder = 1
end
end
object ApplicationEvents1: TApplicationEvents
Left = 32
Top = 120
end
end
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AppEvnts, Grids, StdCtrls, Buttons;
type
TForm1 = class(TForm)
ScrollBox1: TScrollBox;
BitBtn1: TBitBtn;
StringGrid1: TStringGrid;
ScrollBox2: TScrollBox;
BitBtn2: TBitBtn;
StringGrid2: TStringGrid;
ApplicationEvents1: TApplicationEvents;
procedure FormCreate(Sender: TObject);
private
FOldWndProc: TWndMethod;
public
procedure NewWndProc(var Msg: TMessage);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Self.FOldWndProc := Self.ScrollBox1.WindowProc;
Self.ScrollBox1.WindowProc := Self.NewWndProc;
end;
procedure TForm1.NewWndProc(var Msg: TMessage);
begin
if (Msg.Msg=WM_VSCROLL) or (Msg.Msg=WM_HSCROLL) then
if TWMVScroll(Msg).ScrollBar=0 then
Self.ScrollBox2.WindowProc(Msg);
Self.FOldWndProc(Msg);
end;
end.