2016-10-10 37 views
-2

我想更改我的應用程序中的標題欄。我不知道該怎麼做。你可以幫我嗎?更改標題欄的顏色和按鈕

我在Delphi中發現了很多例子,但在Lazarus中不起作用。

我該如何開始,我應該怎麼做才能改變例如標題欄顏色或按鈕?

+0

什麼是操作系統?在Windows上,至少系統決定主題,而應用程序不會查看。在Delphi中,有VCL樣式,條目應用程序由框架繪製。不是因爲心靈的隱隱。 –

回答

0

如果標題欄你的意思是你的窗體的標題,那麼所有你需要做的是:

Form1.Caption := 'The title of the form'; 

這對於名稱Form1的一種形式。

1

通過將窗體的BorderStyle設置爲bsNone來關閉原始標題欄。然後添加一個頂部對齊的面板作爲新的標題欄,您可以用任何方式着色,並可以添加SpeedButtons或任何你想要的。爲了能夠在標題欄上用鼠標拖動窗口,您應該爲面板的OnMouseDown和OnMouseMove添加以下事件處理程序:

type 
    TForm1 = class(TForm) 
    Panel1: TPanel; 
    procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton; 
     Shift: TShiftState; X, Y: Integer); 
    procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer 
    ); 
    private 
    FMouseDownPt: TPoint; 
    public 
    end; 

procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; 
    Shift: TShiftState; X, Y: Integer); 
begin 
    FMouseDownPt := Point(X, Y); 
end; 

procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; 
    X, Y: Integer); 
begin 
    if (ssLeft in Shift) then 
    begin 
    Left := Left + (X - FMouseDownPt.X); 
    Top := Top + (Y - FMouseDownPt.Y); 
    end; 
end;