1.Create Sample Application with name “Application1″ using application creation wizard .
A hello world application is created , that will show “Hello World on Simulator”
2.Add “Application1.h” With the code below
/*=============================================================================
FILE: Application1.c
=============================================================================*/
/*-----------------------------------------------------------------------------
Includes and Variable Definitions
-----------------------------------------------------------------------------*/
#ifndef _Application1_H
#define _Application1_H
#include "AEEModGen.h" // Module interface definitions.
#include "AEEAppGen.h" // Applet interface definitions.
#include "AEEShell.h"
// Shell interface definitions.
#include "AEEStdLib.h"
#include "AEEStdDef.h"
#include "Application1.bid"
#include "AEEIEnv.h"
#include "AEEEnv.bid"
#include "Application1_res.h"
/*-----------------------------------------------------------------------------
Applet Structure - Definition of the Applet Structure that's passed to Brew MP
API functions. All variables in here are referenced via the applet structure
pointer "pMe->", and will be able to be referenced as static.
-----------------------------------------------------------------------------*/
class Application1 {
public:
AEEApplet applet; // First element of this structure must be AEEApplet.
IDisplay * piDisplay; // Copy of IDisplay Interface pointer for easy access.
IShell * piShell; // Copy of IShell Interface pointer for easy access.
IEnv * piEnv;
AEEDeviceInfo deviceInfo; // Copy of device info for easy access.
// Add your own variables here...
protected:
boolean HandleEvent(AEEEvent eCode,uint16 wParam, uint32 dwParam);
boolean InitAppData();
void FreeAppData();
void DrawScreen();
public:
static boolean handleEvent(Application1 * pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
return pMe->HandleEvent(eCode, wParam, dwParam);
}
static boolean initAppData(Application1 * pMe)
{
return pMe->InitAppData();
}
static void freeAppData(Application1 * pMe)
{
pMe->FreeAppData();
}
static void drawScreen(Application1 *pMe)
{
pMe->DrawScreen();
}
static Application1* getInstance()
{
return (Application1*)GETAPPINSTANCE();
}
};
#endif
3. Remove Application1.c file from the folder and add “Application1.cpp” With The Below Code
#include "Application1.h"
boolean Application1::InitAppData()
{
Application1 * pMe = this;
// Save local copy for easy access:
pMe->piDisplay = pMe->applet.m_pIDisplay;
pMe->piShell = pMe->applet.m_pIShell;
// Get the device information for this handset.
// Reference all the data by looking at the pMe->deviceInfo structure.
// Check the API reference guide for all the handy device info you can get.
pMe->deviceInfo.wStructSize = sizeof(pMe->deviceInfo);
ISHELL_GetDeviceInfo(pMe->applet.m_pIShell,&pMe->deviceInfo);
// Insert your code here for initializing or allocating resources...
return TRUE;// No failures up to this point, so return success.
}
void Application1::FreeAppData()
{
//RELEASEIF(this->piEnv);
//RELEASEIF(this->deviceInfo);
//RELEASEIF(this->piDisplay);
//RELEASEIF(this->piShell);
}
boolean Application1::HandleEvent(AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
Application1 *pMe = this;
switch (eCode) {
// Event to inform app to start, so start-up code is here:
case EVT_APP_START:
Application1::initAppData(pMe);
Application1::drawScreen(pMe); // Draw text on display screen.
return TRUE;
// Event to inform app to exit, so shut-down code is here:
case EVT_APP_STOP:
Application1::freeAppData(pMe);
return TRUE;
// Event to inform app to suspend, so suspend code is here:
case EVT_APP_SUSPEND:
Application1::freeAppData(pMe);
return TRUE;
// Event to inform app to resume, so resume code is here:
case EVT_APP_RESUME:
// example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
return TRUE;
// A key was pressed:
case EVT_KEY:
return FALSE;
// Clamshell has opened/closed
// wParam = TRUE if open, FALSE if closed
case EVT_FLIP:
return TRUE;
// wParam = TRUE if keygaurd is on
case EVT_KEYGUARD:
return TRUE;
// If event wasn't handled here, then break out:
default:
break;
}
return FALSE; // Event wasn't handled.
}
void Application1::DrawScreen()
{
Application1 * pMe = this;
AECHAR szBuf[64] = {0};
int nStrLen = 0;
RGBVAL oldTextColor = RGB_BLACK;
IDISPLAY_ClearScreen(pMe->piDisplay); // Erase whole screen.
// Load the string resource into a buffer:
nStrLen = ISHELL_LoadResString(pMe->piShell,
APPLICATION1_RES_FILE,
IDS_STRING_1001, szBuf, sizeof(szBuf));
// If the text was successfully loaded from resource file into buffer:
if (0 < nStrLen) {
// Set user-text color to black:
oldTextColor = IDisplay_SetColor(pMe->piDisplay,
CLR_USER_TEXT,
RGB_BLACK);
IDisplay_DrawText(pMe->piDisplay, // Display instance.
AEE_FONT_BOLD, // Use Bold font.
szBuf, // String buffer containing text.
-1, // Automatically compute string length.
0, // x-coordinate ignored since IDF_ALIGN_CENTER.
0, // y-coordinate ignored since IDF_ALIGN_MIDDLE.
NULL, // No clipping.
IDF_ALIGN_CENTER | // Center-align horizontally.
IDF_ALIGN_MIDDLE); // Middle-align vertically.
}
// Restore previous color:
IDisplay_SetColor(pMe->piDisplay, CLR_USER_TEXT, oldTextColor);
IDisplay_Update (pMe->piDisplay);
}
int AEEClsCreateInstance(AEECLSID ClsId, IShell * piShell, IModule * piModule,
void ** ppObj)
{
*ppObj = NULL;
// Confirm this applet is the one intended to be created (classID matches):
if(AEEApplet_New(sizeof(Application1), ClsId, piShell,piModule,(IApplet**)ppObj,
(AEEHANDLER)Application1::handleEvent,(PFNFREEAPPDATA)Application1::freeAppData))
{
if(Application1::initAppData((Application1 *) *ppObj))
{
return (AEE_SUCCESS);
}
}
return AEE_EFAILED;
}
If u get some error while compiling on target refer Using C++ with Brew Post
Hope this helped …. And Saved Some of your time …

Follow Me!