Z zheng8071 Unregistered / Unconfirmed GUEST, unregistred user! 2003-07-02 #1 我自己写了一个控件,但怎样才能在其中加入滚动条呢?希望大家帮帮我
Y yyii_yyii Unregistered / Unconfirmed GUEST, unregistred user! 2003-07-18 #2 一、用系统的SCROLLBAR。 二、自己画一个
A aolo Unregistered / Unconfirmed GUEST, unregistred user! 2003-07-18 #3 在TImage控件中加入滚动条,使控件可以滚动显示大图片参考) 方法是: 在窗体上放置一TPanel,然后在TPanel上放置一TImage,再将一TLabel放入TPanel中, TLabel的设置如下: Align = AlClient; Transparent = True; Caption = ''; var origin:tpoint; image_left:integer; image_top:integer; visa1:tpoint; visa2:tpoint; canmove:boolean; procedure TDraftForm.Label7MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if button=mbleft then begin origin.X:=x; origin.Y:=y; image_left:=image1.Left; image_top:=image1.Top; visa1.X:=x-(image1.Width-panel5.Width+image1.Left); visa1.Y:=y-(image1.Height-panel5.Height+image1.Top); visa2.X:=x-image1.Left; visa2.Y:=y-image1.Top; canmove:=true; end; procedure TDraftForm.Label7MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if canmove then begin if x<visa1.X then x:=visa1.X; if x>visa2.X then x:=visa2.X; if y<visa1.Y then y:=visa1.Y; if y>visa2.Y then y:=visa2.Y; image1.Left:=image_left+(x-origin.X); image1.Top:=image_top+(y-origin.Y); end; end; procedure TDraftForm.Label7MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin canmove:=false; end; 这样你就可以象AcdSee一样用鼠标拉着图象漫游了。
在TImage控件中加入滚动条,使控件可以滚动显示大图片参考) 方法是: 在窗体上放置一TPanel,然后在TPanel上放置一TImage,再将一TLabel放入TPanel中, TLabel的设置如下: Align = AlClient; Transparent = True; Caption = ''; var origin:tpoint; image_left:integer; image_top:integer; visa1:tpoint; visa2:tpoint; canmove:boolean; procedure TDraftForm.Label7MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if button=mbleft then begin origin.X:=x; origin.Y:=y; image_left:=image1.Left; image_top:=image1.Top; visa1.X:=x-(image1.Width-panel5.Width+image1.Left); visa1.Y:=y-(image1.Height-panel5.Height+image1.Top); visa2.X:=x-image1.Left; visa2.Y:=y-image1.Top; canmove:=true; end; procedure TDraftForm.Label7MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if canmove then begin if x<visa1.X then x:=visa1.X; if x>visa2.X then x:=visa2.X; if y<visa1.Y then y:=visa1.Y; if y>visa2.Y then y:=visa2.Y; image1.Left:=image_left+(x-origin.X); image1.Top:=image_top+(y-origin.Y); end; end; procedure TDraftForm.Label7MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin canmove:=false; end; 这样你就可以象AcdSee一样用鼠标拉着图象漫游了。