BCG 使用之CBCGPCalendar控件

261 篇文章 10 订阅

日历控件的效果如下所示:

 实现这样的效果方法如下所示:

1、vs中拖入picture Control控件:

 

2、头文件中声明

CBCGPCalendar  m_wndCalendarCtrl;

3、实现文件中:

BOOL CBCGCalendarDlg::OnInitDialog()
{
    CBCGPDialog::OnInitDialog();

    // TODO: Add extra initialization here
    m_wndCalendarCtrl.CreateOnPlaceHolder(this, IDC_CALENDARLOCATION, (UINT)-1, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP);
    m_wndCalendarCtrl.EnableVisualManagerStyle(IsVisualManagerStyle());
    m_wndCalendarCtrl.SetSingleMonthMode();
    COleDateTime today = COleDateTime::GetCurrentTime();

    //设置颜色
    {
        int i = 0;
        static int daysMarked[] = { 1, 8, 10, 15, 25, 28 };
        CArray<DATE, DATE&> arMarkedDates;
        for (i = 0; i < sizeof(daysMarked) / sizeof(int); i++)
        {
            COleDateTime dayBold(today.GetYear(), today.GetMonth(), daysMarked[i], 0, 0, 0);
            arMarkedDates.Add(dayBold.m_dt);
        }
        m_wndCalendarCtrl.MarkDates(arMarkedDates);


        static int daysColor1[] = { 4, 5, 6 };
        for (i = 0; i < sizeof(daysColor1) / sizeof(int); i++)
        {
            COleDateTime dayColor(today.GetYear(), today.GetMonth(), daysColor1[i], 0, 0, 0);
            m_wndCalendarCtrl.SetDateColor(dayColor, RGB(255, 69, 0));
        }

        static int daysColor2[] = { 19, 20, 23 };

        for (i = 0; i < sizeof(daysColor2) / sizeof(int); i++)
        {
            COleDateTime dayColor(today.GetYear(), today.GetMonth(), daysColor2[i], 0, 0, 0);
            m_wndCalendarCtrl.SetDateColor(dayColor, RGB(30, 144, 255));
        }
    }
    m_wndCalendarCtrl.EnableTodayButton(true);
    m_wndCalendarCtrl.EnableWeekNumbers(true);
    

    return TRUE;  // return TRUE  unless you set the focus to a control
}

具体点击选择之类的请具体参见类

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值