你慢慢看,写的很乱。几年前做一个界面时写的底层:
static void _cbWinBase(WM_MESSAGE * pMsg) //页面回调函数
{
#ifdef __Db_cbWinBase
WM_HWIN HWIN;
#endif
__PageStr *pPage;
S32 NCode, Id;
GUI_PID_STATE State;
WM_MESSAGE Msg;
switch (pMsg->MsgId)
{
case WM_PAINT:
pPage = HWinToPageStr(pMsg->hWin);
GUI_DrawBitmap(pPage->Bmp,0,0);
GUI_DispStringAt(pPage->Caption, 0, 0);
#ifdef __Db_cbWinBase
HWIN = WM_GetActiveWindow(); //获得当前活动的窗口的句柄
LcdShow_Printf(" PaintHWIN-pMhWin=%d-%d ",HWIN,pMsg->hWin);
#endif
break;
case WM_TOUCH:
PageTouch(pMsg);
break;
case WM_TOUCH_CHILD:
PageTouch(pMsg);
Msg = *(WM_MESSAGE*)pMsg->Data.p;
State = *(GUI_PID_STATE*)Msg.Data.p;
if ((pMsg->hWin == ProStack.HWinPage[ProStack.Index-1].HWin) && (State.Pressed == 0)) //弹起时处理
{
if (ProStack.MaskHwin == NULL)
{
__HideKeyFun(pMsg);
}
else
{
ProStack.MaskHwin = NULL;
}
}
break;
case WM_NOTIFY_PARENT:
//LcdShow_Printf(" --HWIN=%d,%d-- MsgLock=%d-",pMsg->hWin, pMsg->hWinSrc,MsgLock);
//LcdShow_Printf(" --PARENT-- ");
Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */
NCode = pMsg->Data.v; /* Notification code */
switch (NCode)
{
case WM_NOTIFICATION_VALUE_CHANGED: // Value has changed
break;
case WM_NOTIFICATION_RELEASED: // React only if released
if (KeyIdCheck(0,Id) != NULL)
{ //当前页存在该按键
KeyIdToAction(Id)(pMsg); //运行相应的按键回调函数
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
static void _cbPage(WM_MESSAGE * pMsg) //页面回调函数
{
__PageStr *pPage;
#ifdef __Db_cbPage
WM_HWIN HWIN;
GUI_PID_STATE State;
WM_HWIN CurHWIN;
WM_MESSAGE Msg;
HWIN = WM_GetActiveWindow(); //获得当前活动的窗口的句柄
LcdShow_Printf(" -Cur-hWin-Msg=%d-%d-%d ",HWIN, pMsg->hWin, pMsg->MsgId);
if (ProStack.HWinPage[ProStack.Index-1].HWin != HWIN)
{
#ifdef __Db_cbPage
LcdShow_Printf("--cbErrHWin--");
#endif
//WM_DefaultProc(pMsg);
}
#endif
#ifdef __Db_cbPage
//LcdShow_Printf(" -hWin-Msg=%d-%d ",pMsg->hWin, pMsg->MsgId);
/*if ((pMsg->MsgId == 17) || (pMsg->MsgId == WM_TOUCH_CHILD) || (pMsg->MsgId == WM_TOUCH))
//if(pMsg->Data.p != NULL)
{
if (pMsg->MsgId == WM_TOUCH_CHILD)
{
Msg = *(WM_MESSAGE*)pMsg->Data.p;
State = *(GUI_PID_STATE*)Msg.Data.p;
}
else
State = *(GUI_PID_STATE*)pMsg->Data.p;
//if ((State.x>430) && (State.x<600))
{
LcdShow_Printf(" x,y,Pr=%d,%d,%d ", State.x, State.y, State.Pressed);
//CurHWIN = WM_Screen2hWin(101,101);
LcdShow_Printf(" HWIN=%d,%d ",pMsg->hWin, pMsg->hWinSrc);
//BUTTON_SetPressed(CurHWIN,State.Pressed);
//WIDGET_OrState(CurHWIN,BUTTON_STATE_PRESSED);
}
}*/
#endif
pPage = HWinToPageStr(pMsg->hWin);
switch (pPage->Type)
{
case WinBase:
_cbWinBase(pMsg);
break;
default:
break;
}
}
WM_HWIN __CreatePage(__PageStr Page, U32 x0, U32 y0) //创建页面
{
WM_HWIN CurrentHWIN;
WM_HWIN PageHWIN;
CurrentHWIN = WM_GetActiveWindow(); //获得当前活动的窗口的句柄
switch (Page.Type)
{
case WinBase:
PageHWIN = WM_CreateWindowAsChild(
(Page.x0+x0), (Page.y0+y0), Page.xSize, Page.ySize, CurrentHWIN, WM_CF_SHOW, _cbPage, 0);
break;
default:
break;
}
#ifdef __Db__CreatePage
LcdShow_Printf("\r\nCreaterCurHWIN=%d-%d, ",CurrentHWIN,PageHWIN);
LcdShow_Printf(" Page.Type=%d ",Page.Type);
#endif
return PageHWIN;
}
char __EntryPage(__PageStr *pPage, U32 x0, U32 y0) //进入页面,是可以返回当前页的
{
WM_HWIN HWIN;
WM_MESSAGE Message;
#ifdef __Db__EntryPage
LcdShow_Printf("_EntryPage0 ");
#endif
if (ProStack.Index < __PageMax)
{
ProStack.PageSwitch = TRUE;
#ifdef __Db__EntryPage
LcdShow_Printf("_EntryPage1 ");
#endif
__DelAllAction();
__FunDelAllVarRead();
#ifdef __Db__EntryPage
LcdShow_Printf(" EpPage=%x ",pPage);
#endif
HWIN = __CreatePage(*pPage,x0,y0); //创建页面
#ifdef __Db__EntryPage
LcdShow_Printf("_EntryPage2 ");
#endif
ProStackPush(HWIN, pPage);
WM_SelectWindow(HWIN);
WM_MakeModal(HWIN);
#ifdef __Db__EntryPage
LcdShow_Printf(" HWIN=%d ",HWIN);
#endif
__CreateDisp(*pPage);
#ifdef __Db__EntryPage
LcdShow_Printf("_EntryPage3 ");
#endif
__CreateKey(*pPage);
#ifdef __Db__EntryPage
LcdShow_Printf("_EntryPage4 ");
#endif
Message.MsgId = WM_PAINT;
WM_SendMessage(HWIN, &Message);
#ifdef __Db__EntryPage
LcdShow_Printf("_EntryPage5 ");
#endif
ProStack.PageSwitch = FALSE;
return Pass;
}
#ifdef __Db__EntryPage
LcdShow_Printf("_EntryPage6 ");
#endif
return Error;
}
char __JumpPage(__PageStr *pPage, U32 x0, U32 y0) //跳入页面,是不可以返回当前页的
{
WM_HWIN OldHWIN,NewHWIN;
if (ProStack.Index > 1)
{
ProStack.PageSwitch = TRUE;
#ifdef __Db__JumpPage
LcdShow_Printf(" __JumpStart ");
#endif
ProStackPull();
OldHWIN = ProStack.HWinPage[ProStack.Index].HWin;
WM_DeleteWindow(OldHWIN);
__DelAllAction();
__FunDelAllVarRead();
#ifdef __Db__JumpPage
LcdShow_Printf(" __JumpMid1 ");
#endif
OldHWIN = ProStack.HWinPage[ProStack.Index-1].HWin;
WM_MakeModal(OldHWIN);
WM_SelectWindow(OldHWIN);
NewHWIN = __CreatePage(*pPage,x0,y0); //创建页面
ProStackPush(NewHWIN, pPage);
WM_MakeModal(NewHWIN);
WM_SelectWindow(NewHWIN);
#ifdef __Db__JumpPage
LcdShow_Printf(" __JumpMid2 ");
#endif
__CreateDisp(*pPage);
__CreateKey(*pPage);
#ifdef __Db__JumpPage
LcdShow_Printf(" __JumpEnd ");
#endif
ProStack.PageSwitch = FALSE;
ProStack.MaskHwin = NewHWIN;
return Pass;
}
return Error;
}
char __ReturnPage(void) //返回上一级页面
{
WM_HWIN HWIN;
//LcdShow_Printf("__ReturnPage ");
if (ProStack.Index > 1)
{
ProStack.PageSwitch = TRUE;
ProStackPull();
HWIN = ProStack.HWinPage[ProStack.Index].HWin;
WM_DeleteWindow(HWIN);
#ifdef __Db__ReturnPage
LcdShow_Printf(" DelHWIN=%d ",HWIN);
#endif
__DelAllAction();
__FunDelAllVarRead();
HWIN = ProStack.HWinPage[ProStack.Index-1].HWin;
WM_MakeModal(HWIN);
WM_SelectWindow(HWIN);
__CreateActionKey(*ProStack.HWinPage[ProStack.Index-1].pPage);
#ifdef __Db__ReturnPage
LcdShow_Printf(" ReturnHWIN=%d ",HWIN);
HWIN = WM_GetActiveWindow(); //获得当前活动的窗口的句柄
LcdShow_Printf(" RCurHWIN=%d ",HWIN);
//OSTimeDly(1500);
GUI_Delay(1500);
HWIN = WM_GetActiveWindow(); //获得当前活动的窗口的句柄
LcdShow_Printf(" RCurHWIN=%d ",HWIN);
#endif
ProStack.PageSwitch = FALSE;
return Pass;
}
return Error;
}
|