線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2626
推到 Plurk!
推到 Facebook!

請問如何設計像ACDSEE的掌形捲動工具在看圖

答題得分者是:bugmans
17kobe
初階會員


發表:86
回覆:73
積分:31
註冊:2007-07-30

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-09-28 15:38:36 IP:220.132.xxx.xxx 訂閱
我有
一個TScrollBox 及
一個TImage(Autosize屬性true)

而我像做用掌形來捲動圖片就好了,來取代還要拉TScrollBox的捲軸,請問該如何來下手。


以下是擷取螢幕的畫面,但是滑鼠還沒做掌形拖曳工具
程式有物件
1個TScrollBox、1個TImage(AutoSize屬性為True)、1個TButton
程式有事件
TButton的OnClick

[code delphi]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
ScrollBox1: TScrollBox;
Image1: TImage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
DC:hdc;
MyCanvas:TCanVas;
Bmp:TBitMap;
begin
Application.Minimize; //視窗縮到工作列
Sleep(1000);
Application.ProcessMessages;

MyCanvas:=TCanvas.Create;
Bmp:=TBitMap.Create;

Bmp.Width := Screen.Width;
Bmp.Height := Screen.Height;

DC:=getdc(0);
try
MyCanvas.Handle := DC;

Bmp.Canvas.CopyRect(Rect(0,0,Screen.Width,Screen.Height),myCanvas,Rect(0,0,Screen.Width,Screen.Height));
image1.Picture.Bitmap.Assign(Bmp);
finally
Releasedc(0,dc);
MyCanvas.Free;
Bmp.Free;
end;
application.Restore;
end;

end.
[/code]
編輯記錄
17kobe 重新編輯於 2007-09-29 15:35:50, 註解 無‧
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-09-28 15:46:18 IP:122.124.xxx.xxx 未訂閱
您有很多問題尚未結案,請留意
http://delphi.ktop.com.tw/members_question.php?uid=68129

建議您將你已經寫好的部份PO上來,讓前輩們幫您看看如何修改

編輯記錄
taishyang 重新編輯於 2007-09-28 15:47:01, 註解 無‧
bugmans
高階會員


發表:95
回覆:322
積分:188
註冊:2003-04-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-12-08 06:46:08 IP:125.225.xxx.xxx 未訂閱
可以參考ATImageBox這個元件
http://atorg.net.ru/delphi/atimagebox.htm
要實作拖曳功能請看ATImageBox.pas原始碼


[code delphi]
procedure TATImageBox.ImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if FImageDrag and (Button = mbLeft) then//當按下滑鼠左鍵時
begin
FImageDragging := True; //設定為拖曳模式
FImageDraggingPoint := Point(X, Y); //並紀錄下目前滑鼠位置
Screen.Cursor := FImageDragCursor;
end;
end;
procedure TATImageBox.ImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if FImageDrag and FImageDragging then //在移動滑鼠的時候
begin
HorzScrollBar.Position := HorzScrollBar.Position (FImageDraggingPoint.X - X);
VertScrollBar.Position := VertScrollBar.Position (FImageDraggingPoint.Y - Y);
//更新ScrollBar的位置,並依位移的距離來調整圖片的位置
UpdateImageLabelPosition;
end;
end;
procedure TATImageBox.ImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if FImageDragging and (Button = mbLeft) then
begin
FImageDragging := False; //取消拖曳模式
Screen.Cursor := crDefault;
end;
end;
[/code]
編輯記錄
bugmans 重新編輯於 2007-12-08 06:47:46, 註解 無‧
歸木淡
中階會員


發表:1
回覆:49
積分:75
註冊:2005-09-07

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-01-14 01:35:46 IP:71.235.xxx.xxx 訂閱
http://delphi.about.com/od/adptips2006/qt/panning.htm
系統時間:2024-04-19 10:09:25
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!