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

 

    摘要:背景资料: 本人开始java开发是最近两个月的事,在一个项目中决定是使用struts框架还是自己开发框架,我犹豫不决。 于是开始看struts的代码,最後决定使用struts,但自己做一些扩展。 由于本人jsp,java等接触时间太短,如有不对的地方或者更好的办法,请各位指教。 相关资源清单: struts1.1的源代码 jakarta commons-beanutils1.6.1的源代码 动机:......
    摘要:如何嵌入(docking)一个工具条(how to docking a toolbar enabledocking(cbrs_align_any); // initialize dialog bar m_wndquickconnectif (!m_wndquickconnect.create(this, idd_quickconnect,//idd_quickconnect is a toolba......


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

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

  【推荐阅读:wap 开发笔记 (一)

       本文以平面按钮为例,写一个按钮颜色与边框颜色能任意更改的自定义按钮控件,希望能起到抛砖引玉的作用. 【扩展信息:用弹出确认框来确认删除内容(信息动态生成

 

 

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

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:


...   下一页
 ·注册表    »显示摘要«
    摘要:this class--cregkey--- is used for operate on register.if you want to get more,please goto www.confach.533.net then click visual vc++,thank you! 1).h file // regkey.h: interface for the cregkey class.......
» 本期热门文章:

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