Example #1
0
void CInstallDiskSpaceDialog::UpdateDiskSpace(void)
{
	CString csFormat;
	CString csMessage;
	CString csAdditional;
	
	TRY
	{
		LoadConfigurationString(IDS_NotEnoughDiskSpaceFormat1, csFormat);
		wsprintf(csMessage.GetBuffer(1024), csFormat, (LPCSTR)m_csDrive);
		csMessage.ReleaseBuffer();
		SetDlgItemText(IDC_NOT_ENOUGH_DISK_SPACE_1, csMessage);
		
		LoadConfigurationString(IDS_NotEnoughDiskSpaceFormat2, csFormat);
		Util::FormatDouble(MAKE_DOUBLE(m_dwNeededSize-m_dwAvailableSize), 2, csAdditional);
		wsprintf(csMessage.GetBuffer(1024), csFormat, (LPCSTR)csAdditional, (LPCSTR)m_csDrive);
		csMessage.ReleaseBuffer();
		SetDlgItemText(IDC_NOT_ENOUGH_DISK_SPACE_2, csMessage);
	}
	CATCH_ALL(e)
	{
		csFormat.Empty();
		csMessage.Empty();
		csAdditional.Empty();
		
		THROW_LAST();
	}
	END_CATCH_ALL
}
Example #2
0
int CChooseDirectoryDialog::DirectoryMessageBox(CWnd *pcwParent, const CString &csDirectory, int nFormatID, int nTitleID, UINT nType, WORD wFlags /* = 0 */, int nDefaultResult /* = IDOK */)
{
	int nResult = nDefaultResult;
	
	if ((wFlags & OPTION_quiet) == 0)
	{
		CString csTitle;
		CString csFormat;
		CString csMessage;
				
		TRY
		{
			LoadConfigurationString(nTitleID, csTitle);
			LoadConfigurationString(nFormatID, csFormat);
			wsprintf(csMessage.GetBuffer(1024), csFormat, (LPCSTR)csDirectory);
			csMessage.ReleaseBuffer();
		}
		CATCH_ALL(e)
		{
			csTitle.Empty();
			csFormat.Empty();
			csMessage.Empty();
			
			THROW_LAST();
		}
		END_CATCH_ALL
				
		nResult = pcwParent->MessageBox(csMessage, csTitle, nType);
	}
Example #3
0
BOOL CPreferencesOnlinePage::OnKillActive()
   {
      BOOL bValidData = TRUE;
      INHERITED::OnKillActive();

      if(m_bVisitedThisPage)
         {
            CConnectionSettings::Type  connectType = CConnectionSettings::typeNone;
            CComboBox   *pDialupsCombo;
            CString     csFileName;

            pDialupsCombo = (CComboBox*)  GetDlgItem(IDC_DIALUP_CONNECTIONS);
            connectType = (CConnectionSettings::Type) pDialupsCombo->GetItemData(m_nCurDialup);
            if(m_comboDialups.IsWindowEnabled() &&
			      connectType == CConnectionSettings::typeModemCustom)
            {
               csFileName = m_pConnSettings->GetAppFileName();
               if(!Util::FileExists(csFileName))
               {
                  CString  csResource;
				      LoadConfigurationString(IDS_ONLINE_MISSING_APPPATH, csResource);
                  ASSERT(!csResource.IsEmpty());
                  AfxMessageBox(csResource);
                  csResource.Empty();
                  csFileName.Empty();
                  bValidData = FALSE;
               }
            }
         }
      return bValidData;
   }
Example #4
0
int CLabelView::OnPrintLabels(PrintContext &pc, int nCurrentPage, int nNumPages)
{
	CPmwDoc* pDoc = GetDocument();
	PPNT dims = pDoc->get_dimensions();

	int nError = 0;

	int nPrintCopies = pc.m_copies;

	while (nError == 0 && nPrintCopies-- > 0)
	{
	// Source will always be all of the label.

		pc.m_source.x0 = 0;
		pc.m_source.y0 = 0;
		pc.m_source.x1 = dims.x;
		pc.m_source.y1 = dims.y;

		OnPrepareDC(&pc.m_dcPrint, pc.m_pInfo);

	// Set up drawing rect to entire page (in logical coordinates)

		pc.m_pInfo->m_rectDraw.SetRect(0, 0,
							pc.m_dcPrint.GetDeviceCaps(HORZRES),
							pc.m_dcPrint.GetDeviceCaps(VERTRES));
		pc.m_dcPrint.DPtoLP(&pc.m_pInfo->m_rectDraw);

		CString strFmt;
		TRY
			LoadConfigurationString(IDS_PRINTPAGENUM, strFmt);
		END_TRY
		char szBuf[80];
		wsprintf(szBuf, strFmt, (int32)nCurrentPage+1, (int32)nNumPages);
		pc.m_dlgstatus->SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf);

		if (!pc.m_fBanding)
		{
			VERIFY(pc.m_dcPrint.StartPage());
		}
		nError = OnPrint(&pc, pc.m_pInfo) || UserAbort;
		if (!pc.m_fBanding)
		{
			if (pc.m_dcPrint.EndPage() < 0)
				nError = TRUE;
		}
	}
	return nError;
}
Example #5
0
int CInstallDiskSpaceDialog::CheckDiskSpace(const CString &csDirectory, DWORD dwNeededSize)
{
	int nResult = IDOK;
	
	CString csFormat;
	
	TRY
	{
		// If we are installing a demo, check if we can install into the directory.
		if ((GetInstallApp()->GetInstallInfo()->m_nInstallConfiguration == CPrintMasterConfiguration::Demo)
		 && (!GetInstallApp()->DemoCanBeInstalledIntoDirectory(csDirectory)))
		{
			LoadConfigurationString(IDS_CantInstallDemoToDirectory, csFormat);
			Util::MessageBox(
					MB_OK|MB_DEFBUTTON1,
					(UINT)-1,
					(LPCSTR)csFormat,
					(LPCSTR)csDirectory);
			nResult = IDCANCEL;
		}
		
		// Make sure the directory is not a root directory.
		else if (Util::IsRootDirectory(csDirectory))
		{
			LoadConfigurationString(IDS_CantInstallToRootDirectory, csFormat);
			Util::MessageBox(
					MB_OK|MB_DEFBUTTON1,
					(UINT)-1,
					(LPCSTR)csFormat,
					(LPCSTR)csDirectory);
			nResult = IDCANCEL;
		}

		// Make sure the directory is not the Windows directory.
		else if (Util::IsWindowsDirectory(csDirectory))
		{
			LoadConfigurationString(IDS_CantInstallToWindowsDirectory, csFormat);
			Util::MessageBox(
					MB_OK|MB_DEFBUTTON1,
					(UINT)-1,
					(LPCSTR)csFormat,
					(LPCSTR)csDirectory);
			nResult = IDCANCEL;
		}

		// Make sure the directory is not the Windows system directory.
		else if (Util::IsSystemDirectory(csDirectory))
		{
			LoadConfigurationString(IDS_CantInstallToSystemDirectory, csFormat);
			Util::MessageBox(
					MB_OK|MB_DEFBUTTON1,
					(UINT)-1,
					(LPCSTR)csFormat,
					(LPCSTR)csDirectory);
			nResult = IDCANCEL;
		}

		else
		{
			// If we are installing into a 
			// get the available disk space
			DWORD dwAvailableSize = Util::GetAvailableDiskSpace(csDirectory);
		
			if ((dwAvailableSize != DISK_SPACE_NOT_AVAILABLE)
			 && (dwNeededSize != DISK_SPACE_NOT_AVAILABLE))
			{
				// if the available space is less than we need, tell the user
				if (dwAvailableSize < dwNeededSize)
				{
					m_dwNeededSize = dwNeededSize;
					m_dwAvailableSize = dwAvailableSize;
					m_csDirectory = csDirectory;
					
					if (Util::DirectoryDrive(m_csDirectory, m_csDrive))
					{
						if ((m_csDrive.GetLength() >= 2) && (m_csDrive[1] == ':'))
						{
							m_csDrive.MakeUpper();
							char cDriveLetter = m_csDrive[0];
							LoadConfigurationString(IDS_DriveFormatLowercase, csFormat);
							wsprintf(m_csDrive.GetBuffer(1024), csFormat, cDriveLetter);
							m_csDrive.ReleaseBuffer();
							m_csDrive += ':';
						}
					}
					
					if ((!m_csDirectory.IsEmpty())
					 && (!m_csDrive.IsEmpty()))
					{
						nResult = DoModal();
					}
				}
			}
			
			if (nResult == IDOK)
			{
				// check if the directory exists
				if (Util::DirectoryExists(csDirectory))
				{
					// the directory already exists, the user must confirm overwrite
					LoadConfigurationString(IDS_DirectoryAlreadyExistsFormat, csFormat);
					if (Util::MessageBox(
							MB_YESNO|MB_DEFBUTTON1,
							(UINT)-1,
							(LPCSTR)csFormat,
							(LPCSTR)csDirectory,
							(LPCSTR)csDirectory) == IDNO)
					{
						nResult = IDCANCEL;
					}
				}
			
				if (nResult == IDOK)
				{
					// check if the directory can be created
					if (!Util::MakeDirectory(csDirectory))
					{
						LoadConfigurationString(IDS_ErrCantCreateDirectory, csFormat);
						Util::MessageBox(
							MB_OK,
							(UINT)-1,
							(LPCSTR)csFormat,
							(LPCSTR)csDirectory);
						nResult = IDCANCEL;
					}
				}
			}
		}
	}
	CATCH_ALL(e)
	{
		csFormat.Empty();
		
		THROW_LAST();
	}
	END_CATCH_ALL
	
	return nResult;
}
Example #6
0
void CInstallDiskSpaceDialog::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
	CPmwDialog::OnActivate(nState, pWndOther, bMinimized);
	
	/*
	// The user may have left and freed some disk space, so we need to get the new
	// disk space and check.
	*/
	
	if (!m_fAborted)
	{
		if ((nState == WA_ACTIVE) || (nState == WA_CLICKACTIVE))
		{
			DWORD dwAvailableSize = Util::GetAvailableDiskSpace(m_csDirectory);
				
			if (dwAvailableSize == DISK_SPACE_NOT_AVAILABLE)
			{
				/*
				// What da hey? Perhaps a connected drive became
				// unconnected. Do the default cancel action.
				*/
				
				OnCancel();
			}
			
			m_dwAvailableSize = dwAvailableSize;
					
			if (m_dwAvailableSize < m_dwNeededSize)
			{
				/*
				// There is still not enough disk space. Update the current dialog
				// with any new numbers.
				*/
				
				UpdateDiskSpace();
			}
			
			else
			{
				/*
				// Amazing! There is now enough disk space! Inform the user and
				// wait for confirmation to proceed.
				*/
				
				CString csFormat;
				CString csMessage;
							
				TRY
				{
					LoadConfigurationString(IDS_NowEnoughDiskSpaceFormat, csFormat);
					wsprintf(csMessage.GetBuffer(1024), csFormat, (LPCSTR)m_csDrive, (LPCSTR)m_csDrive);
					csMessage.ReleaseBuffer();
				}
				CATCH_ALL(e)
				{
					csFormat.Empty();
					csMessage.Empty();
					
					THROW_LAST();
				}
				END_CATCH_ALL
				
				m_fAborted = TRUE;
				
				if (AfxMessageBox(csMessage, MB_YESNO) == IDYES)
				{
					EndDialog(IDOK);
				}
				
				else
				{
					EndDialog(IDCANCEL);
				}
			}
		}
	}
