首先,如果需要更多信息,请问我是否愿意添加更多信息。 (无法在明天09:00 GMT + 1之前回答)
使用圆形组合框和圆形按钮(TCustomControls)在delphi中处理应用程序 出现的问题主要是组件在某种程度上彼此分层的问题 如图1所示(下图)
表格的背景仍然在角落周围闪耀,而组件则相互重叠。
对于每个自定义控件,我自己都在绘制组件。但是,我似乎无法掌握如何让它按原样运作。
我已尝试过以下
- Params.exStyle := Params.exStyle + WS_EX_TRANSPARENT;
- ScanLine and set the pixels equal to the background (which doesn't work as one
would suspect)
- WSEraseBackground procedure empty
但似乎没有什么能解决我的问题(WS_EX_TRANSPARENT确实如此,但是当点击某个组件时,它似乎会翻转Z顺序)
我重写了paint事件,只绘制了圆角矩形(不应该是一个巨大的imo)
procedure TRoundedComboBox.Paint;
var
Rect : TRect;
procedure DrawFirst();
begin
{first}
Canvas.Pen.Color := FColorArray[0];
Canvas.Brush.Color := FColorArray[0];
Canvas.RoundRect(0,
0,
width,
FDefaultComboBoxHeight,
20,
20);
end;
procedure DrawFirstInner();
begin
{first inner}
Canvas.Pen.Color := FColorArray[1];
Canvas.Brush.Color := FColorArray[1];
Canvas.RoundRect(0,
1,
width,
FDefaultComboBoxHeight,
20,
20);
end;
procedure DrawSecondInner();
begin
{second inner}
Canvas.Pen.Color := FColorArray[2];
Canvas.Brush.Color := FColorArray[2] ;
Canvas.RoundRect(0,
round(FDefaultComboBoxHeight /2),
width,
FDefaultComboBoxHeight,
20,
20);
end;
procedure DrawText();
begin
{Text}
Canvas.Font := FFont;
Canvas.Font.Color := FColorArray[3];
Canvas.Brush.Style := bsClear;
FTextRect := TRect.Create(4, 0, width -20, FDefaultComboBoxHeight);
Canvas.TextRect(FTextRect,
12,
round(FTextRect.Height /2) - round(Canvas.TextExtent(FText).Height /2),
FText);
end;
procedure DrawTriangle();
begin
{Triangle}
Canvas.MoveTo(FPoints[0].x, FPoints[0].y);
Canvas.Pen.Color := FColorArray[4];
Canvas.Brush.Color := FColorArray[4];
Canvas.Polygon(FPoints);
end;
begin
//inherited;
FListBox.Invalidate;
FListBox.Visible := FEnabledBtnDown;
if (FEnabledBtnDown) then
begin
FlistBOx.SetFocus;
end;
Height := IfThen (FEnabledBtnDown, FMaxmimumComboBoxHeight, FDefaultComboBoxHeight);
DrawFirst;
DrawFirstInner;
DrawSecondInner;
DrawTriangle;
DrawText;
end;
答案 0 :(得分:1)
您可以从TCustomTransparentControl(单位Controls.pas)派生。如果这不是一个选项,请看看TCustomTransparentControl如何工作。