Dismiss Notice

REGISTRATION IS AFTER ADMIN ACTIVATION

DONATIONS WITH PAYPAL CLICK TO BUTTON

1 MONTH VIP - 5$; 3 MONTHS VIP - 10$; 6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$

DONATIONS WITH Bitcoin Address:3NRs3CK3fhXifrNYxHEZKpETDd9vNLMsMD

Dismiss Notice
The registration is approved by the Administrator. It takes about 1 day to approve your registration
Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Draw to form caption

Discussion in 'Delphi Programming' started by N0body, Jan 3, 2014.

  1. N0body
    Online

    N0bodyN0body is a Verified Member DelphiFan Administrator Staff Member DF Staff

    {
    This writes form caption to center. However, old caption stays. The solution
    could be to use another variable as caption and keep Form.Caption empty.


    Add to private:
    }


    Code:
    procedure RedrawCaption;
      procedure WMMove(var Message: TMessage); message WM_MOVE;
      procedure WMResize(var Message: TMessage); message WM_SIZE;
    
    
    procedure TForm1.RedrawCaption;
    var
      LabelHeight, LabelWidth, LabelTop: Integer;
      Caption_Height, Border3D_Y, Button_Width, Border_Thickness: Integer;
      TitleCanvas: TCanvas;
      CaptionBarRect: TRect;
    begin
      TitleCanvas := TCanvas.Create;
      TitleCanvas.Handle := GetWindowDC(Handle);
      Border3D_Y := GetSystemMetrics(SM_CYEDGE);
      Button_Width := GetSystemMetrics(SM_CXSIZE);
      Border_Thickness  := GetSystemMetrics(SM_CYSIZEFRAME);
      Caption_Height := GetSystemMetrics(SM_CYCAPTION);
      LabelWidth := Canvas.TextWidth(Caption);
      LabelHeight := Canvas.TextHeight(Caption);
      LabelTop := LabelHeight - Caption_Height div 2;
      CaptionBarRect := Rect(Border_Thickness + Border3D_Y + Button_Width,
                             Border_Thickness + Border3D_Y,
                             Width - (Border_Thickness + Border3D_Y) - Button_Width * 4,
                             Caption_Height);
      TitleCanvas.Brush.Style := bsClear;
      TitleCanvas.Font.Color := clCaptionText;
      TitleCanvas.Font.Name := 'MS Sans Serif';
      TitleCanvas.Font.Style := [fsBold];
      DrawText(TitleCanvas.Handle, PChar(Caption), Length(Caption), CaptionBarRect,
               DT_CENTER or DT_SINGLELINE or DT_VCENTER);
    end;
    
    
    procedure TForm1.WMMove(var Message: TMessage);
    begin
      RedrawCaption;
    end;
    
    
    procedure TForm1.WMResize(var Message: TMessage);
    begin
      RedrawCaption;
    end;
     

Share This Page

Laws
Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.
Donate Help To Us and Be VIP
DONATIONS WITH PAYPAL CLICK TO BUTTON
6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$
Social Block