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

📄 testdemo.c

📁 Brew 下一个字自动滚动的实例
💻 C
字号:
/*===========================================================================

FILE: testdemo.c
===========================================================================*/


/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h"          // Module interface definitions
#include "AEEAppGen.h"          // Applet interface definitions
#include "AEEShell.h"           // Shell interface definitions
#include "AEEForm.h"
#include "AEERootForm.h"

#include "AppForm.h"

//define applet structure
typedef struct _TestDemoApp {
   AEEApplet a; 
   IRootForm* rootForm;
   IForm* mainForm;
   IDisplay* piDisplay;
} TestDemoApp;

/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean testdemo_HandleEvent(IApplet * pi, AEEEvent eCode, 
                                      uint16 wParam, uint32 dwParam);
static int testdemo_InitAppData(TestDemoApp* pMe);
static void testdemo_FreeAppData(TestDemoApp* pMe);


/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */


int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)
{
   TestDemoApp* pMe=NULL;
   *ppObj = NULL;

   if(!AEEApplet_New(sizeof(TestDemoApp), ClsId, pIShell,po,(IApplet**)ppObj,
                     (AEEHANDLER)testdemo_HandleEvent, (PFNFREEAPPDATA) testdemo_FreeAppData))
      return ENOMEMORY;

   pMe = (TestDemoApp*) *ppObj;

   if(testdemo_InitAppData(pMe) != 0)
      return EFAILED;

   return AEE_SUCCESS;
}


/* Initialize applet data*/
int testdemo_InitAppData(TestDemoApp* pMe) {
   int result = 0;

   pMe->mainForm = NULL;

   //create rootForm
   result = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_ROOTFORM, (void**) &pMe->rootForm);

   if(result==0)
      ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_DISPLAY, (void**) &pMe->piDisplay);

   return result;
}


// Free app data
static void testdemo_FreeAppData(TestDemoApp* pMe) {
   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;
   }
}



// App handle event
static boolean testdemo_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{  
   int result=0;
   TestDemoApp* pMe = (TestDemoApp*) pi;

   // Allow rootform to handle event first
   if(IROOTFORM_HandleEvent(pMe->rootForm, eCode, wParam, dwParam)) {
      return TRUE;
   }

   switch(eCode) {
   case EVT_APP_START: 
		// create main app form and push it onto the stack
		if (!pMe->mainForm) {
			if(AppForm_New(&pMe->mainForm, pMe->a.m_pIModule, pMe->a.m_pIShell, pMe->rootForm, pMe->piDisplay) != 0) {
				pMe->mainForm = 0;
			}
		}
		if (pMe->mainForm) {
			IROOTFORM_PushForm(pMe->rootForm, pMe->mainForm);
		}
		return TRUE;
		break;

   case EVT_APP_STOP:
      return TRUE;

	case EVT_APP_RESUME:
		IROOTFORM_Activate(pMe->rootForm);
		return TRUE;

	case EVT_APP_SUSPEND:
		IROOTFORM_Deactivate(pMe->rootForm);
		return TRUE;

   default:
      break;
   }
   return FALSE;
}


⌨️ 快捷键说明

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