Esempio n. 1
0
int DoEnterNewAddressDialog(StringPtr name, StringPtr description)
	{
		short itemHit,okay=FALSE,keepGoing=TRUE;
		DialogPtr dlog=NIL; GrafPtr oldPort;
		ModalFilterUPP MyFilterUPP;

		GetPort(&oldPort);

		/* On PowerPC, need a RoutineDescriptor from heap; on 68K, no allocation */

		MyFilterUPP = NewModalFilterProc(MyFilter);
		if (MyFilterUPP == NIL) goto cleanUp;

		/* Build dialog window and install its item values */

		dlog = OpenThisDialog(name, description);
		if (dlog == NIL) goto cleanUp;

		/* Entertain filtered user events until dialog is dismissed */

		while (keepGoing) {
			ModalDialog(MyFilterUPP,&itemHit);
			keepGoing = DoDialogItem(dlog,itemHit);
			}

		/*
		 *	Do final processing of item values, such as exporting them to caller.
		 *	DoDialogItem() has already called AnyBadValues().
		 */

		okay = (itemHit == OK_ITEM);
		if (okay) {
			GetDlgString(dlog, EDIT5, name);
			GetDlgString(dlog, EDIT6, description);
		}

		/* That's all, folks! */

cleanUp:
		if (dlog) CloseThisDialog(dlog);
		if (MyFilterUPP) DisposeRoutineDescriptor(MyFilterUPP);
		SetPort(oldPort);

		return(okay);
	}
Esempio n. 2
0
int DoHostListDialog()
	{
		short itemHit,okay=FALSE,keepGoing=TRUE;
		DialogPtr dlog=NIL; GrafPtr oldPort;
		ModalFilterUPP MyFilterUPP;

		GetPort(&oldPort);

		/* On PowerPC, need a RoutineDescriptor from heap; on 68K, no allocation */
		
		MyFilterUPP = NewModalFilterProc(MyFilterHD);
		if (MyFilterUPP == NIL) goto cleanUp;

		/* Build dialog window and install its item values */
		
		OpenPrefsFile();
		
		dlog = OpenThisDialog();
		if (dlog == NIL) goto cleanUp;

		/* Entertain filtered user events until dialog is dismissed */
		
		while (keepGoing) {
			ModalDialog(MyFilterUPP,&itemHit);
			keepGoing = DoDialogItem(dlog,itemHit);
			}
		
		/*
		 *	Do final processing of item values, such as exporting them to caller.
		 *	DoDialogItem() has already called AnyBadValues().
		 */
		
		if (itemHit == OK_ITEM) {
			Point	theCell;
			short	dataLen;
			OSErr	anErr;
			Handle	aHand;
			
			//	get the current selection and store it in a global which can be accessed
			//	from the application
			
			theCell.h = 0;
			theCell.v = list4.currentRow;
			
			dataLen = 255;
			LGetCell(&gSavedSelection[1], &dataLen, theCell, list4.hndl);
			gSavedSelection[0] = dataLen;

			//	we save the current selection for the next time we use this transport
			
			//	remove the current resource
			
			aHand = Get1Resource('mw2H', 1000);
			if (aHand != nil) {
				RemoveResource(aHand);
				DisposeHandle(aHand);
				aHand = nil;
			}
			
			//	create a handle and add this resource to the resource file
			
			anErr = PtrToHand(&gSavedSelection[0], &aHand, gSavedSelection[0] + 1);		//	name and length byte
			if ( (anErr == noErr) && (aHand != nil) ) {
				AddResource(aHand, 'mw2H', 1000, "\pDefault Host");
				WriteResource(aHand);
			}