下面是大富翁的朋友帮我解决的代码
但存在一个问题:就是当用户按住滚动条拖动的时候
另外一个ListView就没办法跟着滚动
请大家帮忙private
OldGridProc1, OldGridProc2: TWndMethod;
procedure Grid1WindowProc(var Message: TMessage);
procedure Grid2WindowProc(var Message: TMessage);
public {...} procedure TForm1.Grid1WindowProc(var Message: TMessage);
begin
OldGridProc1(Message);
if ((Message.Msg = WM_VSCROLL) or (Message.Msg = WM_HSCROLL) or
Message.msg = WM_Mousewheel)) then
begin
OldGridProc2(Message);
end;
end; procedure TForm1.Grid2WindowProc(var Message: TMessage);
begin
OldGridProc2(Message);
if ((Message.Msg = WM_VSCROLL) or (Message.Msg = WM_HSCROLL) or
(Message.msg = WM_Mousewheel)) then
begin
OldGridProc1(Message);
end;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
OldGridProc1 := StringGrid1.WindowProc;
OldGridProc2 := StringGrid2.WindowProc;
StringGrid1.WindowProc := Grid1WindowProc;
StringGrid2.WindowProc := Grid2WindowProc;
end;
但存在一个问题:就是当用户按住滚动条拖动的时候
另外一个ListView就没办法跟着滚动
请大家帮忙private
OldGridProc1, OldGridProc2: TWndMethod;
procedure Grid1WindowProc(var Message: TMessage);
procedure Grid2WindowProc(var Message: TMessage);
public {...} procedure TForm1.Grid1WindowProc(var Message: TMessage);
begin
OldGridProc1(Message);
if ((Message.Msg = WM_VSCROLL) or (Message.Msg = WM_HSCROLL) or
Message.msg = WM_Mousewheel)) then
begin
OldGridProc2(Message);
end;
end; procedure TForm1.Grid2WindowProc(var Message: TMessage);
begin
OldGridProc2(Message);
if ((Message.Msg = WM_VSCROLL) or (Message.Msg = WM_HSCROLL) or
(Message.msg = WM_Mousewheel)) then
begin
OldGridProc1(Message);
end;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
OldGridProc1 := StringGrid1.WindowProc;
OldGridProc2 := StringGrid2.WindowProc;
StringGrid1.WindowProc := Grid1WindowProc;
StringGrid2.WindowProc := Grid2WindowProc;
end;
即使要问,也不要说在大富翁问过了啊。大富翁是大富翁,CSDN是CSDN。
大富翁比较专一,CSDN是大众化!!什么语言都有,大富翁好象只有Borland的吧?!
说了半天,其实我最主要的是告诉楼主三个字: 我不懂
if (Msg.Msg = WM_VSCROLL) or (Msg.Msg = WM_VSCROLLCLIPBOARD) then
Begin
Label1.Caption:=IntToStr(Msg.WParam);
Label2.Caption:=IntToStr(Msg.LParam);
SendMessage(ListView2.Handle,Msg.Msg,Msg.WParam,Msg.LParam);
End;
在鼠标按住滚动的时候
中间的SENDMESSAGE有执行到(通过看LABEL的caption值
但ListView2就是没有任何响应
如何解决?
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1987969
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1987969
大富翁连接
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1987969
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
ListView1: TListView;
procedure FormCreate(Sender: TObject);
private
OldProc1,OldProc2 : TWndMethod;
procedure L1Wndproc(var Message : TMessage);
procedure L2WndProc(Var Message : TMessage);
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.L1Wndproc(var Message: TMessage);
begin
OldProc1(Message);
if (Message.Msg = WM_VSCROLL) or
(Message.Msg = WM_MOUSEWHEEL) then
OldProc2(Message);
end;procedure TForm1.L2WndProc(var Message: TMessage);
begin
OldProc2(Message);
if (Message.Msg = WM_VSCROLL) or
(Message.Msg = WM_MOUSEWHEEL) then
OldProc1(Message);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
OldProc1 := ListBox1.WindowProc ;
OldProc2 := ListBox2.WindowProc ;
ListBox1.WindowProc := L1WndProc;
ListBox2.WindowProc := L2WndProc;
end;end.
listbox我没有试
等下
我试试看
那用ListView为什么不可以呢?
吐血