如何让memo背景色自动与窗口背景色一致 ( 积分: 9 )

  • 主题发起人 主题发起人 sunjunfeng3
  • 开始时间 开始时间
S

sunjunfeng3

Unregistered / Unconfirmed
GUEST, unregistred user!
我发现leabel控件等背景色会自动与窗口保持一致,窗口色色后,颜色也自动会变,可是为什么memo却不能呢,如何做才能保持一致?
 
就是让memmo的背景色透明
 
procedure TCustomLabel.Paint;
const
Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
WordWraps: array[Boolean] of Word = (0, DT_WORDBREAK);
var
Rect, CalcRect: TRect;
DrawStyle: Longint;
begin
with Canvas do
begin
if not Transparent then
begin
Brush.Color := Self.Color;
Brush.Style := bsSolid;
FillRect(ClientRect);
end;
Brush.Style := bsClear;
Rect := ClientRect;
{ DoDrawText takes care of BiDi alignments }
DrawStyle := DT_EXPANDTABS or WordWraps[FWordWrap] or Alignments[FAlignment];
{ Calculate vertical layout }
if FLayout <> tlTop then
begin
CalcRect := Rect;
DoDrawText(CalcRect, DrawStyle or DT_CALCRECT);
if FLayout = tlBottom then OffsetRect(Rect, 0, Height - CalcRect.Bottom)
else OffsetRect(Rect, 0, (Height - CalcRect.Bottom) div 2);
end;
DoDrawText(Rect, DrawStyle);
end;
end;


这段代码码可以看出来
要实现一致的话,可以给它赋值![:D]
 
Memo1.ParentColor := true
 
后退
顶部