Exemple #1
0
// ****************************************************************************
//
//  Function Name:	AskUser::InformUser( )
//
//  Description:		Ask the user a question with an inform icon and OK
//							button.
//							Retrieve the message from a resource file.
//
//  Returns:			kAlertYes
//
//  Exceptions:		None
//
// ****************************************************************************
//
YAlertValues	RAlert::AskUser( YResourceId informId )
	{
	RMBCString	string = GetResourceManager().GetResourceString( informId );
#ifdef	TPSDEBUG
	char	buffer[128];
	buffer[0] = '\0';
	WinCode( wsprintf( buffer, " - %d", informId ) );
	string += buffer;
#endif
	return AskUser( (LPCSZ)string );
	}
Exemple #2
0
// ****************************************************************************
//
//  Function Name:	RAlert::AlertUser( )
//
//  Description:		Alert the user of a problem with an Alert and an OK button
//							Retrieve the message from a resource file.
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void	RAlert::AlertUser( YResourceId alertId )
	{
	RMBCString	string = GetResourceManager().GetResourceString( alertId );
#ifdef	TPSDEBUG
	char	buffer[128];
	buffer[0] = '\0';
	WinCode( wsprintf( buffer, " - %d", alertId ) );
	string += buffer;
#endif
	AlertUser( (LPCSZ)string );
	}
Exemple #3
0
// ****************************************************************************
//
//  Function Name:	RAlert::FormatAlertString( )
//
//  Description:		Format an a string with variable text for alert output.
//							Retrieve the message from a resource file and format the
//							subString into the resource string (likely to be a file 
//							name for an error message).
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
RMBCString RAlert::FormatAlertString( YResourceId alertId, const RMBCString& subString )
	{
	LPSZ	lpszString = (LPSZ)GetGlobalBuffer();
	*lpszString = 0;		//	Make sure the string is null terminated...

	RMBCString	string = GetResourceManager().GetResourceString( alertId );
	wsprintf(  lpszString, (LPCSZ)string, (LPCSZ)subString ); 
	
	RMBCString	returnString(lpszString);
	ReleaseGlobalBuffer( (unsigned char*)lpszString );

#ifdef	TPSDEBUG
	char	buffer[10];
	buffer[0] = '\0';
	WinCode( wsprintf( buffer, " - %d", alertId ) );
	returnString += buffer;
#endif

	return returnString;
	}
Exemple #4
0
// ****************************************************************************
//
//  Function Name:	RWindowView::ReleaseMouseCapture( )
//
//  Description:		Releases the mouse capture. Unnecessary on the Mac
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RWindowView::ReleaseMouseCapture( )
	{
	RView::ReleaseMouseCapture( );
	WinCode( ReleaseCapture( ) );
	}
Exemple #5
0
// ****************************************************************************
//
//  Function Name:	RWindowView::SetMouseCapture( )
//
//  Description:		Captures the mouse to this view.
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RWindowView::SetMouseCapture( )
	{
	WinCode( GetCWnd( ).SetCapture( ) );
	RView::SetMouseCapture( );
	}
Exemple #6
0
// ****************************************************************************
//
//  Function Name:	RStandaloneDocument::OnFileSave( )
//
//  Description:		Called when File::Save is chosen from the menu.
//
//  Returns:			user's response if any to filename request
//
//  Exceptions:		File
//
// ****************************************************************************
//
YAlertValues RStandaloneDocument::OnFileSave( BOOLEAN fSaveAs, RSaveAsData* pGivenSaveData /*= NULL*/ )
	{
	BOOLEAN fContinue = TRUE;
	BOOLEAN fSaveCanceled = FALSE;
	RMBCString filename;
	RFileFormat* pFileFormat = NULL;

	while( fContinue )
		{
		// If we dont have a file format, or we are doing a save as, display the save as dialog
		if( !m_pFileFormat || fSaveAs )
			{
			// Initialize a SaveAsStruct with this documents information
			RSaveAsData saveAsData;
			RSaveAsData* pSaveData = pGivenSaveData;

			//	If we weren't given save as data then get it.
			if ( NULL == pGivenSaveData )
			{
				saveAsData.sPathName = GetDocumentFilename( );
				GetSaveFileFormats( saveAsData.m_FileFormatCollection );
				pSaveData = &saveAsData;
			}
	
			//	Remove the file path from the file name so the save dialog
			//	will install the right one for the user's choice of format.
#ifdef _WINDOWS
			int nExtensionStartsAt = pSaveData->sPathName.operator CString( ).ReverseFind( '.' );
			if ( -1 != nExtensionStartsAt )
				pSaveData->sPathName = pSaveData->sPathName.Head( nExtensionStartsAt );
#endif

			// Do the filesave dialog
			DoFileSaveDialog( pSaveData );
			if( pSaveData->sPathName.IsEmpty() ) fSaveCanceled = TRUE;

			// Retrieve the required information
			filename = pSaveData->sPathName;
			pFileFormat = pSaveData->m_pSelectedFileFormat;
			pSaveData->m_FileFormatCollection.Remove( pFileFormat );
			}

		// Otherwise, use the current type and name
		else
			{
			pFileFormat = m_pFileFormat;
			filename = GetDocumentFilename( );
			}

		// If we have a file type, try to save
		if( !fSaveCanceled )
			{
			try
				{
				TpsAssert( pFileFormat, "Save being called on NULL FileFormat" );
				pFileFormat->Save( filename );

				// If this is a symmetric format, update all the document info
				if( pFileFormat->IsSymmetric( ) )
					{
					// Set the format
					if( m_pFileFormat != pFileFormat )
						delete m_pFileFormat;

					m_pFileFormat = pFileFormat;

					// Set the new document filename
					SetDocumentFilename( filename );

					// Update the MRU list
					WinCode( AfxGetApp( )->AddToRecentFileList( filename ) );
					}

//				else
//					delete pFileFormat;

				return kAlertOk;
				}

			catch( YException exception )
				{
				RAlert askUser;

				if( kShareViolation == exception || kAccessDenied == exception )
					fContinue = static_cast<BOOLEAN>( askUser.WarnUser( STRING_ERROR_ACCESS_DENIED ) == kAlertOk );
				else if( kFileNotFound == exception )
					fContinue = static_cast<BOOLEAN>( askUser.WarnUser( STRING_FILE_MOVED_ERROR ) == kAlertOk );
				else
					{
					::ReportException( exception );
					fContinue = FALSE;
					}

				//	Clean up any allocated file formats so they will not be leaked above
				//	when we try to save again.
				if( !pGivenSaveData && (m_pFileFormat==pFileFormat) )
					{
					delete m_pFileFormat;
					m_pFileFormat = NULL;
					pFileFormat = NULL;
					}
				else if ( pGivenSaveData )
					{
					//	insert the format back into the list of formats
					pGivenSaveData->m_FileFormatCollection.InsertAtEnd( pFileFormat );
					pFileFormat = NULL;
					}
				}
			}

		else
			fContinue = FALSE;
		}

	return kAlertCancel;
	}