父子窗体滚动条支持鼠标滚轮移动
1 //作者: 415799952 追寻 2 // 513187410 疯狂→delphi 3 // 1746539685 dnyy 4 5 6 //1.设置哪个方向移动 7 procedure TForm1.BitBtn2Click(Sender: TObject); 8 begin 9 if bitbtn2.Caption='纵向滚动' then 10 begin 11 bitbtn2.Caption:='横向滚动'; 12 bitbtn2.Tag:=0; 13 end 14 else 15 begin 16 bitbtn2.Caption:='纵向滚动'; 17 bitbtn2.Tag:=1; 18 end; 19 end; 20 21 //2.移动一 22 procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState; 23 MousePos: TPoint; var Handled: Boolean); 24 begin 25 if bitbtn2.Tag=1 then 26 postmessage(Form1.ClientHandle,WM_VSCROLL,SB_LINEDOWN,0) 27 else 28 postmessage(Form1.ClientHandle,WM_HSCROLL,SB_LINERIGHT,0); 29 end; 30 31 //3.移动二 32 procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState; 33 MousePos: TPoint; var Handled: Boolean); 34 begin 35 if bitbtn2.Tag=1 then 36 postmessage(Form1.ClientHandle,WM_VSCROLL,SB_LINEUP,0) 37 else 38 postmessage(Form1.ClientHandle,WM_HSCROLL,SB_LINELEFT,0); 39 end;
作者:疯狂Delphi
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
欢迎关注我,一起进步!扫描下方二维码即可加我