📄 《深入brew开发》——第七章 创建新的brew应用程序 - gemsea的专栏 - csdnblog.htm
字号:
<DIV><SPAN>
AEEApplet a
;
// First element of this structure must be AEEApplet</SPAN></DIV>
<DIV><SPAN> AEEDeviceInfo DeviceInfo; //
always have access to the hardware device information</SPAN></DIV>
<DIV> </DIV>
<DIV> <SPAN> // add your own variables
here...</SPAN></DIV>
<DIV>} helloworld;</DIV>
<DIV> </DIV>
<DIV>/*-------------------------------------------------------------------</DIV>
<DIV>Function Prototypes</DIV>
<DIV>-------------------------------------------------------------------*/</DIV>
<DIV>static boolean helloworld_HandleEvent( helloworld* pMe,
</DIV>
<DIV><SPAN>
AEEEvent eCode, uint16 wParam, </SPAN></DIV>
<DIV><SPAN>
uint32 dwParam);</SPAN></DIV>
<DIV>boolean helloworld_InitAppData(helloworld* pMe);</DIV>
<DIV>void<SPAN> helloworld_FreeAppData(helloworld*
pMe);</SPAN></DIV>
<DIV> </DIV>
<DIV>/*====================================================================</DIV>
<DIV>FUNCTION DEFINITIONS</DIV>
<DIV>====================================================================
*/</DIV>
<DIV> </DIV>
<DIV>/*====================================================================</DIV>
<DIV>FUNCTION: AEEClsCreateInstance</DIV>
<DIV> </DIV>
<DIV>DESCRIPTION</DIV>
<DIV><SPAN> This function is
invoked while the app is being loaded. All Modules must provide this
</SPAN></DIV>
<DIV><SPAN> function. Ensure to
retain the same name and parameters for this function.</SPAN></DIV>
<DIV><SPAN> In here, the module
must verify the ClassID and then invoke the AEEApplet_New()
function</SPAN></DIV>
<DIV><SPAN> that has been
provided in AEEAppGen.c. </SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN> After invoking AEEApplet_New(), this
function can do app specific initialization. In this</SPAN></DIV>
<DIV><SPAN> example, a generic structure is provided so
that app developers need not change app specific</SPAN></DIV>
<DIV><SPAN> initialization section every time except for
a call to IDisplay_InitAppData(). </SPAN></DIV>
<DIV><SPAN> This is done as follows: InitAppData() is
called to initialize AppletData </SPAN></DIV>
<DIV><SPAN> instance. It is app developers
responsibility to fill-in app data initialization </SPAN></DIV>
<DIV><SPAN> code of InitAppData(). App developer is also
responsible to release memory </SPAN></DIV>
<DIV><SPAN> allocated for data contained in AppletData
-- this can be done in </SPAN></DIV>
<DIV><SPAN> IDisplay_FreeAppData().</SPAN></DIV>
<DIV> </DIV>
<DIV>PROTOTYPE:</DIV>
<DIV><SPAN> int AEEClsCreateInstance(AEECLSID
ClsId,IShell * pIShell,IModule * po,void ** ppObj)</SPAN></DIV>
<DIV> </DIV>
<DIV>PARAMETERS:</DIV>
<DIV><SPAN> clsID: [in]:
Specifies the ClassID of the applet which is being
loaded</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN> pIShell: [in]:
Contains pointer to the IShell object. </SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN> pIModule: pin]:
Contains pointer to the IModule object to the current module to
which</SPAN></DIV>
<DIV><SPAN> this app
belongs</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN> ppObj: [out]: On
return, *ppObj must point to a valid IApplet structure.
Allocation</SPAN></DIV>
<DIV><SPAN> of memory for this
structure and initializing the base data members is done by
AEEApplet_New().</SPAN></DIV>
<DIV> </DIV>
<DIV>DEPENDENCIES</DIV>
<DIV> none</DIV>
<DIV> </DIV>
<DIV>RETURN VALUE</DIV>
<DIV> AEE_SUCCESS: If the app needs to be loaded and if
AEEApplet_New() invocation was</DIV>
<DIV><SPAN> successful</SPAN></DIV>
<DIV> EFAILED: If the app does not need to be loaded or if
errors occurred in </DIV>
<DIV><SPAN> AEEApplet_New(). If this
function returns FALSE, the app will not be loaded.</SPAN></DIV>
<DIV> </DIV>
<DIV>SIDE EFFECTS</DIV>
<DIV> none</DIV>
<DIV>====================================================================*/</DIV>
<DIV>int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell,
IModule *po, void **ppObj)</DIV>
<DIV>{</DIV>
<DIV><SPAN> *ppObj =
NULL;</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN> if( ClsId ==
AEECLSID_HELLOWORLD )</SPAN></DIV>
<DIV><SPAN> {</SPAN></DIV>
<DIV><SPAN>
// Create the applet and make room for the applet
structure</SPAN></DIV>
<DIV><SPAN>
if( AEEApplet_New(sizeof(helloworld),</SPAN></DIV>
<DIV><SPAN>
ClsId,</SPAN></DIV>
<DIV><SPAN>
pIShell,</SPAN></DIV>
<DIV><SPAN>
po,</SPAN></DIV>
<DIV><SPAN>
(IApplet**)ppObj,</SPAN></DIV>
<DIV><SPAN>
(AEEHANDLER)helloworld_HandleEvent,</SPAN></DIV>
<DIV><SPAN>
(PFNFREEAPPDATA)helloworld_FreeAppData) ) </SPAN></DIV>
<DIV><SPAN>
{</SPAN></DIV>
<DIV><SPAN>
//Initialize applet data, this is called before sending
EVT_APP_START</SPAN></DIV>
<DIV><SPAN>
// to the HandleEvent function</SPAN></DIV>
<DIV><SPAN>
if(helloworld_InitAppData((helloworld*)*ppObj))</SPAN></DIV>
<DIV><SPAN>
{</SPAN></DIV>
<DIV><SPAN>
//Data initialized successfully</SPAN></DIV>
<DIV><SPAN>
return(AEE_SUCCESS);</SPAN></DIV>
<DIV><SPAN>
}</SPAN></DIV>
<DIV><SPAN>
else</SPAN></DIV>
<DIV><SPAN>
{</SPAN></DIV>
<DIV><SPAN>
//Release the applet. This will free the memory allocated for the
applet when</SPAN></DIV>
<DIV><SPAN>
// AEEApplet_New was called.</SPAN></DIV>
<DIV><SPAN>
IAPPLET_Release((IApplet*)*ppObj);</SPAN></DIV>
<DIV><SPAN>
return EFAILED;</SPAN></DIV>
<DIV><SPAN>
}</SPAN></DIV>
<DIV><SPAN> } // end
AEEApplet_New</SPAN></DIV>
<DIV><SPAN> }</SPAN></DIV>
<DIV><SPAN>
return(EFAILED);</SPAN></DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>/*====================================================================</DIV>
<DIV>FUNCTION SampleAppWizard_HandleEvent</DIV>
<DIV> </DIV>
<DIV>DESCRIPTION</DIV>
<DIV><SPAN> This is the
EventHandler for this app. All events to this app are handled in
this</SPAN></DIV>
<DIV><SPAN> function. All APPs
must supply an Event Handler.</SPAN></DIV>
<DIV> </DIV>
<DIV>PROTOTYPE:</DIV>
<DIV><SPAN> boolean
SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16
wParam, uint32 dwParam)</SPAN></DIV>
<DIV> </DIV>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -