轉(zhuǎn)帖|其它|編輯:郝浩|2012-09-21 10:43:08.000|閱讀 342 次
概述:本文主要介紹如何應(yīng)用BCGControlBar在工具欄上添加datetimepicker控件。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
步驟:
1、在工具欄上定義菜單比如ID_DATE,ID_TIME
2、在CMainFrm中修改
(1)
LRESULT CMainFrame::OnToolbarReset(WPARAM wp,LPARAM)
{
//----Example----//
UINT uiToolBarId = (UINT) wp;
switch (uiToolBarId)
{
case IDR_MAINFRAME:
{
CBCGPToolbarDateTimeCtrl dateButton (ID_DATE,
CImageHash::GetImageOfCommand (ID_DATE, FALSE));
m_wndToolBar.ReplaceButton (ID_DATE, dateButton);
CBCGPToolbarDateTimeCtrl timeButton (ID_TIME,
CImageHash::GetImageOfCommand (ID_TIME, FALSE),
DTS_TIMEFORMAT | DTS_UPDOWN);
m_wndToolBar.ReplaceButton (ID_TIME, timeButton);
}
break;
}
//----Example----//
return 0;
}
(2)
void CMainFrame::OnViewCustomize()
{
//------------------------------------
// Create a customize toolbars dialog:
//------------------------------------
CBCGPToolbarCustomize* pDlgCust = new CBCGPToolbarCustomize (this,
TRUE /* Automatic menus scaning */
);
//----Example----//
CBCGPToolbarDateTimeCtrl dateButton (ID_DATE,
CImageHash::GetImageOfCommand (ID_DATE, FALSE));
pDlgCust- >ReplaceButton (ID_DATE, dateButton);
CBCGPToolbarDateTimeCtrl timeButton (ID_TIME,
CImageHash::GetImageOfCommand (ID_TIME, FALSE),
DTS_TIMEFORMAT | DTS_UPDOWN);
pDlgCust- >ReplaceButton (ID_TIME, timeButton);
//----Example----//
pDlgCust->Create ();
}
3、響應(yīng)菜單
添加OnDate、OnTime的菜單響應(yīng)消息
實(shí)現(xiàn)如下:
void CMainFrame::OnDate()
{
SYSTEMTIME t;
CString str;
CBCGPToolbarDateTimeCtrl::GetTimeAll(ID_DATE, &t);
CString sDate,sTime;
COleDateTime sd(t);
sDate=sd.Format( "%y-%m-%d");
CBCGPToolbarDateTimeCtrl::GetTimeAll(ID_TIME, &t);
COleDateTime st(t);
sTime=st.Format( "%H:%M:%S");
str.Format( "%s %s",sDate,sTime);
_StartTime.ParseDateTime(str);
}
void CMainFrame::OnTime()
{
SYSTEMTIME t;
CString str;
CBCGPToolbarDateTimeCtrl::GetTimeAll(ID_DATE, &t);
CString sDate,sTime;
COleDateTime sd(t);
sDate=sd.Format( "%y-%m-%d");
CBCGPToolbarDateTimeCtrl::GetTimeAll(ID_TIME, &t);
COleDateTime st(t);
sTime=st.Format( "%H:%M:%S");
str.Format( "%s %s",sDate,sTime);
_StartTime.ParseDateTime(str);
}
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:博客園