⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 《深入brew开发》——第七章 创建新的brew应用程序 - gemsea的专栏 - csdnblog.htm

📁 《深入BREW开发》——第八章 BREW的事件处理
💻 HTM
📖 第 1 页 / 共 5 页
字号:
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            AEEApplet&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a 
            ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            // First element of this structure must be AEEApplet</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp; AEEDeviceInfo&nbsp;DeviceInfo; // 
            always have access to the hardware device information</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV>&nbsp;<SPAN>&nbsp;&nbsp;// add your own variables 
            here...</SPAN></DIV>
            <DIV>} helloworld;</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>/*-------------------------------------------------------------------</DIV>
            <DIV>Function Prototypes</DIV>
            <DIV>-------------------------------------------------------------------*/</DIV>
            <DIV>static&nbsp;boolean helloworld_HandleEvent( helloworld* pMe, 
            </DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            &nbsp;AEEEvent eCode, uint16 wParam, </SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            &nbsp;uint32 dwParam);</SPAN></DIV>
            <DIV>boolean helloworld_InitAppData(helloworld* pMe);</DIV>
            <DIV>void<SPAN>&nbsp;&nbsp;&nbsp; helloworld_FreeAppData(helloworld* 
            pMe);</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV>/*====================================================================</DIV>
            <DIV>FUNCTION DEFINITIONS</DIV>
            <DIV>==================================================================== 
            */</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>/*====================================================================</DIV>
            <DIV>FUNCTION: AEEClsCreateInstance</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>DESCRIPTION</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This function is 
            invoked while the app is being loaded. All Modules must provide this 
            </SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function. Ensure to 
            retain the same name and parameters for this function.</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In here, the module 
            must verify the ClassID and then invoke the AEEApplet_New() 
            function</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; that has been 
            provided in AEEAppGen.c. </SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV><SPAN>&nbsp;&nbsp; After invoking AEEApplet_New(), this 
            function can do app specific initialization. In this</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp; example, a generic structure is provided so 
            that app developers need not change app specific</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp; initialization section every time except for 
            a call to IDisplay_InitAppData(). </SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp; This is done as follows: InitAppData() is 
            called to initialize AppletData </SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp; instance. It is app developers 
            responsibility to fill-in app data initialization </SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp; code of InitAppData(). App developer is also 
            responsible to release memory </SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp; allocated for data contained in AppletData 
            -- this can be done in </SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp; IDisplay_FreeAppData().</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV>PROTOTYPE:</DIV>
            <DIV><SPAN>&nbsp;&nbsp; int AEEClsCreateInstance(AEECLSID 
            ClsId,IShell * pIShell,IModule * po,void ** ppObj)</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV>PARAMETERS:</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clsID: [in]: 
            Specifies the ClassID of the applet which is being 
            loaded</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pIShell: [in]: 
            Contains pointer to the IShell object. </SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pIModule: pin]: 
            Contains pointer to the IModule object to the current module to 
            which</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this app 
            belongs</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ppObj: [out]: On 
            return, *ppObj must point to a valid IApplet structure. 
            Allocation</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of memory for this 
            structure and initializing the base data members is done by 
            AEEApplet_New().</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV>DEPENDENCIES</DIV>
            <DIV>&nbsp;none</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>RETURN VALUE</DIV>
            <DIV>&nbsp;AEE_SUCCESS: If the app needs to be loaded and if 
            AEEApplet_New() invocation was</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp; successful</SPAN></DIV>
            <DIV>&nbsp;EFAILED: If the app does not need to be loaded or if 
            errors occurred in </DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp; AEEApplet_New(). If this 
            function returns FALSE, the app will not be loaded.</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV>SIDE EFFECTS</DIV>
            <DIV>&nbsp;none</DIV>
            <DIV>====================================================================*/</DIV>
            <DIV>int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, 
            IModule *po, void **ppObj)</DIV>
            <DIV>{</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *ppObj = 
            NULL;</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( ClsId == 
            AEECLSID_HELLOWORLD )</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            // Create the applet and make room for the applet 
            structure</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            if( AEEApplet_New(sizeof(helloworld),</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            ClsId,</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            pIShell,</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            po,</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            (IApplet**)ppObj,</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            (AEEHANDLER)helloworld_HandleEvent,</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            (PFNFREEAPPDATA)helloworld_FreeAppData) ) </SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            {</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            //Initialize applet data, this is called before sending 
            EVT_APP_START</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            // to the HandleEvent function</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            if(helloworld_InitAppData((helloworld*)*ppObj))</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            {</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            //Data initialized successfully</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            return(AEE_SUCCESS);</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            }</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            else</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            {</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            //Release the applet. This will free the memory allocated for the 
            applet when</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            // AEEApplet_New was called.</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            IAPPLET_Release((IApplet*)*ppObj);</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            return EFAILED;</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            }</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } // end 
            AEEApplet_New</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp; }</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            return(EFAILED);</SPAN></DIV>
            <DIV>}</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>/*====================================================================</DIV>
            <DIV>FUNCTION SampleAppWizard_HandleEvent</DIV>
            <DIV>&nbsp;</DIV>
            <DIV>DESCRIPTION</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is the 
            EventHandler for this app. All events to this app are handled in 
            this</SPAN></DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function. All APPs 
            must supply an Event Handler.</SPAN></DIV>
            <DIV>&nbsp;</DIV>
            <DIV>PROTOTYPE:</DIV>
            <DIV><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boolean 
            SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 
            wParam, uint32 dwParam)</SPAN></DIV>
            <DIV>&nbsp;</DIV>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -