Ejemplo n.º 1
0
void CuPageInformation::SetTitle (LPCTSTR  strItem, CTreeItem* pItem, CdIpmDoc* pDoc)
{
	CString strNotAvailable;
	strNotAvailable.LoadString(IDS_NOT_AVAILABLE);
	if (m_nIDTitle == 0)
	{
		m_strTitle = _T("");
		return;
	}
	if (m_strClassName == _T("CuTMSession") || 
	    m_strClassName == _T("CuTMBlockingSession") ||
	    m_strClassName == _T("CuTMSessBlockingSession") )
	{
		SERVERDATAMIN svrdta;
		ASSERT (pDoc != NULL);
		if (pDoc == NULL)
		{
			m_strTitle = _T("");
			return;
		}
		TCHAR tchszServer [100];
		LPVOID pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL;
		BOOL bOK = IPM_GetRelatedInfo (pDoc, OT_MON_SESSION, pStruct, OT_MON_SERVER, &svrdta);

		if (bOK) 
		{
			IPM_GetInfoName (pDoc, OT_MON_SERVER, (void*)&svrdta, tchszServer, sizeof (tchszServer));
			AfxFormatString2 (m_strTitle, m_nIDTitle, (LPCTSTR)tchszServer, (LPCTSTR)strItem);
		}
		else
			AfxFormatString2 (m_strTitle, m_nIDTitle, strNotAvailable, (LPCTSTR)strItem);//"<n/a>"
	}
	else
		AfxFormatString1 (m_strTitle, m_nIDTitle, (LPCTSTR)strItem);
}
Ejemplo n.º 2
0
void CaIjaTable::Display (CTreeCtrl* pTree, HTREEITEM hParent)
{
	HTREEITEM hItem = m_treeCtrlData.GetTreeItem();
	BOOL bMultiple = FALSE;
	CString strDisplay;
#if defined (MULTIPLE_TABLEOWNER)
	//
	// Find if this Item exists in the Tree:
	if (pTree->ItemHasChildren(hParent))
	{
		HTREEITEM hT1 = pTree->GetChildItem(hParent);
		while (hT1)
		{
			CaIjaTreeItemData* pData = (CaIjaTreeItemData*)pTree->GetItemData(hT1);
			if (pData && pData != this)
			{
				if (pData->GetItem().CompareNoCase(m_strItem) == 0)
				{
					if (!pData->GetOwner().IsEmpty())
						AfxFormatString2 (strDisplay, IDS_OWNERxITEM, (LPCTSTR)pData->GetOwner(), (LPCTSTR)pData->GetItem());
					else
						strDisplay = pData->GetItem();
					pTree->SetItemText (hT1, strDisplay);
					bMultiple = TRUE;
					break;
				}
			}
			hT1 = pTree->GetNextItem (hT1, TVGN_NEXT);
		}
	}
	
	if (bMultiple)
		AfxFormatString2 (strDisplay, IDS_OWNERxITEM, (LPCTSTR)m_strOwner, (LPCTSTR)m_strItem);
	else
		strDisplay = m_strItem;

	if (hItem == NULL)
	{
		hItem = IJA_TreeAddItem (strDisplay, pTree, hParent, TVI_SORT, m_treeCtrlData.GetImage(), (DWORD)this);
		m_treeCtrlData.SetTreeItem(hItem);
		GetTreeCtrlData().SetState (CaTreeCtrlData::ITEM_EXIST);
	}
	else
	{
		pTree->SetItemText (hItem, strDisplay);
	}
#else
	if (hItem == NULL)
	{
		if (!m_strItemOwner.IsEmpty())
			AfxFormatString2 (strDisplay, IDS_OWNERxITEM, (LPCTSTR)m_strItemOwner, (LPCTSTR)m_strItem);
		else
			strDisplay = m_strItem;
		hItem = IJA_TreeAddItem (strDisplay, pTree, hParent, TVI_LAST, m_treeCtrlData.GetImage(), (DWORD)this);
		m_treeCtrlData.SetTreeItem(hItem);
	}
#endif
}
Ejemplo n.º 3
0
bool CPluginParamDlg::CreateView()
{
	// create child view that contains parameter controls
	CRuntimeClass	*pFactory = RUNTIME_CLASS(CPluginParamView);
	m_View = DYNAMIC_DOWNCAST(CPluginParamView, pFactory->CreateObject());
	if (m_View == NULL) {
		AfxMessageBox(IDS_PLUGIN_CANT_CREATE_VIEW);
		return(FALSE);
	}
	CRect	rView;
	GetViewHolderRect(rView);
	DWORD	dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_BORDER;
    if (!m_View->Create(NULL, NULL, dwStyle, rView, this, 0, NULL)) {
		AfxMessageBox(IDS_PLUGIN_CANT_CREATE_VIEW);
		return(FALSE);
	}
	if (!m_View->InitRows(m_PluginPath, m_SampleRate)) {
		CString	msg;
		AfxFormatString2(msg, IDS_PLUGIN_CANT_LOAD, m_PluginPath,
			CWinAppEx::GetLastErrorString());
		AfxMessageBox(msg);
		return(FALSE);
	}
	if (m_Param.GetSize())
		m_View->SetParams(m_Param);
	SetWindowText(CString(m_View->GetDescriptor()->Name));
	return(TRUE);
}
Ejemplo n.º 4
0
void CMacroDlg::OnOpenFile()
{
   int nResult;
   HRESULT hResult;

   CString strFilter;
   LOAD_STRING_FROM_RESOURCE(strFilter, IDS_SCRIPT_FILES);
   CFileDialog dlg( TRUE, _T( "dsm" ), NULL, OFN_HIDEREADONLY|
	  OFN_OVERWRITEPROMPT, strFilter );

   nResult = (int)dlg.DoModal();
   if( nResult != IDOK )
   {
	  return;
   }

   hResult = m_pScriptManager->LoadScript( dlg.GetPathName(),
	  dlg.GetFileTitle() );
   if( FAILED( hResult ) )
   {
	  CString strErrorMessage;
	  _com_error error( hResult );

	  AfxFormatString2( strErrorMessage, IDS_ERRORLOADINGSCRIPT,
		 dlg.GetFileTitle(), error.ErrorMessage() );
	  AfxMessageBox( strErrorMessage );
	  return;
   }

   UpdateMacroList();
}
Ejemplo n.º 5
0
BOOL CCompactDataBase::OnInitDialog() // ok
{
	CDialog::OnInitDialog();
	
//	TODO: Add extra initialization here
	CButton *pButton = NULL;
	if (dbVersion30 == m_iVersion)
		pButton = (CButton *) GetDlgItem (IDB_VERSION30);		
	else
		pButton = (CButton *) GetDlgItem (IDB_VERSION20);		
	ASSERT (NULL != pButton);
	pButton -> SetCheck (1);

	m_btAsNew.SetCheck (1);
	m_btOk.EnableWindow (FALSE);

//	Caption neu bilden
	ASSERT (!m_strOldDatabase.IsEmpty ());

	CString strFileName, strExt, strCaption, strDrive, strDir, strPath;
	char *pFileName = strFileName.GetBuffer (_MAX_FNAME);
	char *pExt = strExt.GetBuffer (_MAX_EXT);
	char *pDrive = strDrive.GetBuffer (_MAX_DRIVE);
	char *pDir = strDir.GetBuffer (_MAX_DIR);
	char *pPath = strPath.GetBuffer (_MAX_PATH);
	_splitpath (m_strOldDatabase, pDrive, pDir, pFileName, pExt);
	_makepath (pPath, pDrive, pDir, NULL, NULL);
	m_strDir = pPath;				// Verzeichnis speichern
	AfxFormatString2 (strCaption, IDS_COMPACT_DATABASE, 
					  strupr (pFileName), strupr (pExt));
	SetWindowText (strCaption);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 6
0
BOOL SQLW_ComboBoxFillTables (CComboBox* pCombo, CaLLQueryInfo* pInfo)
{
	int idx = -1;
	CString strItem;
	CTypedPtrList<CObList, CaDBObject*> listObject;

	BOOL bOk = theApp.INGRESII_QueryObject (pInfo, listObject);
	if (!bOk)
		return FALSE;

	POSITION pos = listObject.GetHeadPosition();
	while (pos != NULL)
	{
		CaDBObject* pObj = listObject.GetNext(pos);
#if defined (_DISPLAY_OWNERxITEM)
		AfxFormatString2 (strItem, IDS_OWNERxITEM, (LPCTSTR)pObj->GetOwner(), (LPCTSTR)pObj->GetItem());
#else
		strItem = pObj->GetName();
#endif
		idx = pCombo->AddString (strItem);
		if (idx != CB_ERR)
			pCombo->SetItemData (idx, (DWORD)pObj);
		else
			delete pObj;
	}

	return TRUE;
}
Ejemplo n.º 7
0
BOOL CPerServerLicensingDialog::OnInitDialog() 

/*++

Routine Description:

    Message handler for WM_INITDIALOG.

Arguments:

    None.

Return Values:

    Returns false if focus set manually.

--*/

{
    AfxFormatString2(
        m_strStaticClients, 
        IDS_PER_SERVER_LICENSING_1, 
        m_strLicenses, 
        m_strProduct
        );

    CDialog::OnInitDialog();
    
    m_agreeBtn.SetCheck(0);
    m_okBtn.EnableWindow(FALSE);

    return TRUE;  
}
Ejemplo n.º 8
0
BOOL COSMCtrlMapOperationsDlg::DeleteCachedTilesHelper()
{
  //What will be the return value from this function (assume the best)
  BOOL bSuccess = TRUE;

  //Accumulate how many tiles we have deleted and not deleted
  int nTilesDeleted = 0;
  int nTilesNotDeleted = 0;

  //Work thro all the tiles
  CString sCacheDirectory(m_pOSMCtrl->GetCacheDirectory());
  for (std::vector<COSMCtrlMapOperationsDlgTile>::size_type i=0; (i<m_Tiles.size()) && bSuccess; i++)
  {
    //Pull out the tile we are working on
    const COSMCtrlMapOperationsDlgTile& tile = m_Tiles[i];

    //Do the deletion of the tile        
    CString sTile(m_pOSMCtrl->GetTileCachePath(sCacheDirectory, tile.m_nZoom, tile.m_nTileX, tile.m_nTileY, FALSE));
    COSMCtrlMapOperationsDlgEvent dlgEvent;
    if (GetFileAttributes(sTile) != INVALID_FILE_ATTRIBUTES) //Don't bother doing anything if the tile does not already exist
    {
      if (DeleteFile(sTile))
      {
        //Update the stats
        ++nTilesDeleted;
        
        dlgEvent.m_bSuccess = true;
      }
      else
      {
        //Update the stats
        ++nTilesNotDeleted;
        
        dlgEvent.m_bSuccess = false;
      }
    }

    //Update the UI          
    dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
    dlgEvent.m_sString = sTile;
    dlgEvent.m_nItemData = i + 1;
    AddEvent(dlgEvent);
    
    //Check if we have been cancelled before we loop around
    bSuccess = (WaitForSingleObject(m_WorkerTerminateEvent, 0) == WAIT_TIMEOUT);
  }
  
  //Finally add a event about how many items have been deleted
  COSMCtrlMapOperationsDlgEvent dlgEvent;
  dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
  CString sTilesDeleted;
  sTilesDeleted.Format(_T("%d"), nTilesDeleted);
  CString sTilesNotDeleted;
  sTilesNotDeleted.Format(_T("%d"), nTilesNotDeleted);
  AfxFormatString2(dlgEvent.m_sString, IDS_OSMCTRL_DELETE_FILES_STATS, sTilesDeleted, sTilesNotDeleted);
  AddEvent(dlgEvent);
  
  return bSuccess;
}
Ejemplo n.º 9
0
bool CMainFrame::CheckForUpdates(bool Explicit)
{
	enum {	// update check flags
		UF_EXPLICIT	= 0x01,	// explicit check (as opposed to automatic)
		UF_X64		= 0x02,	// target application is 64-bit
		UF_PORTABLE	= 0x04,	// target application is portable (no installer)
	};
	CPathStr	DLLPath(theApp.GetAppFolder());
	DLLPath.Append(_T("CKUpdate.dll"));
	CDLLWrap	dll;
	if (!dll.LoadLibrary(DLLPath)) {	// if we can't load DLL
		if (Explicit) {
			CString	msg;
			AfxFormatString2(msg, IDS_CKUP_CANT_LOAD_DLL, DLLPath,
				CWinAppEx::GetLastErrorString());
			AfxMessageBox(msg);
		}
		return(FALSE);
	}
	LPCTSTR	ProcName = _T("CKUpdate");
	CKUPDATE_PTR	CKUpdate = (CKUPDATE_PTR)dll.GetProcAddress(ProcName);
	if (CKUpdate == NULL) {	// if we can't get address
		if (Explicit) {
			CString	msg;
			AfxFormatString2(msg, IDS_CKUP_CANT_GET_ADDR, ProcName,
				CWinAppEx::GetLastErrorString());
			AfxMessageBox(msg);
		}
		return(FALSE);
	}
	UINT	flags = 0;
	if (Explicit)
		flags |= UF_EXPLICIT;	// explicit check (as opposed to automatic)
#ifdef _WIN64
	flags |= UF_X64;	// target application is 64-bit
#endif
#ifdef PORTABLE_APP
	flags |= UF_PORTABLE;	// target application is portable (no installer)
#endif
	// if this app uses Unicode, the CKUpdate DLL must also use Unicode,
	// else CKUpdate only receives the first character of TargetAppName.
	UINT	retc = CKUpdate(m_hWnd, theApp.m_pszAppName, flags);
	return(retc != 0);
}
Ejemplo n.º 10
0
void CHttpDownloadDlg::SetPercentage(int nPercentage)
{
	//Change the progress control
	m_ctrlProgress.SetPos(nPercentage);

	//Change the caption text
	CString sPercentage;
	sPercentage.Format(_T("%d"), nPercentage);
	CString sCaption;
	AfxFormatString2(sCaption, IDS_HTTPDOWNLOAD_PERCENTAGE, sPercentage, m_sFilename);
	SetWindowText(sCaption);
}
Ejemplo n.º 11
0
void CFTPTransferDlg::SetPercentage(int nPercentage)
{
  //Change the progress control
  m_ctrlProgress.SetPos(nPercentage);

  //Change the caption text
  CString sPercentage;
  sPercentage.Format(_T("%d"), nPercentage);
  CString sCaption;
  AfxFormatString2(sCaption, IDS_FTPTRANSFER_PERCENTAGE, sPercentage, m_sRemoteFile);  
  
}
Ejemplo n.º 12
0
CString CEntsorgerSet::GetDefaultSQL()
{
	ASSERT (!m_strTableName.IsEmpty ());	
	CString strSQL, strWhere;

//	ggf. Where-Klausel einbauen
	if (((CGakApp*)AfxGetApp ()) -> OnlyValidEntsorger ())
		VERIFY (strWhere.LoadString (IDS_ENTS_WHERE));

	//	SELECT Nummer,Name,Ortsname,Postleitzahl,Strasse,Anlage FROM [%1] %2 ORDER BY Nummer
	AfxFormatString2 (strSQL, IDS_ENTS_SELECT, m_strTableName, strWhere);
	return strSQL;
}
void COXNetBrowseTree::ReportNetError(DWORD nResult, LPCTSTR pszResource)
{
	// ... pszResource may be NULL
	CString sNetResource(pszResource);
	CString sErrorMsg;
	sErrorMsg = GetResultMessage(nResult);
	CString sPrompt;
	AfxFormatString2(sPrompt, IDS_OX_NET_BROWSE_ERROR, sNetResource, sErrorMsg);
	if (m_bReport)
		AfxMessageBox(sPrompt, MB_ICONEXCLAMATION | MB_OK, IDS_OX_NET_BROWSE_ERROR);
	else
	{
		TRACE1("COXNetBrowseTree::ReportNetError : Not warning the user of the network error :\n\t%s",
			sPrompt);
		return;
	}
}
Ejemplo n.º 14
0
bool CCrossDlg::SaveCheck(int Sel)
{
	ASSERT(Sel >= 0 && Sel < SELS);
	if (!m_Modified[Sel])
		return(TRUE);
	CString	s, fname;
	GetName(Sel, fname);
	AfxFormatString2(s, IDS_CF_SAVE_PROMPT, m_Frm->GetSelName(Sel), fname);
	int	retc = AfxMessageBox(s, MB_YESNOCANCEL);
	if (retc == IDCANCEL)
		return(FALSE);
	if (retc == IDNO) {
		m_Modified[Sel] = FALSE;
		return(TRUE);
	}
	return(Save(Sel));
}
Ejemplo n.º 15
0
CString CSearchSet::GetDefaultSQL()
{
	CString strTableName;
	strTableName = ((CGakApp *)(AfxGetApp ())) -> ErzeugerDefaultSQL ();

	CString strSelect;
	if (m_strSearch.IsEmpty ())
	//	SELECT Nummer FROM %1 ORDER BY Nummer	
		AfxFormatString1 (strSelect, IDS_SELECT_NUMMER_WW, strTableName);
	else
	//	SELECT Nummer FROM %1 WHERE %2 ORDER BY Nummer
		AfxFormatString2 (strSelect, IDS_SELECT_NUMBER, strTableName, m_strSearch);

	return strSelect;

	// return strTableName;		// tableset
}
Ejemplo n.º 16
0
bool CRecorder::Open(LPCTSTR Path, const CRecordInfo& Info, const CVideoComprState *ComprState)
{
	static const LPCTSTR COMPR_STATE_FILE_NAME = _T("ComprState.dat");
	if (m_IsRecording)
		return(FALSE);
	m_RecInfo = Info;
	m_FrameCounter = 0;
	BMPTOAVI_PARMS	parms = {
		m_RecInfo.m_OutFrameSize.cx,
		m_RecInfo.m_OutFrameSize.cy,
		m_RecInfo.m_BitCount,
		m_RecInfo.m_OutFrameRate
	};
	bool	GotComprArg = ComprState != NULL;
	CPathStr	StateFolder, StatePath;
	if (GotComprArg)	// if caller specified a compressor state
		m_RecAvi.SetComprState(*ComprState);	// use it
	else {	// read previous compressor state from file
		theApp.GetAppDataFolder(StateFolder);
		StatePath = StateFolder;
		StatePath.Append(COMPR_STATE_FILE_NAME);
		if (PathFileExists(StatePath) && m_ComprState.Read(StatePath))
			m_RecAvi.SetComprState(m_ComprState);	// restore compressor state
	}
	// only show compression dialog if caller didn't pass compressor state
	if (!m_RecAvi.Open(parms, Path, !GotComprArg)) {	// open output AVI file
		if (m_RecAvi.GetLastError()) {	// if user didn't cancel
			CString	msg, Err, DSErr;
			m_RecAvi.GetLastErrorString(Err, DSErr);
			AfxFormatString2(msg, IDS_REC_CANT_CREATE_FILTER, Err, DSErr);
			AfxMessageBox(msg);
		}
		return(FALSE);
	}
	if (!GotComprArg) {
		m_RecAvi.GetComprState(m_ComprState);
		if (!PathFileExists(StatePath))	// test using shlwapi, it's faster
			theApp.CreateFolder(StateFolder);
		m_ComprState.Write(StatePath);	// save compressor state
	}
	return(TRUE);
}
Ejemplo n.º 17
0
AFX_STATIC void AFXAPI _AfxFailMinMaxReal(CDataExchange* pDX,
	 double minVal, double maxVal, int precision, UINT nIDPrompt)
	// error string must have '%1' and '%2' in it
{
	if (!pDX->m_bSaveAndValidate)
	{
		TRACE0("Warning: initial dialog data is out of range.\n");
		return;         // don't stop now
	}
	TCHAR szMin[32], szMax[32];
	CString prompt;

	_stprintf(szMin, _T("%.*g"), precision, minVal);
	_stprintf(szMax, _T("%.*g"), precision, maxVal);
	AfxFormatString2(prompt, nIDPrompt, szMin, szMax);

	AfxMessageBox(prompt, MB_ICONEXCLAMATION, nIDPrompt);
	prompt.Empty(); // exception prep
	pDX->Fail();
}
Ejemplo n.º 18
0
void PASCAL DDV_MinMaxTwips(CDataExchange* pDX, int value, int minVal, int maxVal)
{
	ASSERT(minVal <= maxVal);
	if (value < minVal || value > maxVal)
	{
		// "The measurement must be between %1 and %2."
		if (!pDX->m_bSaveAndValidate)
		{
			TRACE0("Warning: initial dialog data is out of range.\n");
			return;     // don't stop now
		}
		TCHAR szMin[32];
		TCHAR szMax[32];
		theApp.PrintTwips(szMin, minVal, 2);
		theApp.PrintTwips(szMax, maxVal, 2);
		CString prompt;
		AfxFormatString2(prompt, IDS_MEASUREMENT_RANGE, szMin, szMax);
		AfxMessageBox(prompt, MB_ICONEXCLAMATION, AFX_IDS_APP_TITLE);
		prompt.Empty(); // exception prep
		pDX->Fail();
	}
}
Ejemplo n.º 19
0
bool CChordEaseApp::BoostThreads()
{
	// In Vista and later, MIDI input callbacks run at priority 0 instead of 15.
	// Consequently input callbacks no longer preempt normal threads, including
	// the GUI thread, and this can increase the latency of our response to MIDI
	// input, particularly if all CPUs are saturated with normal priority work.
	// We solve this by loading a DLL that catches thread launching, and boosts
	// any threads having priority 0 (normal) to priority 1 (above normal).
	OSVERSIONINFO	osvi;
	osvi.dwOSVersionInfoSize = sizeof(osvi);	// init struct size before call
	if (!GetVersionEx(&osvi))
		return(FALSE);
	if (osvi.dwMajorVersion < 6)	// if before Vista
		return(TRUE);	// no need for thread boost
	LPCTSTR	DLLPath = _T("ThreadBoost.dll");
	if (!m_ThreadBoost.LoadLibrary(DLLPath)) {	// if DLL not loaded
		CString	msg;
		AfxFormatString2(msg, IDS_CKUP_CANT_LOAD_DLL, DLLPath, GetLastErrorString());
		AfxMessageBox(msg);
	}
	return(TRUE);
}
Ejemplo n.º 20
0
AFX_STATIC void AFXAPI _AfxFailMinMaxWithFormat(CDataExchange* pDX,
	 long minVal, long maxVal, LPCTSTR lpszFormat, UINT nIDPrompt)
	// error string must have '%1' and '%2' strings for min and max values
	// wsprintf formatting uses long values (format should be '%ld' or '%lu')
{
	ASSERT(lpszFormat != NULL);

	if (!pDX->m_bSaveAndValidate)
	{
		TRACE0("Warning: initial dialog data is out of range.\n");
		return;     // don't stop now
	}
	TCHAR szMin[32];
	TCHAR szMax[32];
	wsprintf(szMin, lpszFormat, minVal);
	wsprintf(szMax, lpszFormat, maxVal);
	CString prompt;
	AfxFormatString2(prompt, nIDPrompt, szMin, szMax);
	AfxMessageBox(prompt, MB_ICONEXCLAMATION, nIDPrompt);
	prompt.Empty(); // exception prep
	pDX->Fail();
}
Ejemplo n.º 21
0
/*************
 * DESCRIPTION:	Test if value is between ]minVal,maxVal[
 * INPUT:			pDX
 *						value		value to be tested
 *						minVal	minimum value
 *						minVal	maximum value
 * OUTPUT:			-
 *************/
void AFXAPI DDV_MinMaxFloatExclude(CDataExchange* pDX, float const &value, float minVal, float maxVal)
{
	ASSERT(minVal <= maxVal);

	if (value <= minVal || value >= maxVal)
	{
		if (!pDX->m_bSaveAndValidate)
		{
			TRACE0("Warning: initial dialog data is out of range.\n");
			return;         // don't stop now
		}
		TCHAR szMin[32], szMax[32];
		CString prompt;

		_stprintf(szMin, _T("%g"), minVal);
		_stprintf(szMax, _T("%g"), maxVal);
		AfxFormatString2(prompt, IDS_DDV_MINMAXFLOATEXC, szMin, szMax);

		AfxMessageBox(prompt, MB_ICONEXCLAMATION, IDS_DDV_MINMAXFLOATEXC);
		prompt.Empty(); // exception prep
		pDX->Fail();
	}
}
Ejemplo n.º 22
0
AFX_STATIC void AFXAPI _AfxFailMinMaxReal(CDataExchange* pDX,
	 double minVal, double maxVal, int precision, UINT nIDPrompt)
	// error string must have '%1' and '%2' in it
{
	if (!pDX->m_bSaveAndValidate)
	{
		TRACE(traceAppMsg, 0, "Warning: initial dialog data is out of range.\n");
		return;         // don't stop now
	}
	
	const int MINMAX_BUFFER_SIZE = 32;
	TCHAR szMin[MINMAX_BUFFER_SIZE], szMax[MINMAX_BUFFER_SIZE];
	CString prompt;

	ATL_CRT_ERRORCHECK_SPRINTF(_sntprintf_s(szMin, _countof(szMin), _countof(szMin) - 1, _T("%.*g"), precision, minVal));
	ATL_CRT_ERRORCHECK_SPRINTF(_sntprintf_s(szMax, _countof(szMax), _countof(szMax) - 1, _T("%.*g"), precision, maxVal));

	AfxFormatString2(prompt, nIDPrompt, szMin, szMax);

	AfxMessageBox(prompt, MB_ICONEXCLAMATION, nIDPrompt);
	prompt.Empty(); // exception prep
	pDX->Fail();
}
Ejemplo n.º 23
0
void CAbfDoc::SetTitle(LPCTSTR) 
{
	ASSERT_VALID (&m_AbfSet);
#pragma MSG("JG SetCaption for invalid Data")
	if (m_AbfSet.IsValid())
	{
		if (!m_AbfSet.m_Nummer.IsEmpty () && !m_AbfSet.m_Abfallnummer.IsEmpty ())
		{
			CString strCaption;
			AfxFormatString2 (strCaption, IDS_ABF_CAPT_FORMAT, m_AbfSet.m_Nummer, m_AbfSet.m_Abfallnummer);						  
			CDocumentExt :: SetTitle (strCaption);
		}
		else
			CDocumentExt :: SetTitle (m_AbfSet.m_Nummer);
	}
	else
	{
		// kein DS selektiert, also leere Überschrift anzeigen
			if (NULL != g_pErzSet)
				CDocumentExt :: SetTitle (g_pErzSet->m_Nummer);
			else
				CDocumentExt :: SetTitle (_T(""));
	}
}
Ejemplo n.º 24
0
DWORD CCertRemoveSelectDlg::RemoveSelectedCertificate()

/*++

Routine Description:

   Remove the given number of licenses from the selected certificate.

Arguments:

   None.

Return Values:

   ERROR_SUCCESS
   NT status code
   Win error

--*/

{
   BOOL        bDisplayError = TRUE;
   NTSTATUS    nt = STATUS_SUCCESS;
   CLicense *  pLicense;

   UpdateData( TRUE );

   if ( !( pLicense = (CLicense*)::LvGetSelObj( &m_listCertificates ) ) )
   {
      // no certificate selected
      bDisplayError = FALSE;
   }
   else if ( ( m_nLicenses < 1 ) || ( m_nLicenses > pLicense->m_lQuantity ) )
   {
      // invalid number of licenses to remove
      AfxMessageBox( IDS_REMOVE_INVALID_NUM_LICENSES, MB_ICONEXCLAMATION | MB_OK, 0 );
      nt = ERROR_CANCELLED;
      bDisplayError = FALSE;
   }
   else
   {
      CString  strLicenses;
      CString  strConfirm;

      strLicenses.Format( TEXT("%d"), m_nLicenses );
      AfxFormatString2( strConfirm, IDS_REMOVE_CERTIFICATE_CONFIRM, strLicenses, pLicense->m_strProduct );

      int nResponse = AfxMessageBox( strConfirm, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2 );

      if ( IDYES != nResponse )
      {
         nt = ERROR_CANCELLED;
         bDisplayError = FALSE;
      }
      else
      {
         // delete certificate
         LPSTR  pszAscServerName  = (LPSTR) LocalAlloc( LMEM_FIXED, 1 + m_strServerName.GetLength()        );
         LPSTR  pszAscProductName = (LPSTR) LocalAlloc( LMEM_FIXED, 1 + pLicense->m_strProduct.GetLength() );
         LPSTR  pszAscVendor      = (LPSTR) LocalAlloc( LMEM_FIXED, 1 + m_strVendor.GetLength()            );

         if ( ( NULL == pszAscServerName ) || ( NULL == pszAscProductName ) || ( NULL == pszAscVendor ) )
         {
            nt = ERROR_NOT_ENOUGH_MEMORY;
         }
         else
         {
            wsprintfA( pszAscServerName,  "%ls", (LPCWSTR) m_strServerName        );
            wsprintfA( pszAscProductName, "%ls", (LPCWSTR) pLicense->m_strProduct );
            wsprintfA( pszAscVendor,      "%ls", (LPCWSTR) m_strVendor            );

            LLS_LICENSE_INFO_1   lic;

            nt = pLicense->CreateLicenseInfo( &lic );

            if ( STATUS_SUCCESS == nt )
            {
               // only remove as many licenses as requested
               lic.Quantity = m_nLicenses;

               if ( !pLicense->m_strSource.CompareNoCase( TEXT( "None" ) ) )
               {
                  nt = NoCertificateRemove( m_hWnd, pszAscServerName, m_dwRemoveFlags, 1, &lic );
                  bDisplayError = FALSE;
               }
               else
               {
                  // get certificate source DLL path
                  CString  strKeyName =   TEXT( "Software\\LSAPI\\Microsoft\\CertificateSources\\" )
                                        + pLicense->m_strSource;
                  HKEY     hKeySource;

                  nt = RegOpenKeyEx( HKEY_LOCAL_MACHINE, strKeyName, 0, KEY_READ, &hKeySource );
   
                  if ( ( ERROR_PATH_NOT_FOUND == nt ) || ( ERROR_FILE_NOT_FOUND == nt ) )
                  {
                     AfxMessageBox( IDS_CERT_SOURCE_NOT_AVAILABLE, MB_ICONSTOP | MB_OK, 0 );
                     nt = ERROR_CANCELLED;
                     bDisplayError = FALSE;
                  }
                  else if ( ERROR_SUCCESS == nt )
                  {
                     TCHAR    szImagePath[ 1 + _MAX_PATH ];
                     DWORD    cbImagePath = sizeof( szImagePath );
                     DWORD    dwType;
      
                     nt = RegQueryValueEx( hKeySource, TEXT( "ImagePath" ), NULL, &dwType, (LPBYTE) szImagePath, &cbImagePath );

                     if ( ERROR_SUCCESS == nt )
                     {
                        TCHAR    szExpandedImagePath[ 1 + _MAX_PATH ];
   
                        BOOL ok = ExpandEnvironmentStrings( szImagePath, szExpandedImagePath, sizeof( szExpandedImagePath ) / sizeof( *szExpandedImagePath ) );

                        if ( !ok )
                        {
                           nt = GetLastError();
                        }
                        else
                        {
                           // load certificate source DLL
                           HINSTANCE hDll = ::LoadLibrary( szExpandedImagePath );
   
                           if ( NULL == hDll )
                           {
                              nt = GetLastError();
                           }
                           else
                           {
                              // get certificate remove function
                              CHAR              szExportName[ 256 ];
                              PCCF_REMOVE_API   pRemoveFn;
   
                              wsprintfA( szExportName, "%lsCertificateRemove", (LPCWSTR) pLicense->m_strSource );
                              pRemoveFn = (PCCF_REMOVE_API) GetProcAddress( hDll, szExportName );
   
                              if ( NULL == pRemoveFn )
                              {
                                 nt = GetLastError();
                              }
                              else
                              {
                                 // remove certificate
                                 nt = (*pRemoveFn)( m_hWnd, pszAscServerName, m_dwRemoveFlags, 1, &lic );
                                 bDisplayError = FALSE;
                              }
   
                              ::FreeLibrary( hDll );
                           }
                        }
                     }        
               
                     RegCloseKey( hKeySource );
                  }
               }

               pLicense->DestroyLicenseInfo( &lic );
            }
         }

         if ( NULL != pszAscServerName  )    LocalFree( pszAscServerName  );
         if ( NULL != pszAscProductName )    LocalFree( pszAscProductName );
         if ( NULL != pszAscVendor      )    LocalFree( pszAscVendor      );

         RefreshLicenses();
         RefreshCertificateList();
         UpdateSpinControlRange();
      }
   }

   if ( bDisplayError && ( ERROR_SUCCESS != nt ) )
   {
      theApp.SetLastError( nt );
      theApp.DisplayLastError();
   }

   return nt;
}
Ejemplo n.º 25
0
bool MakeHelp_GetRelativePath (const AProject *Project, const char *NewPath, char *Dest)
{
	char ProjectDir[MAX_PATH];
	char NewFileDir[MAX_PATH];

	*ProjectDir = '\0';
	*NewFileDir = '\0';

	if (AProject_GetForceRelativePaths (Project))
	{
		// see if NewPath is a subdir of the project path...

		// Get project path, which just happens to be the current directory...
		GetCurrentDirectory (MAX_PATH, ProjectDir);
		if (FilePath_GetDriveAndDir (NewPath, NewFileDir) != GE_FALSE)
		{
			// There's a path on the filename.
			// If there's no drive or leading slash, then it must be relative
			char PathWork[MAX_PATH];

			if (FilePath_GetDrive (NewPath, PathWork) == GE_FALSE)
			{
				// no drive, must be a dir
				FilePath_GetDir (NewPath, PathWork);
				if (*PathWork != '\\')
				{
					// no leading slash, so it's relative.
					strcpy (Dest, NewPath);
					return true;
				}
			}
			// NewPath's directory has to contain ProjectDir at the beginning of it
			if (_strnicmp (ProjectDir, NewFileDir, strlen (ProjectDir)) == 0)
			{
				// it's probably good
				// copy the remaining part to the destination
				strcpy (Dest, &NewPath[strlen (ProjectDir)]);
				if (*Dest == '\\')
				{
					// don't want a leading slash, if ya know what I mean...
					strcpy (Dest, Dest+1);
				}
				return true;
			}
		}
		else
		{
			// no path information on new filename, so it's relative by default
			strcpy (Dest, NewPath);
			return true;
		}
	}
	else
	{
		// no relative path required, so copy the whole thing.
		strcpy (Dest, NewPath);
		return true;
	}

	// The string is not relative, and it's supposed to be.
	// Display an error and return false.
	CString ErrMsg;

	AfxFormatString2 (ErrMsg, IDS_RELATIVEPATH, NewPath, ProjectDir);
	AfxMessageBox (ErrMsg, MB_ICONEXCLAMATION | MB_OK);

	return false;
}
Ejemplo n.º 26
0
BOOL COSMCtrlMapOperationsDlg::ForceMapnikRerenderHelper()
{
  //Validate our parameters
  AFXASSUME(m_pOSMCtrl != NULL);

  //Next get the server to connect to
  COSMCtrlMapnikTileProvider MapnikTileProvider;
  CStringW sServer(MapnikTileProvider.GetDownloadServer());

  //Accumulate how many tiles we have request to rerender and which ones indicated a failure to rerender
  int nTilesRerendered = 0;
  int nTilesNotRerendered = 0;

  //Next create the WinHTTP session object
  CWinHTTPSession session;
  HRESULT hr = m_pOSMCtrl->CreateSession(session, 0);
  if (SUCCEEDED(hr))
  {
    //Now create the connection object from the session object
    CWinHTTPConnection connection;
    hr = connection.Initialize(session, sServer, MapnikTileProvider.GetDownloadPort());
    if (SUCCEEDED(hr))
    {
      //Iterate across the array of tiles to download
      BOOL bSuccess = TRUE;
      for (std::vector<COSMCtrlMapOperationsDlgTile>::size_type i=0; i<m_Tiles.size() && bSuccess; i++)
      {
        //Pull out the next tile to download
        const COSMCtrlMapOperationsDlgTile& tile = m_Tiles[i];

        //Now issue the request to rerender
        COSMCtrlMapOperationsDlgEvent dlgEvent;
        dlgEvent.m_bSuccess = false;
        LPCWSTR pwszAcceptTypes[2];
        pwszAcceptTypes[0] = L"*/*";
        pwszAcceptTypes[1] = NULL;
        CSyncWinHTTPDownloader winHttpRequest;
        //winHttpRequest.m_sFileToDownloadInto = sFile;
        CString sObject(MapnikTileProvider.GetDownloadObject(tile.m_nZoom, tile.m_nTileX, tile.m_nTileY) + _T("/dirty"));
        hr = winHttpRequest.Initialize(connection, CStringW(sObject), NULL, NULL, NULL, pwszAcceptTypes, WINHTTP_FLAG_REFRESH);
        if (FAILED(hr))
        {
          //report the error
          TRACE(_T("COSMCtrlMapOperationsDlg::ForceMapnikRerenderHelper, Failed to create request for object \"%s\", Error:%08X\n"), sObject.operator LPCTSTR(), hr);
            
          //Update the stats
          ++nTilesNotRerendered;
        }
        else
        {
          hr = winHttpRequest.SendRequestSync();
          if (FAILED(hr))
          {
            //report the error
            TRACE(_T("COSMCtrlMapOperationsDlg::ForceMapnikRerenderHelper, Failed to send request for object \"%s\", Error:%08X\n"), sObject.operator LPCTSTR(), hr);
            
            //Update the stats
            ++nTilesNotRerendered;
          }
          else
          {
            CStringA sResponse;
            sResponse.Append(reinterpret_cast<LPCSTR>(winHttpRequest.m_Response.GetData()), static_cast<int>(winHttpRequest.m_Response.GetSize()));
            if (sResponse.Find("Tile submitted for rendering") != -1)
            {
              //Update the stats
              ++nTilesRerendered;
              dlgEvent.m_bSuccess = true;
            }
            else
            {
              //Update the stats
              ++nTilesNotRerendered;
            }  
          }
        }

        //Update the UI          
        dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
        dlgEvent.m_sString = sObject;
        dlgEvent.m_nItemData = i + 1;
        AddEvent(dlgEvent);

        //Check if we have been cancelled before we loop around
        bSuccess = (WaitForSingleObject(m_WorkerTerminateEvent, 0) == WAIT_TIMEOUT);
      }
    }
  }

  //Finally add a event about how many items have been downloaded
  COSMCtrlMapOperationsDlgEvent dlgEvent;
  dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
  CString sTilesRerendered;
  sTilesRerendered.Format(_T("%d"), nTilesRerendered);
  CString sTilesNotRerendered;
  sTilesNotRerendered.Format(_T("%d"), nTilesNotRerendered);
  AfxFormatString2(dlgEvent.m_sString, IDS_OSMCTRL_RERENDER_TILES_STATS, sTilesRerendered, sTilesNotRerendered);
  AddEvent(dlgEvent);

  return TRUE;
}
Ejemplo n.º 27
0
BOOL COSMCtrlMapOperationsDlg::DownloadTiles(BOOL bSkipIfTileAlreadyExists)
{
  //Validate our parameters
  AFXASSUME(m_pOSMCtrl != NULL);

  //Pull out the tile provider we will be using
  IOSMCtrlTileProvider* pTileProvider = m_pOSMCtrl->GetTileProvider();
  AFXASSUME(pTileProvider != NULL);

  //Next get the server to connect to
  CStringW sServer(pTileProvider->GetDownloadServer());

  //Accumulate how many tiles we have deleted and not deleted
  int nTilesDownloaded = 0;
  int nTilesNotDownloaded = 0;

  //Next create the WinHTTP session object
  CWinHTTPSession session;
  HRESULT hr = m_pOSMCtrl->CreateSession(session, 0);
  if (SUCCEEDED(hr))
  {
    //Now create the connection object from the session object
    CWinHTTPConnection connection;
    hr = connection.Initialize(session, sServer, pTileProvider->GetDownloadPort());
    if (SUCCEEDED(hr))
    {
      //Iterate across the array of tiles to download
      BOOL bSuccess = TRUE;
      for (std::vector<COSMCtrlMapOperationsDlgTile>::size_type i=0; i<m_Tiles.size() && bSuccess; i++)
      {
        //Pull out the next tile to download
        const COSMCtrlMapOperationsDlgTile& tile = m_Tiles[i];

        //Create the sub directories if we can
        CString sCacheDirectory(m_pOSMCtrl->GetCacheDirectory());
        CString sSubDirectory;
        sSubDirectory.Format(_T("%s\\%d"), sCacheDirectory.operator LPCTSTR(), tile.m_nZoom);
        CreateDirectory(sSubDirectory, NULL);
        sSubDirectory.Format(_T("%s\\%d\\%d"), sCacheDirectory.operator LPCTSTR(), tile.m_nZoom, tile.m_nTileX);
        CreateDirectory(sSubDirectory, NULL);

        //Form the path to the tile we will be downloading to and determine if we should do the download
        CString sFile(COSMCtrl::GetTileCachePath(sCacheDirectory, tile.m_nZoom, tile.m_nTileX, tile.m_nTileY, FALSE));
        BOOL bDownload = TRUE;
        if (bSkipIfTileAlreadyExists)
          bDownload = (GetFileAttributes(sFile) == INVALID_FILE_ATTRIBUTES);

        //Now download the specific tile to the cache if required
        COSMCtrlMapOperationsDlgEvent dlgEvent;
        dlgEvent.m_bSuccess = false;
        if (bDownload)
        {
          //We will accept any mime type
          LPCWSTR pwszAcceptTypes[2];
          pwszAcceptTypes[0] = L"*/*";
          pwszAcceptTypes[1] = NULL;
          CSyncWinHTTPDownloader winHttpRequest;
          winHttpRequest.m_sFileToDownloadInto = sFile;
          CString sObject(pTileProvider->GetDownloadObject(tile.m_nZoom, tile.m_nTileX, tile.m_nTileY));
          hr = winHttpRequest.Initialize(connection, CStringW(sObject), NULL, NULL, NULL, pwszAcceptTypes, WINHTTP_FLAG_REFRESH);
          if (FAILED(hr))
          {
            //report the error
            TRACE(_T("COSMCtrlMapOperationsDlg::DownloadTiles, Failed to create request for tile \"%s\", Error:%08X\n"), sFile.operator LPCTSTR(), hr);
            
            //Ensure any remants of a bad download file are nuked
            DeleteFile(sFile);
            
            //Update the stats
            ++nTilesNotDownloaded;
          }
          else
          {
            hr = winHttpRequest.SendRequestSync();
            if (FAILED(hr))
            {
              //report the error
              TRACE(_T("COSMCtrlMapOperationsDlg::DownloadTiles, Failed to send request for tile \"%s\", Error:%08X\n"), sFile.operator LPCTSTR(), hr);
            
              //Ensure any remants of a bad download file are nuked
              DeleteFile(sFile);
            
              //Update the stats
              ++nTilesNotDownloaded;
            }
            else
            {
              //Update the stats
              ++nTilesDownloaded;
              dlgEvent.m_bSuccess = true;
            }
          }
        }
        else
        {
          //Update the stats
          ++nTilesNotDownloaded;
        }

        //Update the UI          
        dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
        dlgEvent.m_sString = sFile;
        dlgEvent.m_nItemData = i + 1;
        AddEvent(dlgEvent);

        //Check if we have been cancelled before we loop around
        bSuccess = (WaitForSingleObject(m_WorkerTerminateEvent, 0) == WAIT_TIMEOUT);
      }
    }
  }

  //Finally add a event about how many items have been downloaded
  COSMCtrlMapOperationsDlgEvent dlgEvent;
  dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
  CString sTilesDownloaded;
  sTilesDownloaded.Format(_T("%d"), nTilesDownloaded);
  CString sTilesNotDownloaded;
  sTilesNotDownloaded.Format(_T("%d"), nTilesNotDownloaded);
  AfxFormatString2(dlgEvent.m_sString, IDS_OSMCTRL_DOWNLOAD_TILES_STATS, sTilesDownloaded, sTilesNotDownloaded);
  AddEvent(dlgEvent);

  return TRUE;
}
Ejemplo n.º 28
0
BOOL COSMCtrlMapOperationsDlg::DownloadTiles(BOOL bSkipIfTileAlreadyExists)
{
  //Validate our parameters
  AFXASSUME(m_pOSMCtrl);

  //What will be the return value from this function (assume the best)
  BOOL bSuccess = TRUE;

  CSingleLock sl(&m_pOSMCtrl->m_csData, TRUE);
  IOSMCtrlTileProvider* pTileProvider = m_pOSMCtrl->GetTileProvider();
  CString sCacheDirectory(m_pOSMCtrl->m_sCacheDirectory);
  ASSERT(sCacheDirectory.GetLength());
  BOOL bUseIfModifiedSinceHeader(m_pOSMCtrl->m_bUseIfModifiedSinceHeader);
  sl.Unlock();

  //Next get the server to connect to
  CString sServer(pTileProvider->GetDownloadServer());

  //Accumulate how many tiles we have deleted and not deleted
  int nTilesDownloaded = 0;
  int nTilesNotDownloaded = 0;

  //Next create the Wininet session object
  ASSERT(m_hSession == NULL);
  HRESULT hr = m_pOSMCtrl->CreateSession(m_hSession);
  if (SUCCEEDED(hr))
  {
    //Now create the connection object from the session object
    HINTERNET hConnection = NULL;
    hr = m_pOSMCtrl->CreateConnection(m_hSession, sServer, 80, hConnection);
    if (SUCCEEDED(hr))
    {
      //Iterate across the array of tiles to download
      for (INT_PTR i=0; i<m_Tiles.GetSize() && bSuccess; i++)
      {
        //Pull out the next tile to download
        const COSMCtrlMapOperationsDlgTile& tile = m_Tiles.ElementAt(i);

        //Create the sub directories if we can
        CString sSubDirectory;
        sSubDirectory.Format(_T("%s\\%d"), sCacheDirectory.operator LPCTSTR(), tile.m_nZoom);
        CreateDirectory(sSubDirectory, NULL);
        sSubDirectory.Format(_T("%s\\%d\\%d"), sCacheDirectory.operator LPCTSTR(), tile.m_nZoom, tile.m_nTileX);
        CreateDirectory(sSubDirectory, NULL);

        //Form the name of the tile we will be downloading
        CString sObject(pTileProvider->GetDownloadObject(tile.m_nZoom, tile.m_nTileX, tile.m_nTileY));

        //Form the path to the tile we will be downloading to  and determine if we should do the download
        CString sFile(COSMCtrl::GetTileCachePath(sCacheDirectory, tile.m_nZoom, tile.m_nTileX, tile.m_nTileY, FALSE));
        BOOL bDownload = TRUE;
        if (bSkipIfTileAlreadyExists)
          bDownload = (GetFileAttributes(sFile) == INVALID_FILE_ATTRIBUTES);

        //Now download the specific tile to the cache if required
        COSMCtrlMapOperationsDlgEvent dlgEvent;
        dlgEvent.m_bSuccess = false;
        if (bDownload)
        {
          hr = m_pOSMCtrl->DownloadTile(hConnection, sObject, bUseIfModifiedSinceHeader, !bSkipIfTileAlreadyExists, tile.m_nZoom, tile.m_nTileX, tile.m_nTileY, sFile);
          if (FAILED(hr))
          {
            //report the error
            TRACE(_T("COSMCtrlMapOperationsDlg::DownloadTiles, Failed to download tile \"%s\", Error:%08X\n"), sFile.operator LPCTSTR(), hr);
            
            //Ensure any remants of a bad download file are nuked
            DeleteFile(sFile);
            
            //Update the stats
            ++nTilesNotDownloaded;
          }
          else
          {
            //Update the stats
            ++nTilesDownloaded;
            dlgEvent.m_bSuccess = true;
          }
        }
        else
        {
          //Update the stats
          ++nTilesNotDownloaded;
        }

        //Update the UI          
        dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
        dlgEvent.m_sString = sFile;
        dlgEvent.m_nItemData = i + 1;
        AddEvent(dlgEvent);

        //Check if we have been cancelled before we loop around
        bSuccess = (WaitForSingleObject(m_WorkerTerminateEvent, 0) == WAIT_TIMEOUT);
      }
      
      //Close the wininet connection
    #ifdef COSMCTRL_NOWINHTTP
      InternetCloseHandle(hConnection);
    #else
      WinHttpCloseHandle(hConnection);
    #endif
    }

    //Clean up the wininet session before we exit
  #ifdef COSMCTRL_NOWINHTTP
    InternetCloseHandle(m_hSession);
  #else
    WinHttpCloseHandle(m_hSession);
  #endif
    m_hSession = NULL;
  }

  //Finally add a event about how many items have been downloaded
  COSMCtrlMapOperationsDlgEvent dlgEvent;
  dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
  CString sTilesDownloaded;
  sTilesDownloaded.Format(_T("%d"), nTilesDownloaded);
  CString sTilesNotDownloaded;
  sTilesNotDownloaded.Format(_T("%d"), nTilesNotDownloaded);
  AfxFormatString2(dlgEvent.m_sString, IDS_OSMCTRL_DOWNLOAD_TILES_STATS, sTilesDownloaded, sTilesNotDownloaded);
  AddEvent(dlgEvent);

  return TRUE;
}
Ejemplo n.º 29
0
void COSMCtrlMapOperationsDlg::UpdateZoom(int nZoomLevel)
{
  //Validate our parameters
  AFXASSUME(m_pOSMCtrl != NULL);
  
  //Display a wait cursor while we do the maths to work out how many tiles we will be working on
  CWaitCursor waitCursor;

  //Reset the tiles array
  m_Tiles.reserve(100000);
  
  //Work out how many tiles this operation will affect
  COSMCtrlPosition topLeft;
  COSMCtrlPosition bottomRight;
  int nZoom = static_cast<int>(m_pOSMCtrl->GetZoom());
  if (m_pOSMCtrl->m_SelectionPolygon.GetBoundingRect(topLeft, bottomRight))
  {
    //Iterate across all the zoom levels we will be operating on
    for (int i=nZoom; i<=nZoomLevel; i++)
    { 
      //Work our the start and end X and Y values for the tiles at this zoom level 
      double fStartX = COSMCtrlHelper::Longitude2TileX(topLeft.m_fLongitude, i);
      int nStartX = static_cast<int>(fStartX);
      double fStartY = COSMCtrlHelper::Latitude2TileY(topLeft.m_fLatitude, i);
      int nStartY = static_cast<int>(fStartY);

      double fEndX = COSMCtrlHelper::Longitude2TileX(bottomRight.m_fLongitude, i);
      int nEndX = static_cast<int>(fEndX);
      double fEndY = COSMCtrlHelper::Latitude2TileY(bottomRight.m_fLatitude, i);
      int nEndY = static_cast<int>(fEndY);
    
      //Add all the tiles for this zoom level to the array
      for (int j=nStartX; j<=nEndX; j++)
      {
        for (int k=nStartY; k<=nEndY; k++)
        {
          COSMCtrlMapOperationsDlgTile tile;
          tile.m_nTileX = j;
          tile.m_nTileY = k;
          tile.m_nZoom = i;
          m_Tiles.push_back(tile);
        }
      }
    }
  }
  
  //Free up any unused memory in the array
  m_Tiles.shrink_to_fit();

  //Set the range on the progress control  
  int nTiles = static_cast<int>(m_Tiles.size());
  m_ctrlProgress.SetPos(0);
  m_ctrlProgress.SetRange32(0, nTiles);

  //Finally update the text on the UI
  CString sStatus;
  CString sZoom1;
  sZoom1.Format(_T("%d"), nZoom);
  CString sTiles;
  sTiles.Format(_T("%d"), nTiles);
  if (nZoom == nZoomLevel)
    AfxFormatString2(sStatus, IDS_OSMCTRL_MAP_OPERATIONS_UPDATE_ZOOM2, sZoom1, sTiles);
  else
  {
    CString sZoom2;
    sZoom2.Format(_T("%d"), nZoomLevel);
    
    LPCTSTR szStrings[3];
    szStrings[0] = sZoom1;
    szStrings[1] = sZoom2;
    szStrings[2] = sTiles;
    AfxFormatStrings(sStatus, IDS_OSMCTRL_MAP_OPERATIONS_UPDATE_ZOOM3, szStrings, 3);
  }
  m_ctrlStatusText.SetWindowText(sStatus);
}
Ejemplo n.º 30
0
BOOL COSMCtrlMapOperationsDlg::ForceMapnikRerenderHelper()
{
  //Validate our parameters
  AFXASSUME(m_pOSMCtrl);

  //What will be the return value from this function (assume the best)
  BOOL bSuccess = TRUE;

  //Next get the server to connect to
  COSMCtrlMapnikTileProvider MapnikTileProvider;
  CString sServer(MapnikTileProvider.GetDownloadServer());

  //Accumulate how many tiles we have request to rerender and which ones indicated a failure to rerender
  int nTilesRerendered = 0;
  int nTilesNotRerendered = 0;

  //Next create the Wininet session object
  ASSERT(m_hSession == NULL);
  HRESULT hr = m_pOSMCtrl->CreateSession(m_hSession);
  if (SUCCEEDED(hr))
  {
    //Now create the connection object from the session object
    HINTERNET hConnection = NULL;
    hr = m_pOSMCtrl->CreateConnection(m_hSession, sServer, 80, hConnection);
    if (SUCCEEDED(hr))
    {
      //Iterate across the array of tiles to rerender
      for (INT_PTR i=0; i<m_Tiles.GetSize() && bSuccess; i++)
      {
        //Pull out the next tile to download
        const COSMCtrlMapOperationsDlgTile& tile = m_Tiles.ElementAt(i);

        //Form the name of the tile we will be rerendering
        CString sObject(MapnikTileProvider.GetDownloadObject(tile.m_nZoom, tile.m_nTileX, tile.m_nTileY) + _T("/dirty"));

        //Now issue the request to rerender
        COSMCtrlMapOperationsDlgEvent dlgEvent;
        dlgEvent.m_bSuccess = false;
        CStringA sResponse;
        hr = m_pOSMCtrl->DownloadPage(hConnection, sObject, TRUE, sResponse);
        if (FAILED(hr))
        {
          //report the error
          TRACE(_T("COSMCtrlMapOperationsDlg::ForceMapnikRerenderHelper, Failed to download page \"%s\", Error:%08X\n"), sObject.operator LPCTSTR(), hr);
          
          //Update the stats
          ++nTilesNotRerendered;
        }
        else
        {
          //Screen scrape the response to see if it worked
          if (sResponse.Find("Tile submitted for rendering") != -1)
          {
            //Update the stats
            ++nTilesRerendered;
            dlgEvent.m_bSuccess = true;
          }
          else
          {
            //Update the stats
            ++nTilesNotRerendered;
          }  
        }

        //Update the UI          
        dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
        dlgEvent.m_sString = sObject;
        dlgEvent.m_nItemData = i + 1;
        AddEvent(dlgEvent);

        //Check if we have been cancelled before we loop around
        bSuccess = (WaitForSingleObject(m_WorkerTerminateEvent, 0) == WAIT_TIMEOUT);
      }
      
      //Close the wininet connection
    #ifdef COSMCTRL_NOWINHTTP
      InternetCloseHandle(hConnection);
    #else
      WinHttpCloseHandle(hConnection);
    #endif
    }

    //Clean up the wininet session before we exit
  #ifdef COSMCTRL_NOWINHTTP
    InternetCloseHandle(m_hSession);
  #else
    WinHttpCloseHandle(m_hSession);
  #endif
    m_hSession = NULL;
  }

  //Finally add a event about how many items have been downloaded
  COSMCtrlMapOperationsDlgEvent dlgEvent;
  dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
  CString sTilesRerendered;
  sTilesRerendered.Format(_T("%d"), nTilesRerendered);
  CString sTilesNotRerendered;
  sTilesNotRerendered.Format(_T("%d"), nTilesNotRerendered);
  AfxFormatString2(dlgEvent.m_sString, IDS_OSMCTRL_RERENDER_TILES_STATS, sTilesRerendered, sTilesNotRerendered);
  AddEvent(dlgEvent);

  return TRUE;
}