Example #7
0
LRESULT CWorkspacePreferencesDialog::OnValidateWorkspaceSize(WPARAM wParam, LPARAM lParam)
{
	CString csSize;
	CString csFormat;
	CString csMessage;
	CString csError;

	LRESULT lResult = 0;

	TRY
	{
		GetDlgItemText(IDC_WORKSPACE_SIZE, csSize.GetBuffer(100), 100-1);
		csSize.ReleaseBuffer();

		// get the value that the user entered
		BOOL fIsValid = TRUE;
		BOOL fSeenDigit = FALSE;
		BOOL fSeenDecimal = FALSE;
		DWORD dwSize = 0L;
		DWORD dwFraction = 1000000L;

		for (int i = 0; i < csSize.GetLength(); i++)
		{
			if ((csSize[i] >= '0') && (csSize[i] <= '9'))
			{
				if (!fSeenDecimal)
				{
					dwSize = (dwSize*10L)+(1000000L*(csSize[i]-'0'));
				}

				else
				{
					dwFraction /= 10L;
					dwSize += dwFraction*(csSize[i]-'0');
				}

				fSeenDigit = TRUE;
			}

			else if (csSize[i] == '.')
			{
				if (fSeenDecimal)
				{
					fIsValid = FALSE;
					break;
				}

				fSeenDecimal = TRUE;
			}

			else if (csSize[i] != ' ')
			{
				fIsValid = FALSE;
				break;
			}
		}

		if (!fSeenDigit)
		{
			fIsValid = FALSE;
		}

		if (!fIsValid)
		{
			GetConfiguration()->MessageBox(IDS_ErrInvalidWorkspaceSize, 0, MB_OK|MB_ICONEXCLAMATION);
		}

		else
		{
			// a number was entered, check if it is with the legal range

			DWORD dwMinMaxSize;

			if (dwSize < MINIMUM_WORKSPACE_SIZE)
			{
				LoadConfigurationString(IDS_ErrWorkspaceSizeTooSmall, csFormat);
				dwMinMaxSize = MINIMUM_WORKSPACE_SIZE;
				fIsValid = FALSE;
			}

			if (dwSize > MAXIMUM_WORKSPACE_SIZE)
			{
				LoadConfigurationString(IDS_ErrWorkspaceSizeTooLarge, csFormat);
				dwMinMaxSize = MAXIMUM_WORKSPACE_SIZE;
				fIsValid = FALSE;
			}

			if (!fIsValid)
			{
				wsprintf(csMessage.GetBuffer(1024), csFormat, (int)(dwMinMaxSize/1000000L));
				csMessage.ReleaseBuffer();
			}

			if (!fIsValid)
			{
				AfxMessageBox(csMessage, MB_OK|MB_ICONEXCLAMATION);
			}
		}

		if (fIsValid)
		{
			// the number entered was valid, display it
			SetWorkspaceSize(dwSize);
			RedrawInterface();
			lResult = 1;
		}

		else
		{
			// restore the number to its previous value
			m_fRedrawWorkspaceSize = TRUE;
			RedrawInterface();

			// reset the focus back to the workspace edit
			GetDlgItem(IDC_WORKSPACE_SIZE)->SetFocus();
		}
	}
	CATCH_ALL(e)
	{
		csSize.Empty();
		csFormat.Empty();
		csMessage.Empty();

		THROW_LAST();
	}
	END_CATCH_ALL

	return lResult;
}
Example #8
0
void CWorkspacePreferencesDialog::RedrawInterface(void)
{
	/*
	// Redraw those interface elements that have changed.
	*/

	CString csSize;
	CString csValue;

	TRY
	{
		// workspace size changed
		if (m_fRedrawWorkspaceSize)
		{
			if (m_dwWorkspaceSize != DISK_SPACE_NOT_AVAILABLE)
			{
				// update the interface
				Util::FormatDouble(((double)m_dwWorkspaceSize)/1000000.0, -2, csSize);
				SetDlgItemText(IDC_WORKSPACE_SIZE, csSize);
			}

			m_fRedrawWorkspaceSize = FALSE;
		}

		// disk requirements changed
		if (m_fRedrawDiskRequirements)
		{
			if (m_dwWorkspaceSize != DISK_SPACE_NOT_AVAILABLE)
			{
				DWORD dwAvailableSize = Util::GetAvailableDiskSpace(m_csWorkspaceDirectory);
				DWORD dwRecommendedSize = GetRecommendedWorkspaceSize(m_csWorkspaceDirectory,
																						m_cache->get_physical_size());

				// display the recommended size
				double dRecommendedSize = MAKE_DOUBLE(dwRecommendedSize);
				Util::FormatDouble(dRecommendedSize, 2, csValue);
				csValue += " Mb";
				SetDlgItemText(IDC_RECOMMENDED_SIZE, csValue);

				// display available disk space
				double dAvailableSize;

				if (dwAvailableSize == DISK_SPACE_NOT_AVAILABLE)
				{
					LoadConfigurationString(IDS_DiskSpaceNotAvailable, csValue);
				}

				else
				{
					dAvailableSize = MAKE_DOUBLE(dwAvailableSize);
					Util::FormatDouble(dAvailableSize, 2, csValue);
					csValue += " Mb";
				}

				SetDlgItemText(IDC_CURRENT_DISK_SPACE, csValue);
			}

			m_fRedrawDiskRequirements = FALSE;
		}
	}
	CATCH_ALL(e)
	{
		csSize.Empty();
		csValue.Empty();

		THROW_LAST();
	}
	END_CATCH_ALL
}