怎樣設定元件的次序? |
|
白日夢
一般會員 發表:5 回覆:0 積分:1 註冊:2007-02-09 發送簡訊給我 |
|
pedro
尊榮會員 發表:152 回覆:1187 積分:892 註冊:2002-06-12 發送簡訊給我 |
|
y2464372001
一般會員 發表:6 回覆:7 積分:2 註冊:2007-01-23 發送簡訊給我 |
|
P.D.
版主 發表:603 回覆:4038 積分:3874 註冊:2006-10-31 發送簡訊給我 |
有些元件是無法正常的被覆蓋在上面, 例如 strgingrid 與 shape, shape永遠會被strgingrid蓋位, 所以到類似的情況, 你可以用
stringgrid panel, 然後在panel內再放sharp就能表現出來了! ===================引 用 文 章=================== 可是我有使用你教的方式,但是無法使StringGrid為次序耶!! Ps.因為我想使Shape元件在?StringGrid的上方。 不知如何來用,麻煩你一下,謝謝 |
pedro
尊榮會員 發表:152 回覆:1187 積分:892 註冊:2002-06-12 發送簡訊給我 |
恩呀,要是你真要這麼做,除非對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; |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |