ucGUI界面切换疑问
时间:10-02
整理:3721RD
点击:
我在做ucGUI界面,按下up键后,可以在表面的四个虚拟键上切换,现在碰到一个问题,就是在按下UP键后,跳过一个页面,是什么原因,程序是下面的!
#include <GUI.h>
#include "MyGui.h"
#include <WM.h>
#include <stddef.h>
#include <string.h>
#include "FRAMEWIN.h"
#include "BUTTON.h"
#include "BUTTON_Private.h"
#include "GUI_Protected.h"
extern const GUI_BITMAP bmtu_1;
extern const GUI_BITMAP bmtu_2;
extern const GUI_BITMAP bmtu_3;
extern const GUI_BITMAP bmtu_4;
extern const GUI_BITMAP bmtu_5;
unsigned int zhu_jie_mian_id=1;
static void Main_Callback(WM_MESSAGE * pMsg)
{
int id = 0;
switch (pMsg->MsgId)
{
case WM_KEY:
switch (((WM_KEY_INFO *)(pMsg->Data.p))->Key)
{
case GUI_KEY_UP:
zhu_jie_mian_id++;
switch(zhu_jie_mian_id)
{
case 1:
GUI_DrawBitmap(&bmtu_1,0,0);
break;
case 2:
GUI_DrawBitmap(&bmtu_2,0,0);
break;
case 3:
GUI_DrawBitmap(&bmtu_3,0,0);
break;
case 4:
GUI_DrawBitmap(&bmtu_4,0,0);
break;
}
break;
case GUI_KEY_DOWN:
zhu_jie_mian_id--;
switch(zhu_jie_mian_id)
{
case 1:
GUI_DrawBitmap(&bmtu_1,0,0);
break;
case 2:
GUI_DrawBitmap(&bmtu_2,0,0);
break;
case 3:
GUI_DrawBitmap(&bmtu_3,0,0);
break;
case 4:
GUI_DrawBitmap(&bmtu_4,0,0);
break;
}
//if(zhu_jie_mian_id == 0)
// zhu_jie_mian_id = 1;
break;
case GUI_KEY_ESCAPE:
break;
case GUI_KEY_ENTER:
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
static void Main_Create(void)
{
GUI_HWIN hWin = 0;
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
//建立新窗口
hWin = FRAMEWIN_Create( NULL, NULL , FRAMEWIN_CF_ACTIVE,0,0,640, 480);
//hWin = WM_GetFirstChild(m_MainWin.hFrame); //获得窗口桌面
GUI_SetDrawMode(GUI_DRAWMODE_NORMAL);
GUI_DrawBitmap(&bmtu_1,0,0);
/*if(zhu_jie_mian_id == 1)
GUI_DrawBitmap(&bmtu_1,0,0);
if(zhu_jie_mian_id == 2)
GUI_DrawBitmap(&bmtu_2,0,0);
if(zhu_jie_mian_id == 3)
GUI_DrawBitmap(&bmtu_3,0,0);
if(zhu_jie_mian_id == 4)
GUI_DrawBitmap(&bmtu_4,0,0);*/
WM_SetCallback(WM_HBKWIN,Main_Callback);
WM_SetFocus(hWin);
}
void Test(void)
{
//WINAPP_NumpadInit();
Main_Create();
}
#include <GUI.h>
#include "MyGui.h"
#include <WM.h>
#include <stddef.h>
#include <string.h>
#include "FRAMEWIN.h"
#include "BUTTON.h"
#include "BUTTON_Private.h"
#include "GUI_Protected.h"
extern const GUI_BITMAP bmtu_1;
extern const GUI_BITMAP bmtu_2;
extern const GUI_BITMAP bmtu_3;
extern const GUI_BITMAP bmtu_4;
extern const GUI_BITMAP bmtu_5;
unsigned int zhu_jie_mian_id=1;
static void Main_Callback(WM_MESSAGE * pMsg)
{
int id = 0;
switch (pMsg->MsgId)
{
case WM_KEY:
switch (((WM_KEY_INFO *)(pMsg->Data.p))->Key)
{
case GUI_KEY_UP:
zhu_jie_mian_id++;
switch(zhu_jie_mian_id)
{
case 1:
GUI_DrawBitmap(&bmtu_1,0,0);
break;
case 2:
GUI_DrawBitmap(&bmtu_2,0,0);
break;
case 3:
GUI_DrawBitmap(&bmtu_3,0,0);
break;
case 4:
GUI_DrawBitmap(&bmtu_4,0,0);
break;
}
break;
case GUI_KEY_DOWN:
zhu_jie_mian_id--;
switch(zhu_jie_mian_id)
{
case 1:
GUI_DrawBitmap(&bmtu_1,0,0);
break;
case 2:
GUI_DrawBitmap(&bmtu_2,0,0);
break;
case 3:
GUI_DrawBitmap(&bmtu_3,0,0);
break;
case 4:
GUI_DrawBitmap(&bmtu_4,0,0);
break;
}
//if(zhu_jie_mian_id == 0)
// zhu_jie_mian_id = 1;
break;
case GUI_KEY_ESCAPE:
break;
case GUI_KEY_ENTER:
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
static void Main_Create(void)
{
GUI_HWIN hWin = 0;
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
//建立新窗口
hWin = FRAMEWIN_Create( NULL, NULL , FRAMEWIN_CF_ACTIVE,0,0,640, 480);
//hWin = WM_GetFirstChild(m_MainWin.hFrame); //获得窗口桌面
GUI_SetDrawMode(GUI_DRAWMODE_NORMAL);
GUI_DrawBitmap(&bmtu_1,0,0);
/*if(zhu_jie_mian_id == 1)
GUI_DrawBitmap(&bmtu_1,0,0);
if(zhu_jie_mian_id == 2)
GUI_DrawBitmap(&bmtu_2,0,0);
if(zhu_jie_mian_id == 3)
GUI_DrawBitmap(&bmtu_3,0,0);
if(zhu_jie_mian_id == 4)
GUI_DrawBitmap(&bmtu_4,0,0);*/
WM_SetCallback(WM_HBKWIN,Main_Callback);
WM_SetFocus(hWin);
}
void Test(void)
{
//WINAPP_NumpadInit();
Main_Create();
}
case 1:
GUI_DrawBitmap(&bmtu_1,0,0);
break;
case 2:
GUI_DrawBitmap(&bmtu_2,0,0);
break;
case 3:
GUI_DrawBitmap(&bmtu_3,0,0);
break;
case 4:
GUI_DrawBitmap(&bmtu_4,0,0);
break;
}
这样的哦
case 1:
GUI_DrawBitmap(&bmtu_1,0,0);
break;
case 2:
GUI_DrawBitmap(&bmtu_2,0,0);
break;
case 3:
GUI_DrawBitmap(&bmtu_3,0,0);
break;
case 4:
GUI_DrawBitmap(&bmtu_4,0,0);
break;
}
这里出问题
case 1:
GUI_DrawBitmap(&bmtu_1,0,0);
break;
case 2:
GUI_DrawBitmap(&bmtu_2,0,0);
break;
case 3:
GUI_DrawBitmap(&bmtu_3,0,0);
break;
case 4:
GUI_DrawBitmap(&bmtu_4,0,0);
break;
}