Registriert seit: 23. Mai 2011
Ort: Furth im Wald
308 Beiträge
Delphi 11 Alexandria
|
ComboBox wird falsch gezeichnet
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;
|
|
Zitat
|