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

📄 starter.c

📁 CD_高级PALM编程
💻 C
字号:
/********************************************************************* FILE:				Starter.c** DESCRIPTION:	The PAKA Starter project module.** VERSION:		1.0**********************************************************************/#include <PalmOS.h>#include 	<PalmCompatibility.h>#include "Starter.h"#include "StarterRsc.h"#include "Utils.h"#include "UtilsRsc.h"/*********************************************************************** * FUNCTION:    	MainFormInit * * DESCRIPTION: 	This routine initializes the main form. * * RETURNED:    	nothing ***********************************************************************/static void MainFormInit(	FormPtr	frmP		// ( in ) Pointer to the main form.){	if ( frmP != NULL )	{	// Insert code as appropriate		}}/*********************************************************************** * FUNCTION:    	MainFormDraw * * DESCRIPTION: 	This routine draws the non-form contents of the main form. * * RETURNED:    	nothing ***********************************************************************/static void MainFormDraw(	FormPtr	frmP		// ( in ) Pointer to the main form.){	if ( frmP != NULL ) 	{	// Insert code as appropriate	}}/*********************************************************************** * FUNCTION:    	MainFormDone * * DESCRIPTION: 	This routine cleans up after the main form. * * RETURNED:    	nothing ***********************************************************************/static void MainFormDone(	FormPtr	frmP		//  ( in) Pointer to the main form){	if ( frmP != NULL )	{	// Insert application-specific code first// Then do this as the very last thing		FrmEraseForm	( frmP );		FrmDeleteForm	( frmP );	}}/*********************************************************************** * FUNCTION:    	MainFormDoMenuCommand * * DESCRIPTION: 	This routine handles menu commands. * * RETURNED:    	nothing ***********************************************************************/static Boolean MainFormDoMenuCommand(	UInt16 	command	// ( in ) The ID of menu command to do){	Boolean 	handled = false;	FormPtr 	frmP;	switch ( command )	{		case MainOptionsAboutStarterApp:// The About command					MenuEraseStatus ( 0 );			frmP = FrmInitForm ( AboutForm );			FrmDoDialog ( frmP );			FrmDeleteForm ( frmP );			handled = true;			break;			// Insert other commands as needed	}	return handled;}/*********************************************************************** * FUNCTION:    	MainFormHandleEvent * * DESCRIPTION: 	This routine is the event handler for MainForm. * * RETURNED:    	true if the event is handled. ***********************************************************************/ static Boolean MainFormHandleEvent(	EventPtr eventP		// ( in ) Pointer to the event to handle){	Boolean 	handled = false;	FormPtr	frmP = FrmGetActiveForm ();	switch ( eventP->eType ) 	{	// Form events		case frmOpenEvent:				MainFormInit ( frmP );	// ***** WARNING  - falls thru to next case *****					case frmUpdateEvent:			FrmDrawForm ( frmP );			MainFormDraw ( frmP );			handled = true;			break; 								case frmCloseEvent:			MainFormDone ( frmP );			handled = true;			break;// Menu events					case menuEvent:			handled = MainFormDoMenuCommand ( eventP->data.menu.itemID );			break;	}	return handled;}#pragma mark ----------------/*********************************************************************** * FUNCTION:    	AppHandleEvent * * DESCRIPTION: 	Loads a form's resources and set its event handler. * * RETURNED:    	true if the event is handled. ***********************************************************************/static Boolean AppHandleEvent(	EventPtr	eventP	// ( in ) Pointer to the event to handle){		Boolean 	handled = false;	if ( eventP->eType == frmLoadEvent )	{	// Form load event--initialize the form and make it the active form.		UInt16 	formId 	= eventP->data.frmLoad.formID;		FormPtr	frmP 		= FrmInitForm ( formId );		FrmSetActiveForm ( frmP );// Set the event handler for the form.		switch ( formId )		{			case MainForm:					FrmSetEventHandler ( frmP, MainFormHandleEvent );				handled = true;				break;//	Insert other cases as needed for other forms.		}	}	return handled;}/*********************************************************************** * FUNCTION:    	AppEventLoop * * DESCRIPTION: 	The main event loop for the application.   * * RETURNED:    	nothing ***********************************************************************/static void AppEventLoop(	void){	UInt16 		error;	EventType 	event;	do	{		EvtGetEvent ( &event, evtWaitForever );		if (! SysHandleEvent ( &event))			if (! MenuHandleEvent ( 0, &event, &error ))				if (! AppHandleEvent ( &event ))					FrmDispatchEvent ( &event );	} while ( event.eType != appStopEvent );}/*********************************************************************** * FUNCTION:     	AppStart * * DESCRIPTION:  	Do whatever is necessary to get started * * RETURNED:     	Err value or 0 if nothing went wrong ***********************************************************************/static UInt32 AppStart(	void){// Return an error code if necessary. 	return 0;}/*********************************************************************** * FUNCTION:    	AppStop * * DESCRIPTION: 	Do whatever you need to do, like save the preferences. * * RETURNED:    	nothing ***********************************************************************/static void AppStop(	void){	FrmCloseAllForms ();}/*********************************************************************** * FUNCTION:    	PilotMain * * DESCRIPTION:	The application main entry point. * * RETURNED:    	0 if launch & execution are successful, non-zero otherwise. ***********************************************************************/UInt32 PilotMain		// ( out ) error code or zero(	UInt16		cmd,				// ( in ) The launch code	MemPtr	/* cmdPBP*/,		// ( in ) Pointer to the launch code structure	UInt16		launchFlags		// ( in ) Extra launch info){	UInt32 	error = 0;// Check the ROM version for compatibility.	error = RomVersionCompatible ( MIN_ROM_VERSION, launchFlags);	if ( error == 0 ){// ROM OK, check for the various launch codes as needed.			switch (cmd)		{			case sysAppLaunchCmdNormalLaunch:							error = AppStart ();				if ( error == 0 )				{					FrmGotoForm ( MainForm );					AppEventLoop ();					AppStop ();				}				break;				// Insert other launch code checks as needed		}	}	return error;}

⌨️ 快捷键说明

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