zoukankan      html  css  js  c++  java
  • TControlStyle.csParentBackground的作用(附Delphi里的所有例子,待续)

    Only applicable when Themes are enabled in applications on Windows XP. Causes the parent to draw its background into the control's background. This is useful for controls that need to show their parent's theme elements, such as aTPanel or TFrame that appears on a TPageControlTWinControl introduces a protected ParentBackground property that includes/excludes the csParentBackground control style.

    ------------------------------------------------------------------------------------

    在Controls.pas单元里的使用:

    procedure TWinControl.WMEraseBkgnd(var Message: TWMEraseBkgnd);
    begin
      with ThemeServices do
      if ThemesEnabled and Assigned(Parent) and (csParentBackground in FControlStyle) then
        begin
          { Get the parent to draw its background into the control's background. }
          DrawParentBackground(Handle, Message.DC, nil, False);
        end
        else
        begin
          { Only erase background if we're not doublebuffering or painting to memory. }
          if not FDoubleBuffered or
             (TMessage(Message).wParam = TMessage(Message).lParam) then
            FillRect(Message.DC, ClientRect, FBrush.Handle);
        end;
    
      Message.Result := 1;
    end;
    
    procedure TWinControl.CMInvalidate(var Message: TMessage);
    var
      I: Integer;
    begin
      if HandleAllocated then
      begin
        if Parent <> nil then Parent.Perform(CM_INVALIDATE, 1, 0);
        if Message.WParam = 0 then
        begin
          InvalidateRect(FHandle, nil, not (csOpaque in ControlStyle));
          { Invalidate child windows which use the parentbackground when themed }
          if ThemeServices.ThemesEnabled then
            for I := 0 to ControlCount - 1 do
              if csParentBackground in Controls[I].ControlStyle then
                Controls[I].Invalidate;
        end;
      end;
    end;
    
    function TWinControl.GetParentBackground: Boolean;
    begin
      Result := csParentBackground in ControlStyle;
    end;
    
    procedure TWinControl.SetParentBackground(Value: Boolean);
    begin
      if ParentBackground <> Value then
      begin
        if Value then
          ControlStyle := ControlStyle + [csParentBackground]
        else
          ControlStyle := ControlStyle - [csParentBackground];
        Invalidate;
      end;
    end;

    问题是,D7里的ThemeServices.ThemesEnabled始终都是False,即使使用了Windows皮肤也是如此,莫非需要做什么额外的设置?

  • 相关阅读:
    ( 三十一 )、 SpringBoot项目启动自动执行sql脚本
    转:OAuth 2.0 介绍
    采坑:python base64
    Redis学习——数据结构介绍(四)
    美化你的博客园,flash插件的使用
    Redis学习——详解Redis配置文件(三)
    Redis学习——Windows环境下Redis的安装(二)
    Redis学习——Linux环境下Redis的安装(一)
    NPM 安装速度慢,镜像修改
    日志配置(springboot、mybatis、Lombok)
  • 原文地址:https://www.cnblogs.com/findumars/p/5369928.html
Copyright © 2011-2022 走看看