当前位置:首页 » 服务器技术
开发技术指南» 文章正文
    引言: FlatStyle按钮自己做quot; style=&qu
 

 

    摘要: a).如何在工具栏中,加上图标和文字?(how to add icon and text) /********************************************************************//* *//* function name : createhottoolbar *//* description : create the main toolbar. *//* *//********************......
    摘要:********************************************************************//* *//* function name : oncreateclient *//* description : create some splitter windows. *//* *//*****************************************************************......


FlatStyle按钮自己做
flatstyle按钮自己做

       与c或vb比起来,使用c#写自定义控件,特别是从零开始写自定义控件,不知简化了多少倍,没有复杂而晦涩的消息映射,思路就像写应用程序一样如行云流水,一路畅通。学过delphi的人都知道有一套flatstyle控件,平面式的简约风格给用户带来了良好的视觉效果。但是看看他的源码,如果没有一定的windows底层功底,看起来可不是件容易的事。现在好了,有了c#这个异常强大的工具,我们就可以轻轻松松的写一个自己的flatstyle控件了。 【相关文章:公布TstringGrid增强控件Tcb

  【扩展阅读:一个体现Java接口及工厂模式优点的例子

       本文以平面按钮为例,写一个按钮颜色与边框颜色能任意更改的自定义按钮控件,希望能起到抛砖引玉的作用。 【扩展信息:.net事务处理并发性处理的意义(此文仅

 

 

       如果我们只是改变已有的控件的外观(如本例),那么最好继承原有的控件。如:

public class buttonlzh : system.windows.forms.button

 

       定义一个枚举类型,用来描述鼠标的状态:

              protected enum status

        {

            mouseenter,

            mouseleave,

            mousedown,

            mouseup

        }

   

       写一个画文字的函数:

       protected void drawstring(string strtext,graphics g)

        {

            stringformat sf=new stringformat();

            sf.linealignment=stringalignment.center;

            sf.alignment=stringalignment.center;

            g.drawstring(strtext,this.font,new solidbrush(color.blue),this.clientrectangle,sf);

        }

 

    填充按钮颜色及画边框颜色:

       protected void drawborder(status status,graphics g)

        {

            pen[] mousepen=new pen[4];//定义四支笔

            mousepen[(int)status.mousedown]=new pen(_mousedownbordercolor,2);

            mousepen[(int)status.mouseenter]=new pen(_mouseenterbordercolor,2);

            mousepen[(int)status.mouseleave]=new pen(_mouseleavebordercolor,2);

            mousepen[(int)status.mouseup]=new pen(_mouseupbordercolor,2);

 

            solidbrush[] mousebrush=new solidbrush[4];//定义四个笔刷

            mousebrush[(int)status.mousedown]=new solidbrush(_mousedowncolor);

            mousebrush[(int)status.mouseenter]=new solidbrush(_mouseentercolor);

            mousebrush[(int)status.mouseleave]=new solidbrush(_mouseleavecolor);

            mousebrush[(int)status.mouseup]=new solidbrush(_mouseupcolor);

 

            switch(status)

            {

                case status.mousedown:

                    g.fillrectangle(mousebrush[(int)status.mousedown],this.clientrectangle);

                    g.drawrectangle(mousepen[(int)status.mousedown],this.clientrectangle);                  

                    break;

 

                case status.mouseenter:


...   下一页
 ·在 linux 下使用优盘。    »显示摘要«
    摘要:mount /dev/sda1 /mnt/usb ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE