初级会员
- 积分
- 82
- 金钱
- 82
- 注册时间
- 2016-4-6
- 在线时间
- 12 小时
|
5金钱
我想做的事是这样的:创建一个窗口,上面有一个进度条PROGBAR,用WM定时器来更新它的数值,1秒让它增加1。想要的效果是这样的:
#include "DIALOG.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_PROGBAR_0 (GUI_ID_USER + 0x01)
int Flag = 0;
// USER START (Optionally insert additional defines)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
{ PROGBAR_CreateIndirect, "Progbar", ID_PROGBAR_0, 76, 89, 155, 38, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
// Initialization of 'Window'
hItem = pMsg->hWin;
WINDOW_SetBkColor(hItem, GUI_LIGHTBLUE);
// Initialization of 'Progbar'
hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGBAR_0);
PROGBAR_SetFont(hItem, GUI_FONT_6X8);
|
最佳答案
查看完整内容[请看2#楼]
找到问题了,定时器创建的问题,把WM_HWIN CreateWindow(void)函数注释掉;在void MainTask(void)中添加:
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
将hTimer = WM_CreateTimer(WM_HBKWIN,0,1000,0);改为hTimer = WM_CreateTimer(hWin,0,1000,0);
就搞定了
|