AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Text in Titelzeile eines Formulars positionieren
Thema durchsuchen
Ansicht
Themen-Optionen

Text in Titelzeile eines Formulars positionieren

Ein Thema von eddy · begonnen am 1. Nov 2003 · letzter Beitrag vom 4. Nov 2003
Antwort Antwort
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#1

Re: Text in Titelzeile eines Formulars positionieren

  Alt 4. Nov 2003, 00:31
Oder besser:
Delphi-Quellcode:
type
  TForm1 = class(TForm)
  private
    { Private-Deklarationen }
    procedure WMNCPAINT(var Msg: TMessage); Message WM_NCPAINT;
    procedure WMNCACTIVATE(var msg: TMessage); Message WM_NCACTIVATE;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

const
  MYCAPTION = 'Meine zentrierte Fenster-Caption';

procedure PaintCaption(hWnd: THandle; WndCaption: String);
var
  dc : HDC;
  CaptRect, WndRect: TRect;
begin
  dc := GetWindowDC(hWnd);
  GetWindowRect(hWnd, WndRect);
  CaptRect.Left := GetSystemMetrics(SM_CXEDGE);
  CaptRect.Top := GetSystemMetrics(SM_CYEDGE)+2;
  CaptRect.Right := WndRect.right-WndRect.Left-GetSystemMetrics(SM_CYEDGE);
  CaptRect.Bottom := GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYEDGE);
  SetBkMode(dc, TRANSPARENT);
  SetTextColor(dc, RGB(255, 255, 255));
  DrawText(dc, @WndCaption[1], lstrlen(@WndCaption[1]), CaptRect, DT_CENTER or DT_VCENTER);
  ReleaseDC(hWnd, dc);
end;

procedure TForm1.WMNCPAINT(var Msg: TMessage);
begin
  Inherited;
  if msg.Msg = WM_NCPAINT then
  begin
    PaintCaption(Self.Handle, MyCaption);
  end;
end;

procedure TForm1.WMNCACTIVATE(var msg: TMessage);
begin
  Inherited;
  if msg.Msg = WM_NCACTIVATE then
    PaintCaption(Form1.Handle, MyCaption);
end;
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:37 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz