zoukankan      html  css  js  c++  java
  • 修改的Vista风格多功能日历Demo

    Vista风格日历程序来源于网上开源程序,首先感谢下原作者的无私奉献!

    在原来基础上稍作修改添加了一些演示,效果如图:

     

    新增演示:1,gdi绘制小图标,

                  2,带图标的ComboBox 

    实际应用:

               可以抓取气象网上的气象信息,做一个完善的小程序。


    代码:

    带图标的ComboBox
    public class UIcombox : ComboBox
        {
            
    public UIcombox()
            {
                DrawMode 
    = DrawMode.OwnerDrawFixed;
            }
            
    private ImageList _ListaImg = new ImageList();

            
    public ImageList ImageList
            {
                
    get
                {
                    
    return _ListaImg;
                }
                
    set
                {
                    _ListaImg 
    = value;
                }
            }

            
    private bool _ShowTitle = true;
            
    public bool ShowTitle
            {
                
    get
                {
                    
    return _ShowTitle;
                }
                
    set
                {
                    _ShowTitle 
    = value;
                }
            }
            
    protected override void OnDrawItem(DrawItemEventArgs e)
            {
                
    if (e.Index >= 0)
                {
                    e.DrawBackground();
                    e.DrawFocusRectangle();
                    Rectangle bounds 
    = new Rectangle();

                    bounds 
    = e.Bounds;

                    
    string s = "";
                    
    if (_ShowTitle == true)
                    {
                        s 
    = this.Items[e.Index].ToString();
                    }

                    
    try
                    {
                        
    if (_ListaImg.Images.Count != 0)
                        {
                            
    //_ListaImg.ImageSize = new Size(this.Height - 8, this.Height - 8);  /*此处new操作之后_ListImg会为NULL*/
                            _ListaImg.Draw(e.Graphics, bounds.Left, bounds.Top, e.Index);
                            e.Graphics.DrawString(s, e.Font, 
    new SolidBrush(e.ForeColor), bounds.Left + _ListaImg.Images[e.Index].Width, bounds.Top);
                        }
                        
    else
                        {
                            e.Graphics.DrawString(s, e.Font, 
    new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
                        }
                    }
                    
    catch   /*ImageList中Images尽量与ComBox中Items对应*/
                    {
                        e.Graphics.DrawString(s, e.Font, 
    new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
                    }
                }
                
    base.OnDrawItem(e);
            }
        }

    完整项目下载: /Files/cxwx/VistaCalendarProject.rar

  • 相关阅读:
    记一次网站迁移的过程
    如何才能搜索微信群和网盘群
    2021最新车载u盘歌曲集合,每轴更新。想要拉你入群
    工具分享:目录生成器
    福利,剪映PC版来了~ 支持windos系统和苹果系统
    微信8.0来了,可以加1w人好友,微商必看!!!
    centOS7安装 redis server
    Task handler raised error: ValueError('not enough values to unpack (expected 3, got 0)')
    《More Effective C++》读书笔记(下)
    《More Effective C++》读书笔记(中)
  • 原文地址:https://www.cnblogs.com/cxwx/p/1766665.html
Copyright © 2011-2022 走看看