whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

16 Visitors Online


 
...draw a vertical Title bar?
Autor: ---
[ Print tip ]  

Tip Rating (10):  
     




type
  
TForm1 = class(TForm)
    procedure FormResize(Sender: TObject);
    procedure FormPaint(Sender: TObject);
  private
    procedure 
VerticalTitleBar(Texto: string; Size: Integer);
  end;

const
  
MY_TITLE_TEXT = 'Vertical Text';
var
  
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.VerticalTitleBar(TexTo: string; Size: Integer);
var
  
LogFont: TLogFont;
  tmpCanvas: TCanvas;
  tmpRect: TRect;
  x1, x2, y1, y2: integer;
begin
  
tmpCanvas        := TCanvas.Create;
  tmpCanvas.Handle := GetWindowDc(Handle);
  try
    
GetObject(Canvas.Font.Handle, SizeOf(LogFont), @LogFont);
    with LogFont do
    begin
      
lfEscapement   := 90 * 10;
      lfOrientation  := 90 * 10;
      lfOutPrecision := OUT_TT_ONLY_PRECIS;
      lfFaceName     := 'Arial';
      lfHeight       := Size;
      lfWeight       := FW_BOLD;
      lfQuality      := PROOF_QUALITY;
    end;
    with tmpCanvas do
    begin
      
Font.Handle := CreateFontIndirect(LogFont);
      Font.Color  := clWhite;
      Brush.Color := clNavy;
    end;
    x1 := GetSystemMetrics(SM_CXEDGE) + GetSystemMetrics(SM_CXBORDER);
    x2 := 20;
    y1 := GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYEDGE) +
          GetSystemMetrics(SM_CYBORDER) + 1;
    y2 := Height - GetSystemMetrics(SM_CYEDGE) - GetSystemMetrics(SM_CYBORDER);
    tmpRect := Rect(x1, y1, x2, y2);
    tmpCanvas.FillRect(tmpRect);
    DrawText(tmpCanvas.Handle, PChar(Texto), - 1, tmpRect, DT_BOTTOM or
      
DT_SINGLELINE);
  finally
    
tmpCanvas.Free;
  end;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  
VerticalTitleBar(MY_TITLE_TEXT, 12);
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  
VerticalTitleBar(MY_TITLE_TEXT, 12);
end;

end.


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners