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

怎樣設定元件的次序?

 
白日夢
一般會員


發表:5
回覆:0
積分:1
註冊:2007-02-09

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-02-27 18:25:44 IP:125.31.xxx.xxx 訂閱
怎樣設定元件的次序?

例如我想一些元件都永遠在最前
永遠在第二這些

請問怎樣才做到?
pedro
尊榮會員


發表:152
回覆:1187
積分:892
註冊:2002-06-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-02-27 20:55:05 IP:61.217.xxx.xxx 未訂閱
在delphi ide環境裡,在元件上按滑鼠右鍵,
有control->Bring to front及Send to back可調整元件的Z-Order順序
y2464372001
一般會員


發表:6
回覆:7
積分:2
註冊:2007-01-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-03-13 22:06:29 IP:218.162.xxx.xxx 訂閱
可是我有使用你教的方式,但是無法使StringGrid為次序耶!!
Ps.因為我想使Shape元件在 StringGrid的上方。
不知如何來用,麻煩你一下,謝謝

P.D.
版主


發表:603
回覆:4038
積分:3874
註冊:2006-10-31

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-03-14 10:48:17 IP:61.67.xxx.xxx 未訂閱
有些元件是無法正常的被覆蓋在上面, 例如 strgingrid 與 shape, shape永遠會被strgingrid蓋位, 所以到類似的情況, 你可以用
stringgrid panel, 然後在panel內再放sharp就能表現出來了!
===================引 用 文 章===================
可是我有使用你教的方式,但是無法使StringGrid為次序耶!!
Ps.因為我想使Shape元件在?StringGrid的上方。
不知如何來用,麻煩你一下,謝謝

pedro
尊榮會員


發表:152
回覆:1187
積分:892
註冊:2002-06-12

發送簡訊給我
#5 引用回覆 回覆 發表時間:2007-03-14 11:05:07 IP:60.248.xxx.xxx 未訂閱
恩呀,要是你真要這麼做,除非對TStringGrid類做加工,在Paint繪自己要的圖像
底下Paint那一段,取自TShape.Paint原始碼

type
TForm1 = class(TForm)
Shape1: TShape;
procedure FormPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TExtStringGrid=class(TStringGrid)
private
FShape:TShape;
protected
procedure Paint;override;
public
constructor Create(AOwner: TComponent;AShape:TShape);overload;
end;


var
Form1: TForm1;
ExtStringGrid1:TExtStringGrid;
implementation
{$R *.dfm}
procedure TForm1.FormPaint(Sender: TObject);
begin
end;
{ TExtStringGrid }
constructor TExtStringGrid.Create(AOwner: TComponent; AShape: TShape);
begin
inherited Create(AOwner);
FShape:=AShape;
end;
procedure TExtStringGrid.Paint;
var
X, Y, W, H, S: Integer;
begin
inherited;
with Canvas do
begin
Pen := FShape.Pen;
Brush := FShape.Brush;
X := FShape.Left;
Y := FShape.Top;
W := FShape.Width - Pen.Width 1;
H := FShape.Height - Pen.Width 1;
if Pen.Width = 0 then
begin
Dec(W);
Dec(H);
end;
if W < H then S := W else S := H;
if FShape.Shape in [stSquare, stRoundSquare, stCircle] then
begin
Inc(X, (W - S) div 2);
Inc(Y, (H - S) div 2);
W := S;
H := S;
end;
case FShape.Shape of
stRectangle, stSquare:
Rectangle(X, Y, X W, Y H);
stRoundRect, stRoundSquare:
RoundRect(X, Y, X W, Y H, S div 4, S div 4);
stCircle, stEllipse:
Ellipse(X, Y, X W, Y H);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ExtStringGrid1:=TExtStringGrid.Create(self,shape1);
ExtStringGrid1.Parent:=Self;
ExtStringGrid1.SetBounds(100,10,400,300);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ExtStringGrid1.Free;
end;
系統時間:2024-05-03 9:34:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!