AGB  ·  Datenschutz  ·  Impressum  







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

ComboBox wird falsch gezeichnet

Offene Frage von "Andreas L."
Ein Thema von Andreas L. · begonnen am 20. Okt 2011 · letzter Beitrag vom 27. Okt 2011
 
Andreas L.

Registriert seit: 23. Mai 2011
Ort: Furth im Wald
308 Beiträge
 
Delphi 11 Alexandria
 
#1

ComboBox wird falsch gezeichnet

  Alt 20. Okt 2011, 13:01
Hallo,

ich habe mir eine Komponente von TCustomPanel abgeleitet. Platziere ich darauf eine TComboBox mit Style csDropDownList wird diese falsch gezeichnet. Auf einem normalen TPanel sieht die Box aber richtig aus (siehe Bild). Wie kommt das zu stande? Was mache ich falsch?

Delphi-Quellcode:
procedure TCsCustomPanel.Paint;
begin
  inherited Paint;

  RefreshPadding;

  if FDrawHovered then
  begin
    if FEnableHoverColor then
      inherited Color := FHoverColor;

    inherited Paint;

    if FEnableHoverBorder then
    begin
      DrawBorder(FHoverBorderTop, cbpTop);
      DrawBorder(FHoverBorderBottom, cbpBottom);
      DrawBorder(FHoverBorderRight, cbpRight);
      DrawBorder(FHoverBorderLeft, cbpLeft);
    end;{
    else
    begin
      DrawBorder(FBorderLeft, cbpLeft);
      DrawBorder(FBorderRight, cbpRight);
      DrawBorder(FBorderTop, cbpTop);
      DrawBorder(FBorderBottom, cbpBottom);
    end; }

  end
  else
  begin
    inherited Color := FColor;
    inherited Paint;
    DrawBorder(FBorderLeft, cbpLeft);
    DrawBorder(FBorderRight, cbpRight);
    DrawBorder(FBorderTop, cbpTop);
    DrawBorder(FBorderBottom, cbpBottom);
  end;
end;

procedure TCsCustomPanel.Refresh;
begin
  inherited Refresh;

  Invalidate;

  if Assigned(FOnRefreshed) then
    OnRefreshed(Self);
end;

procedure TCsCustomPanel.DrawBorder(Style: TCsBorderStyle;
  Position: TCsBorderPosition);
var
  Coord: TPoint;
  BorderRect: TRect;
begin
  if Style.Visible and (Style.Width > 0) then
  begin
    // Startposition ermitteln
    Coord := GetBorderStartPosition(Position, Style.Width);
    BorderRect.TopLeft.X := Coord.X;
    BorderRect.TopLeft.Y := Coord.Y;

    // Endposition ermitteln
    Coord := GetBorderEndPosition(Position, Style.Width);
    BorderRect.BottomRight.X := Coord.X;
    BorderRect.BottomRight.Y := Coord.Y;

    Canvas.Brush.Color := Style.Color;

    Canvas.FillRect(BorderRect);

    // ggf. Schatten zeichnen
    if Style.ShadowVisible then
    begin
      Canvas.Pen.Color := Style.ShadowColor;
      Canvas.Pen.Width := 1;

      Canvas.PenPos := GetBorderShadowStartPostition(Position, Style.Width);

      Coord := GetBorderShadowEndPosition(Position, Style.Width);

      Canvas.LineTo(Coord.X, Coord.Y);
    end;

  end;
end;

procedure TCsCustomPanel.RefreshPadding;
var
  PaddLeft, PaddRight, PaddTop, PaddBottom: Integer;
begin

  // Padding links ermitteln
  PaddLeft := FPadding.Left;

  if FDrawHovered and (FHoverBorderLeft.Width > 0) and FHoverBorderLeft.Visible then
    PaddLeft := PaddLeft + FHoverBorderLeft.Width
  else
    PaddLeft := PaddLeft + FBorderLeft.Width;

  // Padding rechts ermitteln
  PaddRight := FPadding.Right;

  if FDrawHovered and (FHoverBorderRight.Width > 0) and FHoverBorderRight.Visible then
    PaddRight := PaddRight + FHoverBorderRight.Width
  else
    PaddRight := PaddRight + FBorderRight.Width;

  // Padding oben ermitteln
  PaddTop := FPadding.Top;

  if FDrawHovered and (FHoverBorderTop.Width > 0) and FHoverBorderTop.Visible then
    PaddTop := PaddTop + FHoverBorderTop.Width
  else
    PaddTop := PaddTop + FHoverBorderTop.Width;

  // Padding unten ermitteln
  PaddBottom := FPadding.Bottom;

  if FDrawHovered and (FHoverBorderBottom.Width > 0) and FHoverBorderBottom.Visible then
    PaddBottom := PaddBottom + FHoverBorderBottom.Width
  else
    PaddBottom := PaddBottom + FBorderBottom.Width;

  inherited Padding.Left := PaddLeft;
  inherited Padding.Right := PaddRight;
  inherited Padding.Top := PaddTop;
  inherited Padding.Bottom := PaddBottom;
end;
Angehängte Grafiken
Dateityp: png cspanel_combobox_error.png (21,1 KB, 60x aufgerufen)
Andreas Lauß
Blog
  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 07:58 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