|

楼主 |
发表于 2018-5-31 19:56:13
|
显示全部楼层
本帖最后由 hpdell 于 2018-5-31 20:17 编辑
你好,参考那个日历程序,获取点击位置的数据可以了,
但是 设置数据还是不行,
我现在是每s跟新一次,在定时器消息里面
/*
*********************************************************************************************************
* 函 数 名: GUI_ClockUpdate
* 功能说明: 更新时间
* 形 参: pMsg 消息指针变量
* 返 回 值: 无
*********************************************************************************************************
*/
static void GUI_ClockUpdate(WM_MESSAGE * pMsg)
{
char buf[30];
WM_HWIN hWin = pMsg->hWin;
/* Get the RTC current Time */
HAL_RTC_GetTime(&RtcHandle, &sTime, RTC_FORMAT_BIN); // 时间与日期需要同时获取,切记切记,
/* Get the RTC current Date */
HAL_RTC_GetDate(&RtcHandle, &sDate, RTC_FORMAT_BIN);
/* 更新时间 */
sprintf(buf,
"时间:%0.2d:%0.2d:%0.2d",
sTime.Hours,
sTime.Minutes,
sTime.Seconds);
TEXT_SetText(WM_GetDialogItem(hWin, GUI_ID_TEXT0), buf);
/* 更新日期 */
sprintf(buf,
"日期:20%0.2d/%0.2d/%0.2d ",
sDate.Year,
sDate.Month,
sDate.Date);
TEXT_SetText(WM_GetDialogItem(hWin, GUI_ID_TEXT1), buf);
}
/* 定时1秒更新一次时间 */
case WM_TIMER: 或者在 WM_PAINT 这个消息里面调用也行 ??????????
WM_InvalidateRect(hWin, &rRTC); //指定区域无效化
GUI_ClockUpdate(pMsg);
{
// 日历数据更新失败 ,原因不明待查 .... ..??
CALENDAR_DATE pDate;
pDate.Year = sDate.Year;
pDate.Month = sDate.Month;
pDate.Day = sDate.Date;
CALENDAR_SetDate(WM_GetDialogItem(pMsg->hWin,GUI_ID_CALENDAR0), &pDate);
}
|
|