【求助】:为什么用BUIW创建ROOTFORM和IFORM后IFORM没法显示。
rootform显示正常
iform 新手求大侠们帮忙。。
没法显示 源码如下:
- C/C++ code
//文件: BrewReader.c/*===============================================================================头文件和可用的宏定义=============================================================================== */#include "AEEModGen.h" // Module interface definitions#include "AEEAppGen.h" // Applet interface definitions#include "AEEShell.h" // Shell interface definitions#include "AEEFile.h" // File interface definitions//BUIW Head Files#include "AEEForm.h"#include "AEERootForm.h"#include "AEEDialog.h"#include "AEEPopUp.h"#include "ListForm.h"#include "AEEListForm.h"//#include "AEEScrollWidget.h"//#include "AEEWProperties.h"#include "AEEXYContainer.h"//#include "AEEPropContainer.h"#include "AEEStaticWidget.h"//#include "AEEListWidget.h"//#include "AEEArrayModel.h"#include "AEEStdLib.h"//BUIW Bid Files#include "AEEImageStaticWidget.h"#include "AEECLSID_ROOTFORM.bid"#include "AEECLSID_POPUPMENUFORM.bid"#include "AEECLSID_WARNDIALOG.bid"//BID And Brh Files#include "BrewReader.bid"#include "BrewReader.brh"/*-------------------------------------------------------------------应用结构体定义. 所有可用的都通过 "pMe->"指向-------------------------------------------------------------------*/// 创建一个应用结构体.此处所有的定义为静态typedef struct _BrewReader { AEEApplet a ; // 结构体的第一个元素必须是 AEEApplet AEEDeviceInfo DeviceInfo; // 通常需要使用获取设备的信息 // 添加自己的代码,... IDisplay *piDisplay; // give a standard way to access the Display IShell *pIShell; // give a standard way to access the Shell interface //All Forms define IRootForm* rootForm; //RootForm IForm* mainForm; //MainForm HandlerDesc mainFormHandler;} BrewReader;/*-------------------------------------------------------------------函数声明部分-------------------------------------------------------------------*/static boolean BrewReader_HandleEvent(BrewReader* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam);boolean BrewReader_InitAppData(BrewReader* pMe);void BrewReader_FreeAppData(BrewReader* pMe);//添加自己的函数定义void AppForm_Delete(BrewReader* pMe) { if(pMe->mainForm) IFORM_Release(pMe->mainForm); if(pMe) FREE(pMe);}int AppForm_new(BrewReader* pMe);int AppForm_mainForm(BrewReader* pMe);//事件static boolean AppForm_mainFormHandleEvent(void *po, AEEEvent evt, uint16 wParam, uint32 dwParam);/*===============================================================================函数定义部分:对已经声明的函数进行定义.包含几个必须的函数: //初始化某个接口,实例化 int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj) //整个应用事件驱动机制函数 static boolean BrewReader_HandleEvent(BrewReader* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam) //初始化应用数据函数 boolean BrewReader_InitAppData(BrewReader* pMe) //释放应用数据函数 void BrewReader_FreeAppData(BrewReader* pMe)=============================================================================== *//*===========================================================================函数/方法: AEEClsCreateInstance返回值 这个函数/方法在APP载入的时候被调用. 所有的Modules必须提供这个函数/方法. 确保对这个函数/方法的名字和参数不变. 在此.会检查ClassID,并且调用 AEEApplet_New() 函数/方法 AEEApplet_New() 定义在AEEAppGen.c 在调用 AEEApplet_New()之后, 该函数可以执行APP的自定义的初始化. 函数/方法原型: int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)=====*/int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj){ *ppObj = NULL; if( ClsId == AEECLSID_BREWREADER ) { // 创建应用,并为应用申请空间 if( AEEApplet_New(sizeof(BrewReader), ClsId, pIShell, po, (IApplet**)ppObj, (AEEHANDLER)BrewReader_HandleEvent, (PFNFREEAPPDATA)BrewReader_FreeAppData) ) // 该函数/方法在 EVT_APP_STOP之后调用 { //初始化应用数据,该函数/方法在 EVT_APP_START 之前调用 if(BrewReader_InitAppData((BrewReader*)*ppObj)) { //数据初始化成功 return(AEE_SUCCESS); } else { //释放applet. 当AEEApplet_New调用时,调用该函数释放该APP占用的存储空间. IAPPLET_Release((IApplet*)*ppObj); return EFAILED; } } // AEEApplet_New 执行完毕 } return(EFAILED);}/*===========================================================================函数 SampleAppWizard_HandleEvent函数/方法原型: boolean SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)===========================================================================*/static boolean BrewReader_HandleEvent(BrewReader* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam){ // Allow rootform to handle event first if(IROOTFORM_HandleEvent(pMe->rootForm, eCode, wParam, dwParam)) { return TRUE; } switch (eCode) { // 应用被告知启动 case EVT_APP_START: //在此处 添加自己的代码,... AppForm_mainForm(pMe); IROOTFORM_PushForm(pMe->rootForm, pMe->mainForm); //IDISPLAY_Update (pMe->a.m_pIDisplay); return(TRUE); // 应用被告知退出 case EVT_APP_STOP: //在此处 添加自己的代码,... return(TRUE); // 应用被告知挂起 case EVT_APP_SUSPEND: //在此处 添加自己的代码,... return(TRUE); // 应用被告知恢复 case EVT_APP_RESUME: //在此处 添加自己的代码,... return(TRUE); // 有消息到达该APPLET. 消息以(char *)存储在dwParam中 // 以如下格式发送 "//BREW:ClassId:Message", 例如 //BREW:0x00000001:Hello World case EVT_APP_MESSAGE: //在此处 添加自己的代码,... return(TRUE); // 某个按键被按下. 查看wParam 判断哪个按键被按下. 案件编号在AEEVCodes.h中. //例如 "AVK_1" 代表 数字键"1" 被按下. case EVT_KEY: //在此处 添加自己的代码,... return(TRUE); // 如果没有与按下的键相匹配的操作则执行break default: break; } return FALSE;}// 在applet启动的时候调用该函数/方法boolean BrewReader_InitAppData(BrewReader* pMe){ int result = 0; // 获取设备的基本信息. // 通过 pMe->DeviceInfo 参考获取的信息 // 查看 API reference guide 来确定你能获得设备的哪些信息 // pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo); //ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo); // 输入自己的代码来初始化或分配资源... //在这里载入rootform result = AppForm_new(pMe); // 如果没有错误则返回 成功 return TRUE;}// 当程序退出时候调用该函数/方法void BrewReader_FreeAppData(BrewReader* pMe){ // 输入自己的代码以释放所有已经申请/分配的资源/内存... // 例如释放各个接口: // if ( pMe->pIMenuCtl != NULL ) // 判断pImenuCtl是否存在 // { // IMENUCTL_Release(pMe->pIMenuCtl) // 释放IMENU接口 // pMe->pIMenuCtl = NULL; // 将接口设置为 NULL 以便于之后释放 if(pMe->rootForm) { IROOTFORM_Release(pMe->rootForm); pMe->rootForm = NULL; } if(pMe->mainForm) { IFORM_Release(pMe->mainForm); pMe->mainForm = NULL; } if(pMe->piDisplay) { IDISPLAY_Release(pMe->piDisplay); pMe->piDisplay = NULL; }}//自己添加的函数定义int AppForm_new(BrewReader* pMe){ static const AECHAR awchSoftkey1[] = {'T','e','s','t', 0}; int result = 0; IWidget* formWidget = NULL; pMe->mainForm = NULL; pMe->piDisplay=pMe->a.m_pIDisplay; pMe->pIShell = pMe->a.m_pIShell; //create rootForm result = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_ROOTFORM, (void**) &pMe->rootForm);// 设置边框(应该可以在lua文件修改的) IFORM_GetWidget((IForm*)pMe->rootForm, WID_FORM, &formWidget); if(formWidget&&result==0) { //IWIDGET_SetBorderColor(formWidget, RGB_BLACK); IWIDGET_SetBorderWidth(formWidget, 1); //IFORM_SetWidget((IForm*)pMe->rootForm, WID_FORM, formWidget); IWIDGET_Release(formWidget); } //(void)IFORM_SetText(pMe->rootForm, FID_SOFTKEY1, awchSoftkey1); //set the theme// if(result == 0)// result = IROOTFORM_SetThemeFileName(pMe->rootForm, "theme.bar"); if(result==0) ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_DISPLAY, (void**) &pMe->piDisplay); return result;}int AppForm_mainForm(BrewReader* pMe){ int result=0; pMe->mainForm = NULL; pMe->piDisplay=pMe->a.m_pIDisplay; pMe->pIShell = pMe->a.m_pIShell; result = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FORM, (void**)&pMe->mainForm); result = IFORM_SetSoftkeys(pMe->mainForm, BREWREADER_RES_FILE , IDS_MENU_1004, IDS_EXIT_1005); result += IFORM_SetResText(pMe->mainForm, FID_TITLE, BREWREADER_RES_FILE, IDS_TITLE_1001); HANDLERDESC_Init(&pMe->mainFormHandler, AppForm_mainFormHandleEvent, pMe, AppForm_Delete); IFORM_SetHandler(pMe->mainForm, &pMe->mainFormHandler); return result; }//事件的函数定义static boolean AppForm_mainFormHandleEvent(void *po, AEEEvent evt, uint16 wParam, uint32 dwParam){ BrewReader* pMe = (BrewReader*) po; int result = 0; switch (evt) { case EVT_KEY: switch (wParam) { case AVK_SOFT1: return TRUE; case AVK_SOFT2: return TRUE; case AVK_CLR: return TRUE; } break; } //the default form handler is swapped with the AppForm handler // calling this allows the default form handler to handle the event return HANDLERDESC_Call(&pMe->mainFormHandler, evt, wParam, dwParam); }