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

📄 dials.c

📁 CD_高级PALM编程
💻 C
字号:
/********************************************************************* FILE:				Dials.c** DESCRIPTION:	The Dialz example.** VERSION:		1.0**********************************************************************/#include <PalmOS.h>#include 	<PalmCompatibility.h>#include "Dials.h"#include "DialsRsc.h"#include "Utils.h"#include "UtilsRsc.h"/*********************************************************************** * FUNCTION:    	MainFormInit * * DESCRIPTION: 	This routine initializes the MainForm form. * * RETURNED:    	nothing ***********************************************************************/ static void MainFormInit(	FormPtr	frmP		// ( in ) Pointer to the MainForm form.){	if ( frmP != NULL )	{	// Insert code as appropriate		}}/*********************************************************************** * FUNCTION:    	MainFormDraw * * DESCRIPTION: 	This routine draws the non-form contents of the MainForm form. * * RETURNED:    	nothing ***********************************************************************/ static void MainFormDraw(	FormPtr	frmP		// ( in ) Pointer to the MainForm 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 MainForm 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:    	true if the event is handled. ***********************************************************************/ static Boolean MainFormDoMenuCommand // (out) true if the event is handled.(	UInt16 	command			// ( in ) The ID of menu command to do){	Boolean handled = false;	FormPtr frmP;	switch ( command )	{		case MainOptionsAboutDials:					MenuEraseStatus ( 0 );			frmP = FrmInitForm ( AboutForm );			FrmDoDialog ( frmP );			FrmDeleteForm ( frmP );			handled = true;			break;	}	return handled;}/*********************************************************************** * FUNCTION:    	MainFormHandleEvent * * DESCRIPTION: 	This routine is the event handler for MainForm. * * RETURNED:    	true if the event is handled. ***********************************************************************/ static Boolean MainFormHandleEvent // (out) true if the event is handled.(	EventPtr eventP		// ( in ) Pointer to an EventType that contains the event to handle){    Boolean 	handled = false;    FormPtr		frmP = FrmGetActiveForm ();	switch ( eventP->eType ) 	{	// Menu event - call MainFormDoMenuCommand to handle it.		case menuEvent:					handled = MainFormDoMenuCommand ( eventP->data.menu.itemID );			break;		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;	}	return handled;}/*********************************************************************** * FUNCTION:    	AppHandleEvent * * DESCRIPTION: 	Loads a form's resources and set its event handler. * * RETURNED:    	true if the event is handled. ***********************************************************************/ static Boolean AppHandleEvent // (out) true if the event is handled.(	EventPtr eventP		// ( in ) Pointer to an EventType that contains 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.		}		handled = true;	}	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, like read the app preferences. * * RETURNED:     	Err value or 0 if nothing went wrong ***********************************************************************/ static UInt32 AppStart	// (out ) error code(	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 ) exit code(	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;		}	}	return error;}

⌨️ 快捷键说明

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