Example #1
0
/**
 * Passed a value and two resource string ids
 * if count is 1 then FormatString is called with format_1 and the value
 * otherwise format_2 is used
 * the formatted string is returned
*/
CString CLoglistUtils::ExpandRelativeTime(int count, UINT format_1, UINT format_n)
{
	CString answer;
	if (count == 1)
		answer.FormatMessage(format_1, count);
	else
		answer.FormatMessage(format_n, count);

	return answer;
}
Example #2
0
void CDirstatApp::RestartApplication()
{
	// First, try to create the suspended process
	STARTUPINFO si;
	ZeroMemory(&si, sizeof(si));
	si.cb= sizeof(si);

	PROCESS_INFORMATION pi;
	ZeroMemory(&pi, sizeof(pi));

	BOOL success = CreateProcess(GetAppFileName(), NULL, NULL, NULL, false, CREATE_SUSPENDED, NULL, NULL, &si, &pi);
	if (!success)
	{
		CString s;
		s.FormatMessage(IDS_CREATEPROCESSsFAILEDs, GetAppFileName(), MdGetWinerrorText(GetLastError()));
		AfxMessageBox(s);
		return;
	}

	// We _send_ the WM_CLOSE here to ensure that all CPersistence-Settings
	// like column widths an so on are saved before the new instance is resumed.
	// This will post a WM_QUIT message.
	GetMainFrame()->SendMessage(WM_CLOSE);

	DWORD dw= ::ResumeThread(pi.hThread);
	if (dw != 1)
		TRACE(_T("ResumeThread() didn't return 1\r\n"));

	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);
}
Example #3
0
void CSetBugTraqAdv::OnBnClickedOptions()
{
    m_provider_clsid = GUID_NULL;

    int index = m_cProviderCombo.GetCurSel();
    if (index != CB_ERR)
    {
        CBugTraqProvider *provider = (CBugTraqProvider *)m_cProviderCombo.GetItemDataPtr(index);
        m_provider_clsid = provider->clsid;
    }

    CComPtr<IBugTraqProvider2> pProvider;
    HRESULT hr = pProvider.CoCreateInstance(m_provider_clsid);

    if (SUCCEEDED(hr))
    {
        ATL::CComBSTR temp;
        CString p;
        GetDlgItemText(IDC_BUGTRAQPARAMETERS, p);
        ATL::CComBSTR params;
        params.Attach(p.AllocSysString());
        hr = pProvider->ShowOptionsDialog(GetSafeHwnd(), params, &temp);
        if (SUCCEEDED(hr))
        {
            SetDlgItemText(IDC_BUGTRAQPARAMETERS, temp == 0 ? "" : temp);
        }
        else
        {
            COMError ce(hr);
            CString sErr;
            sErr.FormatMessage(IDS_ERR_FAILEDISSUETRACKERCOM, ce.GetSource().c_str(), ce.GetMessageAndDescription().c_str());
            ::MessageBox(m_hWnd, sErr, L"TortoiseSVN", MB_ICONERROR);
        }
    }
}
Example #4
0
void CRepositoryBrowser::UpdateInfoLabel()
{
	CString temp;
	POSITION pos = m_RepoList.GetFirstSelectedItemPosition();
	if (pos)
	{
		if (m_RepoList.GetSelectedCount() > 1)
		{
			temp.FormatMessage(IDS_REPOBROWSE_INFOMULTI, m_RepoList.GetSelectedCount());
		}
		else
		{
			int index = m_RepoList.GetNextSelectedItem(pos);
			CShadowFilesTree *item = (CShadowFilesTree *)m_RepoList.GetItemData(index);
			if (item->m_bSubmodule)
				temp.FormatMessage(IDS_REPOBROWSE_INFOEXT, (LPCTSTR)m_RepoList.GetItemText(index, eCol_Name), item->m_hash.ToString());
			else if (item->m_bFolder)
				temp.FormatMessage(IDS_REPOBROWSE_INFODIR, (LPCTSTR)m_RepoList.GetItemText(index, eCol_Name));
			else
				temp.FormatMessage(IDS_REPOBROWSE_INFOFILE, (LPCTSTR)m_RepoList.GetItemText(index, eCol_Name), (LPCTSTR)m_RepoList.GetItemText(index, eCol_FileSize));
		}
	}
	else
	{
		HTREEITEM hTreeItem = m_RepoTree.GetSelectedItem();
		if (hTreeItem != nullptr)
		{
			CShadowFilesTree* pTree = (CShadowFilesTree*)m_RepoTree.GetItemData(hTreeItem);
			if (pTree != nullptr)
			{
				size_t files = 0, submodules = 0;
				for (TShadowFilesTreeMap::iterator itShadowTree = pTree->m_ShadowTree.begin(); itShadowTree != pTree->m_ShadowTree.end(); ++itShadowTree)
				{
					if (!(*itShadowTree).second.m_bFolder && !(*itShadowTree).second.m_bSubmodule)
						++files;
					if ((*itShadowTree).second.m_bSubmodule)
						++submodules;
				}
				temp.FormatMessage(IDS_REPOBROWSE_INFO, (LPCTSTR)pTree->m_sName, files, submodules, pTree->m_ShadowTree.size() - files - submodules, pTree->m_ShadowTree.size());
			}
		}
	}
	SetDlgItemText(IDC_INFOLABEL, temp);
}
Example #5
0
void CDirstatApp::DoContextHelp(DWORD topic)
{
	if (FileExists(m_pszHelpFilePath))
	{
		// I want a NULL parent window. So I don't use CWinApp::HtmlHelp().
		::HtmlHelp(NULL, m_pszHelpFilePath, HH_HELP_CONTEXT, topic);
	}
	else
	{
		CString msg;
		msg.FormatMessage(IDS_HELPFILEsCOULDNOTBEFOUND, _T("windirstat.chm"));
		AfxMessageBox(msg);
	}
}
Example #6
0
CString CDirstatApp::GetCurrentProcessMemoryInfo()
{
	UpdateMemoryInfo();

	if (m_workingSet == 0)
		return _T("");

	CString n= PadWidthBlanks(FormatBytes(m_workingSet), 11);

	CString s;
	s.FormatMessage(IDS_RAMUSAGEs, n);

	return s;
}
Example #7
0
void
CImportDlg::_SetDescription(const NifEntry& entry)
{
	CString strDescription;
	strDescription.FormatMessage(
		IDS_NIF_DESCRIPTION_FMT,
		entry.DeviceId.Mid(0,5),
		entry.DeviceId.Mid(5,5),
		entry.DeviceId.Mid(10,5),
		entry.DeviceId.Mid(15,5),
		entry.WriteKey.IsEmpty() ? 
		static_cast<LPCTSTR>(CString(MAKEINTRESOURCE(IDS_WRITE_KEY_NONE))) :
		static_cast<LPCTSTR>(CString(MAKEINTRESOURCE(IDS_WRITE_KEY_PRESENT))),
		entry.Description);
	m_wndDescription.SetWindowText(strDescription);
}
Example #8
0
CString&
pNdasLogicalDiskEncryptString(
	CString& str,
	const NDASUSER_LOGICALDEVICE_INFORMATION* pLogDeviceInfo)
{
	ATLASSERT(NULL != pLogDeviceInfo);
	if (NULL == pLogDeviceInfo)
	{
		str = "";
		return str;
	}
	CString strEncryptType;
	switch (pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Type)
	{
	case NDAS_CONTENT_ENCRYPT_TYPE_NONE:
		strEncryptType.LoadString(IDS_LOGDEVICE_ENCRYPTION_NONE);
		break;
	case NDAS_CONTENT_ENCRYPT_TYPE_SIMPLE:
		strEncryptType.LoadString(IDS_LOGDEVICE_ENCRYPTION_SIMPLE);
		break;
	case NDAS_CONTENT_ENCRYPT_TYPE_AES:
		strEncryptType.LoadString(IDS_LOGDEVICE_ENCRYPTION_AES);
		break;
	default:
		// Unknown Type (%1!04X!)
		strEncryptType.FormatMessage(
			IDS_LOGDEVICE_ENCRYPTION_UNKNOWN_FMT, 
			pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Type);
		break;
	}
	// Encrypted Disk with %1!s! (%2!d! bits) R%3!X!.%4!X!
	str.FormatMessage(
		IDS_LOGDEVICE_ENCRYPTION_FMT,
		strEncryptType,
		pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.KeyLength * 8, // bits
		HIWORD(pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Revision),
		LOWORD(pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Revision));
	return str;
}
Example #9
0
static void BackupFile(LPCTSTR lpszPathName)
{
	size_t len = _tcslen(lpszPathName);
	if (len > 4 && _tcsicmp(lpszPathName + len-4, _T(".gde")) == 0)
	{
		CString newFile(lpszPathName);
		// delete the last 3 chars (gde) and append "bak"
		newFile.Delete((int)len-3, 3);
		newFile += EXTN_BAK;

		// (re)set the attributes of the backup file
		SetFileAttributes(newFile, FILE_ATTRIBUTE_NORMAL);
		// copy .gde -> .bak
		if (CopyFile(lpszPathName, newFile, FALSE) == FALSE)
		{
			DWORD err = GetLastError();
			CString msg;
			msg.FormatMessage(IDS_NOBACKUP, getMessage(err));
			AfxMessageBox(msg, MB_OK|MB_ICONWARNING);
		}
	}
}
Example #10
0
void CBrowseRefsDlg::UpdateInfoLabel()
{
	CString temp;
	temp.FormatMessage(IDS_REFBROWSE_INFO, m_ListRefLeafs.GetItemCount(), m_ListRefLeafs.GetSelectedCount());
	SetDlgItemText(IDC_INFOLABEL, temp);
}
Example #11
0
// **************************************************************************
// OnInitDialog ()
//
// Description:
//	Called immediately before the dialog box is displayed.  Use opportunity
//	to initialize controls.
//
// Parameters:
//  none
//
// Returns:
//	BOOL - TRUE.
// **************************************************************************
BOOL CKServerStatusPage::OnInitDialog () 
{
	IOPCServer *pIServer = NULL;
	OPCSERVERSTATUS *pServerStatus;
	CString strLoader;
	CString strStatus;
	CString strTemp;

	// Perform default processing:
	CPropertyPage::OnInitDialog ();

	// Get IServer interface:
	ASSERT (m_pServer != NULL);
	pIServer = m_pServer->GetIServer ();

	// Add server name to status string:
	strLoader.FormatMessage (IDS_PROGID, m_pServer->GetProgID ());
	strStatus += strLoader;

	// Add remote machine (if applicable) to status string:
	if (m_pServer->GetRemoteMachine ())
	{
		strLoader.FormatMessage (IDS_REMOTEMACHINE, m_pServer->GetRemoteMachine ());
		strStatus += strLoader;
	}

	// Get the server status:
	if (pIServer && SUCCEEDED (pIServer->GetStatus (&pServerStatus)) && pServerStatus)
	{
		FILETIME ftLocal;
		TCHAR szBuffer [DEFBUFFSIZE];

		// Add vendor name to status string:
		if (pServerStatus->szVendorInfo)
		{
			// Convert venter name from UNICODE if needed:
		#ifdef _UNICODE
			lstrcpyn (szBuffer, pServerStatus->szVendorInfo, sizeof (szBuffer) / sizeof (TCHAR));
		#else
			_wcstombsz (szBuffer, pServerStatus->szVendorInfo, sizeof (szBuffer) / sizeof (TCHAR));
		#endif
			// Add vender name:
			strLoader.FormatMessage (IDS_VENDORNAME, szBuffer);
			strStatus += strLoader;

			// Free memory allocated for vender info:
			CoTaskMemFree (pServerStatus->szVendorInfo);
		}

		// Add start time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftStartTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_STARTTIME, strTemp);
				strStatus += strLoader;
			}
		}	

		// Add current time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftCurrentTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_CURRENTTIME, strTemp);
				strStatus += strLoader;
			}
		}

		// Add last update time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftLastUpdateTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_LASTUPDATETIME, strTemp);
				strStatus += strLoader;
			}
		}

		// Create a string describing server state:
		switch (pServerStatus->dwServerState)
		{
		case OPC_STATUS_RUNNING:
			strTemp.LoadString (IDS_RUNNING);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_FAILED: 
			strTemp.LoadString (IDS_FAILED);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_NOCONFIG: 
			strTemp.LoadString (IDS_NOCONFIG);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_SUSPENDED:
			strTemp.LoadString (IDS_SUSPENDED);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_TEST: 
			strTemp.LoadString (IDS_TEST);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		default: 
			strLoader.FormatMessage (IDS_SERVERSTATE, _T("???")); 
			break;			
		}

		// Add server state to status string:
		strStatus += strLoader;

		// Add group count to status string:
		strTemp.Format (_T("%d"), pServerStatus->dwGroupCount);
		strLoader.FormatMessage (IDS_GROUPCOUNT, strTemp);
		strStatus += strLoader;

		// Add major version number to status string:
		strTemp.Format (_T("%d"), pServerStatus->wMajorVersion);
		strLoader.FormatMessage (IDS_MAJORVERSION, strTemp);
		strStatus += strLoader;

		// Add minor version to status string:
		strTemp.Format (_T("%d"), pServerStatus->wMinorVersion);
		strLoader.FormatMessage (IDS_MINORVERSION, strTemp);
		strStatus += strLoader;

		// Add build number to status string:
		strTemp.Format (_T("%d"), pServerStatus->wBuildNumber);
		strLoader.FormatMessage (IDS_BUILDNUMBER, strTemp);
		strStatus += strLoader;

		// Free memeory allocated for server status:
		CoTaskMemFree (pServerStatus);
	}

	// Else if failed, add string stating unable to determin server status
	// to status string:
	else
	{
		strLoader.LoadString (IDS_UNABLE_TO_DETERMINE_STATUS);
		strStatus += strLoader;
	}

	// Display the status string:
	((CStatic *) GetDlgItem (IDC_STATUS))->SetWindowText (strStatus);

	// return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
	return (TRUE);  
}
Example #12
0
BOOL CGuideDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	// create backup if required
	if (theApp.GetAutoBackup())
		BackupFile(lpszPathName);

	// == [0-byte file handling] ============================================
	//
	// Treat specially if file is 0 bytes. This is required so that
	// when the app is asked to open a 0 byte file, it acts as though
	// it is doing a file->new, but with the associated file name.
	// This is required when you do New -> Guide from the explorer
	// RMB. Explorer creates a 0 byte file and calls Guide.exe with
	// the filename as argument.
	DWORD fileSize = 0;
	if (_GetFileSize(lpszPathName, fileSize) && fileSize == 0)
	{
		// delete current contents
		DeleteContents();
		// load an empty guide
		m_pGuide = guide_create();
		// return success
		return TRUE;
	}
	// ======================================================================

	// load the file as a new document
	unsigned os_errcode;
	uint32 gde_format = 0;
	struct guide_t *pNewDocument = guide_load(lpszPathName, &os_errcode, &gde_format);

	// could we open it?
	if (pNewDocument == NULL)
	{
		// could not open file: display an error message

		// get only the filename out
		CString fullName(lpszPathName);
		fullName.Replace(_T('/'), _T('\\'));
		int slashPos = fullName.ReverseFind(_T('\\'));
		LPCTSTR fileName = static_cast<LPCTSTR>(fullName) + slashPos + 1;
		// note: if \ is not present, slashPos == -1.

		// we form the error message in 'msg'
		CString msg;
		if (os_errcode == 0)
		{
			msg.FormatMessage(IDS_NOGDE, fileName);
		}
		else
		{
			if (os_errcode == 32)
			{
				// show a specific message for file locked
				msg.FormatMessage(IDS_FILELOCKED, fileName);
			}
			else
			{
				// show a generic message otherwise
				msg.FormatMessage(IDS_FILEOPENERR, fileName, getMessage(os_errcode));
			}
		}

		// display the message
		AfxMessageBox(msg, MB_OK|MB_ICONSTOP);

		// return error
		return FALSE;
	}

	// now we can delete the old document
	DeleteContents();
	ASSERT(m_pGuide == NULL);

	// use the new one hereafter
	m_pGuide = pNewDocument;

	// opened: "lock" the .gde file
	m_Locker.lock(lpszPathName);

	// migrate old (v1.x gde file format) links to new ones
	if (gde_format == 1)
		migrateLinks(m_pGuide);

	// success!
	return TRUE;
}