BREW 3.15 时间控件与文本控件和日期控件等其他控件的共同显示问题
如题,代码如下:#include "apeconference.h"
struct CBook {
INHERIT_CWindow(IWindow);
ITextCtl * m_pName; //会议名称
ITimeCtl * m_pTime; //会议时间
//ITextCtl * m_pTime; //会议时间
ITextCtl * m_pTimeLen;//会议时长
IDateCtl * m_pDate; //会议日期
IStatic * m_pText;
AEERect * m_pRect;
int m_nKeyCnt;
};
IWindow * CBook_New( Capeconference * pOwner )
{
CBook *pMe;
VTBL(IWindow) vtbl;
JulianType rJulianDate;
GETJULIANDATE(0, &rJulianDate);
AP_IWINDOW_SETVTBL(&vtbl, CBook_Enable, CBook_Redraw, CBook_HandleEvent, CBook_Delete);
pMe = (CBook *)CWindow_New(sizeof(CBook), pOwner, &vtbl);
if (!pMe)
{
return NULL;
}
pMe->m_nKeyCnt = 0;
IDISPLAY_ClearScreen( pMe->m_pIDisplay );
/*malloc*/
pMe->m_pRect = MALLOC(4*sizeof(AEERect));
SETAEERECT(&(pMe->m_pRect[0]), 20,20,200,40);
SETAEERECT(&(pMe->m_pRect[1]), 20,80,80,80);
//SETAEERECT(&(pMe->m_pRect[2]), 20,160,200,40); //文本控件
SETAEERECT(&(pMe->m_pRect[2]), 140,100,60,40); //时间控件
SETAEERECT(&(pMe->m_pRect[3]), 20,200,200,40);
//会议名称输入框
ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_TEXTCTL, (void*)&pMe->m_pName);
ITEXTCTL_SetTitle(pMe->m_pName, APECONFERENCE_RES_FILE , IDS_STRING_CFNAME, NULL);
ITEXTCTL_SetRect(pMe->m_pName, &(pMe->m_pRect[0]));
ITEXTCTL_SetProperties(pMe->m_pName, TP_FRAME | TP_FIXSETRECT);
ITEXTCTL_SetMaxSize(pMe->m_pName, 20);
//输入模式设置为数字、字母、拼音
ITEXTCTL_SetInputMode(pMe->m_pName,AEE_TM_CURRENT | AEE_TM_NUMBERS | AEE_TM_PINYIN | AEE_TM_LETTERS);
ITEXTCTL_SetActive(pMe->m_pName, TRUE);
//会议日期输入框
ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_DATECTL, (void*)&pMe->m_pDate);
IDATECTL_SetRect(pMe->m_pDate, &(pMe->m_pRect[1]));
IDATECTL_SetTitle(pMe->m_pDate, APECONFERENCE_RES_FILE, IDS_STRING_CFDATE, NULL);
//IDATECTL_SetProperties( pMe->m_pDate, DFMT_YYYY_MM_DD );
//set the default date
//IDATECTL_SetDate(pMe->m_pDate, 2009, 8, 24);
IDATECTL_SetDate(pMe->m_pDate, rJulianDate.wYear, rJulianDate.wMonth, rJulianDate.wDay);
IDATECTL_SetActive(pMe->m_pDate, FALSE);
//时间(文本控件)
/*ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_TEXTCTL, (void*)&pMe->m_pTime);
ITEXTCTL_SetTitle(pMe->m_pTime, APECONFERENCE_RES_FILE , IDS_STRING_CFTIME, NULL);
ITEXTCTL_SetRect(pMe->m_pTime, &(pMe->m_pRect[2]));
ITEXTCTL_SetText(pMe->m_pTime, L"12:30", -1);
ITEXTCTL_SetProperties(pMe->m_pTime, TP_FRAME | TP_FIXSETRECT);
ITEXTCTL_SetMaxSize(pMe->m_pTime, 20);
//输入模式设置为数字、字母、拼音
ITEXTCTL_SetInputMode( pMe->m_pTime,AEE_TM_NUMBERS );
ITEXTCTL_SetActive(pMe->m_pTime, FALSE);*/
//会议时间输入(时间控件)
ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_COUNTDOWNCTL, (void *)&pMe->m_pTime);
ITIMECTL_SetTime(pMe->m_pTime, GETTIMEMS());
ITIMECTL_SetRect(pMe->m_pTime, &(pMe->m_pRect[2]));
ITIMECTL_SetProperties(pMe->m_pTime, TP_AUTOREDRAW);
ITIMECTL_SetActive(pMe->m_pTime, FALSE);
//会议时长
ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_TEXTCTL, (void*)&pMe->m_pTimeLen);
ITEXTCTL_SetTitle(pMe->m_pTimeLen, APECONFERENCE_RES_FILE , IDS_STRING_CFLENGTH, NULL);
ITEXTCTL_SetRect(pMe->m_pTimeLen, &(pMe->m_pRect[3]));
ITEXTCTL_SetProperties(pMe->m_pTimeLen, TP_FRAME | TP_FIXSETRECT);
ITEXTCTL_SetMaxSize(pMe->m_pTimeLen, 20);
//输入模式设置为数字、字母、拼音
ITEXTCTL_SetInputMode( pMe->m_pTimeLen,AEE_TM_NUMBERS );
ITEXTCTL_SetActive(pMe->m_pTimeLen, FALSE);
//更新界面
IDISPLAY_Update(pMe->m_pIDisplay);
return (IWindow*)pMe;
}
//释放资源
void CBook_Delete( IWindow * po )
{
CBook* pMe = ( CBook *)po;
if(pMe->m_pName != NULL)
{
ITEXTCTL_Release(pMe->m_pName);
pMe->m_pName = NULL;
}
if(pMe->m_pDate != NULL)
{
IDATECTL_Release(pMe->m_pDate);
pMe->m_pDate = NULL;
}
if(pMe->m_pTime != NULL)
{
ITIMECTL_Release(pMe->m_pTime);
//ITEXTCTL_Release(pMe->m_pTime);
pMe->m_pTime = NULL;
}
if(pMe->m_pTimeLen != NULL)
{
ITEXTCTL_Release(pMe->m_pTimeLen);
pMe->m_pTimeLen = NULL;
}
FREEIF( pMe->m_pRect );
}
void CBook_Enable(IWindow * po, boolean bEnable)
{
}
void CBook_Redraw(IWindow * po)
{
CBook* pMe = ( CBook *)po;
AECHAR szBuff[STR_BUFFER_SIZE+1];
AECHAR szBuff1[STR_BUFFER_SIZE+1];
ITEXTCTL_Redraw(pMe->m_pName);
IDATECTL_Redraw(pMe->m_pDate);
ISHELL_LoadResString(pMe->m_pIShell, APECONFERENCE_RES_FILE, IDS_MM_CANCEL, szBuff1, STR_BUFFER_SIZE*sizeof(AECHAR));
ISHELL_LoadResString(pMe->m_pIShell, APECONFERENCE_RES_FILE, IDS_MM_NEXT, szBuff, STR_BUFFER_SIZE*sizeof(AECHAR));
Display_SoftMenu((IApplet*)&(pMe->m_pOwner->a),NULL,szBuff,szBuff1);
}
boolean CBook_HandleEvent(IWindow * po, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
CBook * pMe = ( CBook * )po;
switch (eCode)
{
case EVT_KEY: // Process key event
case EVT_POINTER_DOWN:
//根据按键事件滚动屏幕
if( pMe->m_pName && ITEXTCTL_IsActive(pMe->m_pName) == TRUE)
{
if (ITEXTCTL_HandleEvent( pMe->m_pName, eCode, wParam, dwParam ))
{
return TRUE;
}
}
if( pMe->m_pDate && IDATECTL_IsActive(pMe->m_pDate) == TRUE )
{
if( wParam == AVK_LEFT )
{
if( pMe->m_nKeyCnt <= 0 )
{
ITEXTCTL_SetActive(pMe->m_pName, TRUE);
IDATECTL_SetActive(pMe->m_pDate, FALSE);
//ITEXTCTL_SetActive(pMe->m_pTime, FALSE);
ITIMECTL_SetActive(pMe->m_pTime, FALSE);
ITEXTCTL_SetActive(pMe->m_pTimeLen, FALSE);
pMe->m_nKeyCnt = 0;
break;
}
pMe->m_nKeyCnt--;
}
if( wParam == AVK_RIGHT )
{
pMe->m_nKeyCnt++;
if( pMe->m_nKeyCnt >= 3 )
{
ITEXTCTL_SetActive(pMe->m_pName, FALSE);
IDATECTL_SetActive(pMe->m_pDate, FALSE);
//ITEXTCTL_SetActive(pMe->m_pTime, TRUE);
ITIMECTL_SetActive(pMe->m_pTime, TRUE);
ITEXTCTL_SetActive(pMe->m_pTimeLen, FALSE);
pMe->m_nKeyCnt = 0;
break;
}
}
if (IDATECTL_HandleEvent( pMe->m_pDate, eCode, wParam, dwParam ))
{
return TRUE;
}
}
if( pMe->m_pTime && ITEXTCTL_IsActive(pMe->m_pTime) == TRUE )
{
if (ITIMECTL_HandleEvent( pMe->m_pTime, eCode, wParam, dwParam ))
{
//在输入2位数字后,在数字后直接添加时间间隔符号":"
/*AECHAR * pBuf;
ITEXTCTL_GetText(pMe->m_pTime, pBuf, 3);
STRCAT(pBuf, L":");
ITEXTCTL_SetText(pMe->m_pTime, pBuf, 5);*/
return TRUE;
}
}
case EVT_COMMAND: // Process menu command event
switch(wParam)
{
case AVK_LEFT:
case AVK_RIGHT:
case AVK_DOWN:
case AVK_UP:
if(ITEXTCTL_IsActive(pMe->m_pName) == TRUE)
{
ITEXTCTL_SetActive(pMe->m_pName,FALSE);
IDATECTL_SetActive(pMe->m_pDate, TRUE);
//ITEXTCTL_SetActive(pMe->m_pTime, FALSE);
ITIMECTL_SetActive(pMe->m_pTime, FALSE);
ITEXTCTL_SetActive(pMe->m_pTimeLen, FALSE);
return TRUE;
}
else if ( IDATECTL_IsActive(pMe->m_pDate ) == TRUE )
{
ITEXTCTL_SetActive(pMe->m_pName, FALSE);
IDATECTL_SetActive(pMe->m_pDate, FALSE);
//ITEXTCTL_SetActive(pMe->m_pTime, TRUE);
ITIMECTL_SetActive(pMe->m_pTime, TRUE);
ITEXTCTL_SetActive(pMe->m_pTimeLen, FALSE);
return TRUE;
}
//else if ( ITEXTCTL_IsActive(pMe->m_pTime) == TRUE )
else if ( ITIMECTL_IsActive(pMe->m_pTime) == TRUE )
{
ITEXTCTL_SetActive(pMe->m_pName, FALSE);
IDATECTL_SetActive(pMe->m_pDate, FALSE);
//ITEXTCTL_SetActive(pMe->m_pTime, FALSE);
ITIMECTL_SetActive(pMe->m_pTime, FALSE);
ITEXTCTL_SetActive(pMe->m_pTimeLen, TRUE);
return TRUE;
}
else if (ITEXTCTL_IsActive(pMe->m_pTimeLen) == TRUE)
{
ITEXTCTL_SetActive(pMe->m_pName, TRUE);
IDATECTL_SetActive(pMe->m_pDate, FALSE);
//ITEXTCTL_SetActive(pMe->m_pTime, FALSE);
ITIMECTL_SetActive(pMe->m_pTime, FALSE);
ITEXTCTL_SetActive(pMe->m_pTimeLen, FALSE);
return TRUE;
}
case AVK_SELECT:
//Capeconference_SetWindow( pMe->m_pOwner, APW_MEMBERLIST, 0);
//ITEXTCTL_GetText(pMe->m_pName, pMe->m_pOwner->m_pConferenceInfo->wsConferenceName, 20*sizeof(AECHAR));
//STRCAT(pMe->m_pBuffer, pMe->m_pOwner->m_pConferenceInfo->wsConferenceName);
////IDATECTL_GetDateString(pMe->m_pDate, pMe->m_pOwner->m_pConferenceInfo->wsConferenceDate, 8*sizeof(AECHAR));
//IDATECTL_GetDateString(pMe->m_pDate, pMe->m_pOwner->m_pConferenceInfo->wsConferenceDate, 8*sizeof(AECHAR));
//STRCAT(pMe->m_pBuffer, pMe->m_pOwner->m_pConferenceInfo->wsConferenceDate);
//ITIMECTL_GetTime(pMe->m_pTime, pMe->m_pOwner->m_pConferenceInfo->wsConferenceTime, 6*sizeof(AECHAR));
//STRCAT(pMe->m_pBuffer, pMe->m_pOwner->m_pConferenceInfo->wsConferenceTime);
break;
case AVK_CLR:
Capeconference_SetWindow( pMe->m_pOwner, APW_MAINMENU, 0);
break;
case AVK_SOFT1:
//Capeconference_SetWindow( pMe->m_pOwner, APW_BOOKSM, 0);
break;
case AVK_SOFT2:
Capeconference_SetWindow( pMe->m_pOwner, APW_MAINMENU, 0);
break;
default:
break;
}
default:
break;
}
return TRUE;
}
但是只显示了2个文本和一个日期控件
--------------------编程问答-------------------- 采用了Mediaplayer的应用框架么?显示了哪两个文本控件呢? --------------------编程问答-------------------- 框架是按照经典的Mediaplayer来的,有2个文本框,分别用于输入名称ITextCtl * m_pName和时长的ITextCtl * m_pTimeLen,但是时间控件显示不出来,不知 wireless_com 兄和其他高人是否有遇这样的问题,BREW版本是3.15
另外问一下。大家现在都用BREW的哪个版本了?
--------------------编程问答-------------------- 是不是区域重叠或控件指针重了 --------------------编程问答-------------------- 可以明确的告诉你,你的CTL没有设成active状态。 --------------------编程问答-------------------- 其实我在HandleEvent的函数里面设置变更了控件的active状态,但是还是不能显示,Timer控件总是不能显示,其他都能显示
没办法。只能用文本控件代替了 --------------------编程问答-------------------- --------------------编程问答--------------------
自己调试一下,而且先分析了再问出来,搞重点...
补充:移动开发 , Brew