zoukankan      html  css  js  c++  java
  • 自绘制按钮

    介绍 我一直讨厌所谓的“聚焦矩形”窗口绘制按钮的焦点。所以我决定派生不显示这样一个矩形的自己的类。后来,我为按钮添加了一个图像支持,这就是它的开始。 使用的代码 在下载中是整个解决方案,所以您只需解压缩它并启动控制。查看项目的所有文件(我想你已经有Visual Studio.NET了)。然后你可以从“但是”类创建你自己的按钮。我为它提供了三个不同的构造函数。第一个使用位图对象显示在按钮上: 隐藏,复制Code

    public But(string str, Bitmap bitmap, int cx, int cy)
    {
        ResizeRedraw = true;            
        txt = str;//text caption of the button
        bmp = bitmap;//bitmap image to display
        bmp.MakeTransparent();
                
        MeasureSizes(cx, cy);//cx and cy are the desired width and height for the button
    }

    下一个是工作与图标: 隐藏,复制Code

    public But(string str, System.Drawing.Icon ico, int cx, int cy, int IconWidth, int IconHeight)
    {
        ResizeRedraw = true;            
        txt = str;
        ico = new Icon(ico, IconWidth, IconHeight);
        bmp = ico.ToBitmap();
        bmp.MakeTransparent();
    
        MeasureSizes(cx, cy);
    }

    最后一个(我经常使用)没有指定cx和cy(在MeasureSizes函数中,我提供了正确显示按钮所需的最小大小)。 隐藏,复制Code

    public But(string str, System.Drawing.Icon ico, int IconWidth, int IconHeight)
    {
        ResizeRedraw = true;            
        txt = str;
        ico = new Icon(ico, IconWidth, IconHeight);
        bmp = ico.ToBitmap();
        bmp.MakeTransparent();
    
        MeasureSizes(Width, Height);

    嗯,就是这样!我希望我自己绘制的按钮将有用。:) 许可证 本文没有附带明确的许可,但可能包含文章文本或下载文件本身的使用条款。如果有疑问,请通过下面的讨论区联系作者。可以在这里找到作者可能使用的许可证列表。 本文转载于:http://www.diyabc.com/frontweb/news463.html

  • 相关阅读:
    uitableview 默认选中行
    ipad 开发常用问题
    NSDate常用代码范例
    MOSS2010站点大文件上传设置
    scm xcode 配置
    ipad 开发 遇到BadAccess
    Tutorial: iPhone SQLite Encryption With SQLCipher
    uitableview
    UML建模——活动图(Activity Diagram)
    【随感】.........................
  • 原文地址:https://www.cnblogs.com/Dincat/p/13450167.html
Copyright © 2011-2022 走看看