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

📄 ndbtest.c

📁 CD_高级PALM编程
💻 C
📖 第 1 页 / 共 2 页
字号:
					MainFormError( err );					SetTextFieldWithHandle( MainPropertyField, CreateEmptyHandle(), true );				}			} // error occurred											handled = true;			break;					case MainBackButton:			if ( mainDatabaseRecordH )			{				if ( NDBRecordIsValid( mainDatabaseRecordH, &err ) )				{// Get the next record.					mainDatabaseRecordH = NDBRecordGetPrev( mainDatabaseRecordH, &err );					MainFormDrawRecordView( );					if ( err != noErr )					{						if ( err == ndbErrorNoPreviousRecord )						{							FrmAlert( FirstRecordAlert );						}						else						{							MainFormError( err );							SetTextFieldWithHandle( MainPropertyField, CreateEmptyHandle(), true );						}					} // error occurred				}			}			handled = true;			break;					case MainNextButton:			if ( mainDatabaseRecordH )			{				if ( NDBRecordIsValid( mainDatabaseRecordH, &err ) )				{// Get the next record.					mainDatabaseRecordH = NDBRecordGetNext( mainDatabaseRecordH, &err );					MainFormDrawRecordView( );					if ( err != noErr )					{						if ( err == ndbErrorSearchOver )						{							FrmAlert( LastRecordAlert );						}						else						{							MainFormError( err );							SetTextFieldWithHandle( MainPropertyField, CreateEmptyHandle(), true );						}					} // error occurred				}			}			handled = true;			break;		}	return handled;}/*********************************************************************** * FUNCTION:    	MainFormHandleDatabasePopup * * DESCRIPTION: 	This routine handles database popup events for  *                  the MainForm. * * RETURNED:    	true if the event is handled. ***********************************************************************/static Boolean MainFormHandleFieldPopup	// (out) returns true if event handled.(	UInt16		selection 		//	(in)	the selection){	Boolean	handledEvt = false;	NDBPropertyEnum prop;	MemHandle resultH;	Err err;	// Find out what property we should fetch.	prop = mainDatabasePickerFields[ selection ];// Fetch a handle to that property.	resultH  = NDBRecordGetProp( mainDatabaseRecordH, prop, &err );	// If there's no error, show the property.	if ( err == noErr )	{		if ( resultH != NULL )		{// Show the property			SetTextFieldWithHandle( MainPropertyField, resultH, true );		} // property available		else		{// That property was empty... tell the user.			FrmAlert( PropertyEmptyAlert );			SetTextFieldWithHandle( MainPropertyField, CreateEmptyHandle(), true );		} // no property available	} // no error	else	{		MainFormError( err );		SetTextFieldWithHandle( MainPropertyField, CreateEmptyHandle(), true );	} // error occurred		return handledEvt;}/*********************************************************************** * FUNCTION:    	MainFormHandleDatabasePopup * * DESCRIPTION: 	This routine handles database popup events for  *                  the MainForm. * * RETURNED:    	true if the event is handled. ***********************************************************************/static Boolean MainFormHandleDatabasePopup	// (out) returns true if event handled.(	UInt16		selection 		//	(in)	the selection){	Boolean	handledEvt = false;	Err	err;		if ( mainDatabaseRecordH )	{		NDBRecordFree ( mainDatabaseRecordH, &err );		mainDatabaseRecordH = NULL;	}		mainDatabaseRecordH = NDBFindRecordWith ( 		mainDatabasePickerDatabases[ selection ],		NULL,		&err	);		if ( err != noErr )	{		if ( mainDatabaseRecordH != NULL )		{			NDBRecordFree( mainDatabaseRecordH, &err );			mainDatabaseRecordH = NULL;		}	}// Redraw fields with new values.	MainFormDrawRecordView( );	return handledEvt;}/*********************************************************************** * FUNCTION:    	MainFormHandleEvent * * DESCRIPTION: 	This routine is the event handler for MainForm. * * RETURNED:    	true if the event is handled. ***********************************************************************/ static Boolean MainFormHandleEvent // (out) true if 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;			// Control activities		case keyDownEvent: 			if ( eventP->data.keyDown.chr == pageUpChr )			{				handled = MainFormHandleControl( MainBackButton );			}			else if ( eventP->data.keyDown.chr == pageDownChr )			{				handled = MainFormHandleControl( MainNextButton );			}					case ctlSelectEvent:			handled = MainFormHandleControl( eventP->data.ctlSelect.controlID );			break;					case popSelectEvent: // A popup list item was selected			if ( eventP->data.ctlSelect.controlID == MainFieldPopTrigger )				handled = MainFormHandleFieldPopup( (unsigned short)eventP->data.popSelect.selection );						if ( eventP->data.ctlSelect.controlID == MainDatabasePopTrigger )				handled = MainFormHandleDatabasePopup( (unsigned short)eventP->data.popSelect.selection );						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 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(	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(	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 + -