修改XPMenu让ToolButton在Down=True时正确显示

  XPMenu是一个不错的程序界面效果控件,但它也存在不少不足之处。我最近又对它作了一点修改。
  原因是我在程序里有一个ToolButton,其Style=tbsButton,当Down=True时,XPMenu绘制的效果效果跟Down=False时一样,也就是说根本看不出它是按下的。当把Style改为tbsCheck后,却能显示效果,但是底色很深。
  这个按钮来我是用来表示某个面板是否可以显示的,我希望它像OfficeXP的工具按钮那样,当工具条显示时,在按钮上画个边框即可,而不是以很深的底色显示。
  XPMenu绘制工具栏按钮是由TXPMenu.ToolBarDrawButton函数完成,原型为如下:

procedure TXPMenu.ToolBarDrawButton(Sender: TToolBar;  Button: TToolButton; State: TCustomDrawState; var DefaultDraw: Boolean);

  在函数内由以下代码决定按钮是否显示边框,以及用什么颜色作底色:

if (cdsHot in State) then
  begin
    if (cdsChecked in State) or (Button.Down) or (cdsSelected in State) then
      ACanvas.Brush.Color := FCheckedAreaSelectColor
    else
      ACanvas.brush.color := FBSelectColor;
    HasBorder := true;
    HasBkg := true;
  end;

if ((cdsChecked in State) and not (cdsHot in State)) then
  begin
    ACanvas.Brush.Color := FCheckedAreaColor;
    HasBorder := true;
    HasBkg := true;
  end;

if (cdsIndeterminate in State) and not (cdsHot in State) then
  begin
    ACanvas.Brush.Color := FBSelectColor;
    HasBkg := true;
  end;

  它忽略掉了非cdsHot、非cdsChecked状态下按钮的Down=True的情况的处理。因此只要加上相应的判断,并让HasBorder=true即可达到我希望的效果。修改后代码如下:

if (cdsHot in State) then
  begin
    if (cdsChecked in State) or (Button.Down) or (cdsSelected in State) then
      ACanvas.Brush.Color := FCheckedAreaSelectColor
    else
      ACanvas.brush.color := FBSelectColor;
    HasBorder := true;
    HasBkg := true;
  end;

if ((cdsChecked in State) and not (cdsHot in State)) then
  begin
    ACanvas.Brush.Color := FCheckedAreaColor;
    HasBorder := true;
    HasBkg := true;
  end;

{Modify: Conch 2005-3-10 在Down=true的按钮上画出边框}
  if (Button.Down) and not (cdsHot in State) then
  begin
    HasBorder := true;
    HasBkg := false;
  end;
//Conch

if (cdsIndeterminate in State) and not (cdsHot in State) then
  begin
    ACanvas.Brush.Color := FBSelectColor;
    HasBkg := true;
  end;

http://blog.csdn.net/nhconch/article/details/317429

时间: 2024-08-26 05:53:49

修改XPMenu让ToolButton在Down=True时正确显示的相关文章

[翻译]在API level 17以下时正确显示适应边界的ImageView

[翻译]在APIlevel 17以下时正确显示adjustViewBounds的ImageView Correct the ImageView's adjustViewBounds behaviour on API Level 17 and below with AdjustableImageView 原文地址: http://inthecheesefactory.com/blog/correct-imageview-adjustviewbounds-with-adjustable-imagev

easyUI draggable插件使用不当,导致拖动div内部文本框无法输入;设置echarts数据为空时就显示空白,不要动画和文字

先上一个Demo <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text

JDBCTemplate在AutoCommit为True时手动控制事务

这是工作中遇到的一个真实问题的处理过程,如果对分析过程不感兴趣,可以直接跳到最后看最终方案. 我们在持久化这一层,并没有用任何的ORM框架(无论是Hibernate还是MyBatis,亦或是DBUtils),而是采用了在JDBCTemplate基础上进行了简单的包装,同时我们也决定将AutoCommit设置为True,在sql语句执行完成后立即提交.这样做相比于@Transactional注解或者通过AOP来控制事务性能更好,也更方便. 在评估了优劣之后,便开始使用这种方式,随之我们也遇到了一个

cxgrid GridMode 等于 True 时的一些问题。

When using grid mode, the data controller loads a fixed number of dataset records into memory. The number of records to be loaded depends on the GridModeBufferCount property value. A user is permitted to perform data-related operations on the loaded

只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态。还请确保在应用程序配置的 // 节中包括 System.Web.SessionSta

首先搞清楚我们的目的,我的目的是验证用户是否登录,也就是Session["userName"]!=null 就ok了 开始的时候我是这么写的,结果报错,提示如上面标题的错误,查了半天资料都没搞清楚什么问题 public class BasePage:System.Web.UI.Page { public BasePage() { this.IsLogin(); } public void IsLogin() { if (Session["DateTime"] ==

UIButton的selected设为TRUE时在按下时显示自定义的背景图

在UIButton的selected设为TRUE后,需要在按钮高亮时,显示自定义的背景图. 经研究hightLighted和selected这两个状态是可以重叠的,就是button可以同时处于selectec和highlighted两个状态下. 从UIControlState的定义也可以看出: typedef NS_OPTIONS(NSUInteger, UIControlState) { UIControlStateNormal       = 0, UIControlStateHighlig

Popup 解决StayOpen=true时,置顶的问题

/// <summary> /// 解决StayOpen=true时,永远置顶问题的Popup控件 /// </summary> public class EasiNotePopup : Popup { public static readonly DependencyProperty IsTopmostProperty = DependencyProperty.Register("IsTopmost", typeof(bool), typeof(EasiNot

当TextBox的ReadOnly属性为true时,Postback后无法读取TextBox之值?

摘要:当TextBox的ReadOnly属性为true时,无法读取Text之值? 文章移至http://petekcchen.com/2009/07/cannot-read-textbox-value-after-postback-when-readonly-is-true.html 原文:大专栏  当TextBox的ReadOnly属性为true时,Postback后无法读取TextBox之值? 原文地址:https://www.cnblogs.com/petewell/p/11516571.

在 SharePoint 2010 打开网页出错时,显示实际的错误信息

每次打开错误页面时,SharePoint出错显示的都是友好信息“发生意外错误”,而且友好到您基本上无法明白到底出什么错,怎么办? 修改Web.config文件配置就可以了,就可以显示更详细的信息: 1. 将<customErrors mode="On" />的mode改为"Off" 2. 将<SafeMode ... CallStack="false" ...... AllowPageLevelTrace="false