一个关于stringgrid的难题,望诸位有以教我 众所周知,stringgrid没有onscrollmove事件,我想通过wm_hscroll和wm_vscroll消息来实现此功能,请提供完整正确程序代码,必将以百分相赠,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, StdCtrls;type TForm1 = class(TForm) StringGrid1: TStringGrid; Button1: TButton; procedure FormCreate(Sender: TObject); private OldWndMethod: TWndMethod; procedure NewWndMethod(var Message: TMessage); public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin OldWndMethod := StringGrid1.WindowProc; StringGrid1.WindowProc := NewWndMethod; with StringGrid1 do begin Cells[1,0] := 'Column 1'; Cells[2,0] := 'Column 2'; Cells[3,0] := 'Column 3'; Cells[4,0] := 'Column 4'; Cells[0,1] := 'Row 1'; Cells[1,1] := 'Object'; Cells[2,1] := 'Pascal'; Cells[3,1] := 'is'; Cells[4,1] := 'excellent'; Cells[0,2] := 'Row 2'; Cells[1,2] := 'Delphi'; Cells[2,2] := 'is'; Cells[4,2] := 'RAD'; end;end;procedure TForm1.NewWndMethod(var Message: TMessage);begin case Message.Msg of WM_HSCROLL: ShowMessage('WM_HSCROLL'); //在这里可以调用一个方法来处理该消息 WM_VSCROLL: ShowMessage('WM_VSCROLL'); else if Assigned(OldWndMethod) then OldWndMethod(Message); end;end;end.————————————————————————————————————宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。———————————————————————————————————— unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, StdCtrls;type TForm1 = class(TForm) StringGrid1: TStringGrid; Button1: TButton; procedure FormCreate(Sender: TObject); private OldWndMethod: TWndMethod; procedure NewWndMethod(var Message: TMessage); public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin OldWndMethod := StringGrid1.WindowProc; StringGrid1.WindowProc := NewWndMethod; with StringGrid1 do begin Cells[1,0] := 'Column 1'; Cells[2,0] := 'Column 2'; Cells[3,0] := 'Column 3'; Cells[4,0] := 'Column 4'; Cells[0,1] := 'Row 1'; Cells[1,1] := 'Object'; Cells[2,1] := 'Pascal'; Cells[3,1] := 'is'; Cells[4,1] := 'excellent'; Cells[0,2] := 'Row 2'; Cells[1,2] := 'Delphi'; Cells[2,2] := 'is'; Cells[4,2] := 'RAD'; end;end;procedure TForm1.NewWndMethod(var Message: TMessage);begin case Message.Msg of WM_HSCROLL: ShowMessage('WM_HSCROLL'); //在这里可以调用一个方法来处理该消息 WM_VSCROLL: ShowMessage('WM_VSCROLL'); else if Assigned(OldWndMethod) then OldWndMethod(Message); end;end;end.————————————————————————————————————宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。———————————————————————————————————— 数据库登录疑问啊! 关于事务处理与锁的问题! 奇怪的adoquery问题 各位md5组件怎么安装 ? 如何将XML文件保存到SQLServer数据库中,并读出。高分在线等!!!! 数值转成特定格式字串问题 怎样知道MDI子窗口已经打开? 请问哪里有delphi6.0方面的书籍下载?谢谢 Delphi的toolbar问题,请教。不难,但是送20分 怎么给一个文件夹分配空间啊?40分送上! 还是鼠标拖动操作的问题。 关于选择路径的问题,还望指教!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls;type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
OldWndMethod: TWndMethod;
procedure NewWndMethod(var Message: TMessage);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
OldWndMethod := StringGrid1.WindowProc;
StringGrid1.WindowProc := NewWndMethod;
with StringGrid1 do
begin
Cells[1,0] := 'Column 1';
Cells[2,0] := 'Column 2';
Cells[3,0] := 'Column 3';
Cells[4,0] := 'Column 4';
Cells[0,1] := 'Row 1';
Cells[1,1] := 'Object';
Cells[2,1] := 'Pascal';
Cells[3,1] := 'is';
Cells[4,1] := 'excellent';
Cells[0,2] := 'Row 2';
Cells[1,2] := 'Delphi';
Cells[2,2] := 'is';
Cells[4,2] := 'RAD';
end;
end;procedure TForm1.NewWndMethod(var Message: TMessage);
begin
case Message.Msg of
WM_HSCROLL: ShowMessage('WM_HSCROLL'); //在这里可以调用一个方法来处理该消息
WM_VSCROLL: ShowMessage('WM_VSCROLL');
else
if Assigned(OldWndMethod) then OldWndMethod(Message);
end;
end;end.————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls;type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
OldWndMethod: TWndMethod;
procedure NewWndMethod(var Message: TMessage);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
OldWndMethod := StringGrid1.WindowProc;
StringGrid1.WindowProc := NewWndMethod;
with StringGrid1 do
begin
Cells[1,0] := 'Column 1';
Cells[2,0] := 'Column 2';
Cells[3,0] := 'Column 3';
Cells[4,0] := 'Column 4';
Cells[0,1] := 'Row 1';
Cells[1,1] := 'Object';
Cells[2,1] := 'Pascal';
Cells[3,1] := 'is';
Cells[4,1] := 'excellent';
Cells[0,2] := 'Row 2';
Cells[1,2] := 'Delphi';
Cells[2,2] := 'is';
Cells[4,2] := 'RAD';
end;
end;procedure TForm1.NewWndMethod(var Message: TMessage);
begin
case Message.Msg of
WM_HSCROLL: ShowMessage('WM_HSCROLL'); //在这里可以调用一个方法来处理该消息
WM_VSCROLL: ShowMessage('WM_VSCROLL');
else
if Assigned(OldWndMethod) then OldWndMethod(Message);
end;
end;end.————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————