AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Mehrzeiliger Header im VST

Ein Thema von Trille · begonnen am 3. Apr 2008 · letzter Beitrag vom 1. Jul 2011
 
madas

Registriert seit: 9. Aug 2007
207 Beiträge
 
#4

AW: Mehrzeiliger Header im VST

  Alt 20. Jun 2011, 14:31
Keiner eine Idee?
Statt des VST den DrawTree nehmen und den Text selber malen.

Dazu im OnHeaderDrawQueryElements folgendes machen:

Include(Elements, hpeText); und im OnAdvancedHeaderDraw darauf reagieren.

Hier mal ein Beispiel (musst Du für Deine Zwecke anpassen):

Delphi-Quellcode:
procedure TForm.AdvancedHeaderDraw(Sender: TVTHeader; var PaintInfo: THeaderPaintInfo;
  const Elements: THeaderPaintElements);
var
  rNormalText, rResultText, rBemerkung, rTypWachstum: TRect;
  x, y: Integer;
  Text: WideString;
  Size: TSize;
begin
  inherited;
  if (hpeText in Elements) then
  begin
    // Trennlinien zeichnen
    if (PaintInfo.Column.Index >= abDieserSpalte) then
    begin
      rNormalText := PaintInfo.PaintRectangle;
      InflateRect(rNormalText, 0, -1);
      OffsetRect(rNormalText, -1, -1);
      if (PaintInfo.IsDownIndex) then
        OffsetRect(rNormalText, 1, 1);
      PaintInfo.TargetCanvas.Pen.Color := clInactiveBorder;
      PaintInfo.TargetCanvas.Pen.Width := 1;
      // Trennlinie Ansatz und typ. Wachstum
      y := rNormalText.Top;
      y := y + ((rNormalText.Bottom - rNormalText.Top) div 3);
      PaintInfo.TargetCanvas.MoveTo(rNormalText.Left, y);
      PaintInfo.TargetCanvas.LineTo(rNormalText.Right, y);
      // Trennlinie typ. Wachstum und Rest
      y := rNormalText.Top;
      y := y + (((rNormalText.Bottom - rNormalText.Top) div 3) * 2) + (FrameVSTTestItemList.Tree.TextMargin div 2);
      PaintInfo.TargetCanvas.MoveTo(rNormalText.Left, y);
      PaintInfo.TargetCanvas.LineTo(rNormalText.Right, y);
      x := rNormalText.Left + leftPartWidth;
      PaintInfo.TargetCanvas.MoveTo(x, y);
      PaintInfo.TargetCanvas.LineTo(x, rNormalText.Bottom);
    end;

    // Bereiche berechnen
    rNormalText := PaintInfo.PaintRectangle;
    InflateRect(rNormalText, -PaintInfo.Column.Margin, 0);
    if (PaintInfo.IsDownIndex) then
      OffsetRect(rNormalText, 1, 1);

    // Normalen Text bestimmen und berechnen
    Text := PaintInfo.Column.Text;
    GetTextExtentPoint32W(PaintInfo.TargetCanvas.Handle, PWideChar(Text), Length(Text), Size);
    if (PaintInfo.Column.Index > -1) and (Size.cx > (rNormalText.Right - rNormalText.Left)) then
      Text := ShortenString(PaintInfo.TargetCanvas.Handle, Text, (rNormalText.Right - rNormalText.Left), 0);

    SetBkMode(PaintInfo.TargetCanvas.Handle, TRANSPARENT);
    SetTextColor(PaintInfo.TargetCanvas.Handle, ColorToRGB(clWindowText));

    if (PaintInfo.Column.Index >= abDieserSpalte) then
    begin
      Windows.DrawTextW(PaintInfo.TargetCanvas.Handle, PWideChar(Text),
        Length(Text), rNormalText, DT_LEFT or DT_TOP or DT_NOPREFIX or DT_SINGLELINE);
      OffsetRect(rNormalText, 0, -2);

      // typ. Wachstum zeichnen
      rTypWachstum := rNormalText;
      Text := 'typ. Wachstum';
      GetTextExtentPoint32W(PaintInfo.TargetCanvas.Handle, PWideChar(Text), Length(Text), Size);
      if (PaintInfo.Column.Index > -1) and (Size.cx > (rTypWachstum.Right - rTypWachstum.Left)) then
        Text := ShortenString(PaintInfo.TargetCanvas.Handle, Text, (rTypWachstum.Right - rTypWachstum.Left), 0);
      Windows.DrawTextW(PaintInfo.TargetCanvas.Handle, PWideChar(Text),
        Length(Text), rTypWachstum, DT_LEFT or DT_VCENTER or DT_NOPREFIX or DT_SINGLELINE);

      // unteren Bereich zeichnen
      rResultText := rNormalText;
      //rResultText.Right := rResultText.Left + ((rResultText.Right-rResultText.Left) div 2) - PaintInfo.Column.Margin;
      rResultText.Right := rResultText.Left + leftPartWidth - PaintInfo.Column.Margin;
      Text := 'Kultur';
      GetTextExtentPoint32W(PaintInfo.TargetCanvas.Handle, PWideChar(Text), Length(Text), Size);
      if (PaintInfo.Column.Index > -1) and (Size.cx > (rResultText.Right - rResultText.Left)) then
        Text := ShortenString(PaintInfo.TargetCanvas.Handle, Text, (rResultText.Right - rResultText.Left), 0);
      Windows.DrawTextW(PaintInfo.TargetCanvas.Handle, PWideChar(Text),
        Length(Text), rResultText, DT_LEFT or DT_BOTTOM or DT_NOPREFIX or DT_SINGLELINE);

      rBemerkung := rNormalText;
      //rBemerkung.Left := rBemerkung.Left + ((rBemerkung.Right-rBemerkung.Left) div 2) + PaintInfo.Column.Margin;
      rBemerkung.Left := rBemerkung.Left + leftPartWidth + PaintInfo.Column.Margin;
      Text := 'Bemerkung';
      GetTextExtentPoint32W(PaintInfo.TargetCanvas.Handle, PWideChar(Text), Length(Text), Size);
      if (PaintInfo.Column.Index > -1) and (Size.cx > (rBemerkung.Right - rBemerkung.Left)) then
        Text := ShortenString(PaintInfo.TargetCanvas.Handle, Text, (rBemerkung.Right - rBemerkung.Left), 0);
      Windows.DrawTextW(PaintInfo.TargetCanvas.Handle, PWideChar(Text),
        Length(Text), rBemerkung, DT_LEFT or DT_BOTTOM or DT_NOPREFIX or DT_SINGLELINE);
    end else
    begin
      // Normalen Text ausgeben
      Windows.DrawTextW(PaintInfo.TargetCanvas.Handle, PWideChar(Text),
        Length(Text), rNormalText, DT_LEFT or DT_VCENTER or DT_NOPREFIX or DT_SINGLELINE);
    end;
  end;
end;
So oder so ähnlich sollte es klappen.
  Mit Zitat antworten Zitat
 


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 13:47 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