最近开始学做BREW MP,基础太差,许多东西还是一头雾水。昨天开始写个Grid Widget的例子,想简单的只显示个Static就好,可水平太差不知道怎么写。在Wizard生成的代码的基础上参考了 http://topic.csdn.net/u/20091123/18/3c67c251-79c0-45cf-b799-08ca40a839a5 一帖中两位仁兄的代码,现写出如下代码,请各位大哥看看小弟哪里写的有问题,谢谢了。
/*=============================================================================
FILE: GridWidgetSample.c
=============================================================================*/
/*-----------------------------------------------------------------------------
Includes and Variable Definitions
-----------------------------------------------------------------------------*/
#include "AEEModGen.h"
#include "AEEAppGen.h"
#include "AEEShell.h"
#include "GridWidgetSample.bid"
#include "GridWidgetSample_res.h"
/* some property definition, like AEERect, ect. */
#include "AEEWProperties.h"
#include "AEERootContainer.h"
#include "AEECLSID_ROOTCONTAINER.bid"
#include "AEEDisplayCanvas.h"
#include "AEECLSID_DISPLAYCANVAS.bid"
#include "AEEListWidget.h"
#include "AEECLSID_GRIDWIDGET.bid"
#include "AEEStaticWidget.h"
#include "AEECLSID_STATICWIDGET.bid"
#include "AEEIDecorator.h"
#include "AEEIVectorModel.h"
#include "AEECLSID_VECTORMODEL.bid"
#ifndef RELEASEIF
#define RELEASEIF(p) ReleaseIf((IBase**)(void*)&p)
//#define ERR_TRY(x) do { nErr = (x); if (nErr) goto ERR_CATCH; } while(0)
static void ReleaseIf(IBase **ppif) {
if (*ppif) {
IBASE_Release(*ppif);
*ppif = 0;
}
}
#endif
/*-----------------------------------------------------------------------------
Applet Structure
-----------------------------------------------------------------------------*/
typedef struct _GridWidgetSample {
AEEApplet applet;
IDisplay * piDisplay;
IShell * piShell;
AEEDeviceInfo deviceInfo;
// Add your own variables here...
IRootContainer *picRootContainer;
IWidget *piwRootWidget;
} GridWidgetSample;
/*-----------------------------------------------------------------------------
Function Prototypes
-----------------------------------------------------------------------------*/
static boolean GridWidgetSample_HandleEvent(GridWidgetSample* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam);
boolean GridWidgetSample_InitAppData(GridWidgetSample* pMe);
void GridWidgetSample_FreeAppData(GridWidgetSample* pMe);
static void GridWidgetSample_DrawScreen(GridWidgetSample * pMe);
/*-----------------------------------------------------------------------------
Function Definitions
-----------------------------------------------------------------------------*/
/*=============================================================================
FUNCTION: AEEClsCreateInstance
=============================================================================*/
int AEEClsCreateInstance(AEECLSID ClsId, IShell * piShell, IModule * piModule,
void ** ppObj)
{
*ppObj = NULL;
if( AEECLSID_GRIDWIDGETSAMPLE == ClsId ) {
if( TRUE == AEEApplet_New(sizeof(GridWidgetSample),
ClsId,
piShell,
piModule,
(IApplet**)ppObj,
(AEEHANDLER)GridWidgetSample_HandleEvent,
(PFNFREEAPPDATA)GridWidgetSample_FreeAppData) ) {
if(TRUE == GridWidgetSample_InitAppData((GridWidgetSample*)*ppObj)) {