예제 #1
0
/** 
 * @brief Read version info from resource to dialog.
 */
BOOL CAboutDlg::OnInitDialog() 
{
	theApp.TranslateDialog(m_hWnd);
	CDialog::OnInitDialog();

	// Load application icon
	HICON icon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	if (icon != NULL) {
		CStatic * pIcon = (CStatic *) GetDlgItem(IDC_ABOUTBOX_ICON);
		pIcon->SetIcon(icon);
	}

	CVersionInfo version(AfxGetResourceHandle());
	CString sVersion = version.GetFixedProductVersion();
	LangFormatString1(m_strVersion, IDS_VERSION_FMT, sVersion);

	m_strVersion += _T(" ");
	m_strVersion += theApp.LoadString(IDS_UNICODE).c_str();

#ifdef WIN64
	m_strVersion += _T(" ");
	m_strVersion += theApp.LoadString(IDS_WINX64).c_str();
#endif

	CString sPrivateBuild = version.GetPrivateBuild();
	if (!sPrivateBuild.IsEmpty())
	{
		LangFormatString1(m_strPrivateBuild, IDS_PRIVATEBUILD_FMT, sPrivateBuild);
	}

	CString copyright = version.GetLegalCopyright();
	m_ctlCompany.SetWindowText(copyright);
	m_ctlWWW.m_link = WinMergeURL;

	UpdateData(FALSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
예제 #2
0
/**
 * @brief Delete selected filter.
 */
void FileFiltersDlg::OnBnClickedFilterfileDelete()
{
    CString path;
    int sel =- 1;

    sel = m_listFilters.GetNextItem(sel, LVNI_SELECTED);

    // Can't delete first "None"
    if (sel > 0)
    {
        m_listFilters.GetItemText(sel, 2, path.GetBuffer(MAX_PATH),	MAX_PATH);
        path.ReleaseBuffer();

        CString sConfirm;
        LangFormatString1(sConfirm, IDS_CONFIRM_DELETE_SINGLE, path);
        int res = AfxMessageBox(sConfirm, MB_ICONWARNING | MB_YESNO);
        if (res == IDYES)
        {
            if (DeleteFile(path))
            {
                FileFilterMgr *pMgr = theApp.m_globalFileFilter.GetManager();
                pMgr->RemoveFilter(path);

                // Remove all from filterslist and re-add so we can update UI
                CString selected;
                m_Filters->RemoveAll();
                theApp.m_globalFileFilter.GetFileFilters(m_Filters, selected);

                UpdateFiltersList();
            }
            else
            {
                ResMsgBox1(IDS_FILEFILTER_DELETE_FAIL, path, MB_ICONSTOP);
            }
        }
    }
}
예제 #3
0
/** 
 * @brief Paint splashscreen.
 * Draws image to window size (which is already set to image size).
 * Then adds texts over image.
 */
void CSplashWnd::OnPaint()
{
	CPaintDC dc(this);
	m_pPicture->Render(&dc);

	CVersionInfo version(TRUE);
	CString s;
	CFont versionFont;
	CFont textFont;
	CFont copyrightFont;
	CFont *oldfont = NULL;

	int fontHeight = -MulDiv(VersionTextSize, dc.GetDeviceCaps(LOGPIXELSY), 72);
	BOOL fontSuccess = versionFont.CreateFont(fontHeight, 0, 0, 0, FW_BOLD, FALSE, FALSE,
		0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, FontName);
	if (fontSuccess)
		oldfont = dc.SelectObject(&versionFont);

	CString sVersion = version.GetFixedProductVersion();
	LangFormatString1(s, IDS_VERSION_FMT, sVersion);
	dc.SetBkMode(TRANSPARENT);
	
	RECT area = VersionTextArea;
	dc.DrawText(s, &area, VersionTextStyle);

	fontHeight = -MulDiv(DevelopersTextSize, dc.GetDeviceCaps(LOGPIXELSY), 72);
	fontSuccess = textFont.CreateFont(fontHeight, 0, 0, 0, 0, FALSE, FALSE,
		0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, FontName);
	if (fontSuccess)
	{
		// We already stored oldfont in previous font change
		if (oldfont == NULL)
			oldfont = dc.SelectObject(&textFont);
		else
			dc.SelectObject(&textFont);
	}

	String text = LoadResString(IDS_SPLASH_DEVELOPERS);

	// avoid dereference of empty strings and the NULL termiated character
	if (text.length() >= 0)
	{
		// Replace ", " with linefeed in developers list text to get
		// developers listed a name per line in the about dialog
		std::string::size_type pos = text.rfind(_T(", "));
		while (pos != std::string::npos)
		{
			text.replace(pos, 2, _T("\n"), 1);
			pos = text.rfind(_T(", "), pos - 1);
		}
	}

	area = DevelopersArea;
	dc.DrawText(text.c_str(), &area, DevelopersTextStyle);

	fontHeight = -MulDiv(CopyrightTextSize, dc.GetDeviceCaps(LOGPIXELSY), 72);
	fontSuccess = copyrightFont.CreateFont(fontHeight, 0, 0, 0, 0, FALSE, FALSE,
		0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, FontName);
	if (fontSuccess)
	{
		// We already stored oldfont in previous font change
		if (oldfont == NULL)
			oldfont = dc.SelectObject(&copyrightFont);
		else
			dc.SelectObject(&copyrightFont);
	}

	text = LoadResString(IDS_SPLASH_GPLTEXT);
	area = CopyrightArea;
	dc.DrawText(text.c_str(), &area, CopyrightTextStyle);

	if (oldfont != NULL)
		dc.SelectObject(oldfont);
}
예제 #4
0
void CEditReplaceDlg::
OnEditReplaceAll ()
{
  if (!UpdateData ())
    return;

  m_ctlFindText.SaveState(_T("Files\\ReplaceInFile"));
  m_ctlReplText.SaveState(_T("Files\\ReplaceWithInFile"));
  UpdateLastSearch ();

  int nNumReplaced = 0;
  BOOL bWrapped = FALSE;
  CWaitCursor waitCursor;


  if (!m_bFound)
    {
      m_ptFoundAt = m_ptCurrentPos;
      m_bFound = DoHighlightText ( FALSE );
    }

  CPoint m_ptFirstFound = m_ptFoundAt;

  while (m_bFound)
    {
      DWORD dwSearchFlags = 0;
      if (m_bMatchCase)
        dwSearchFlags |= FIND_MATCH_CASE;
      if (m_bWholeWord)
        dwSearchFlags |= FIND_WHOLE_WORD;
      if (m_bRegExp)
        dwSearchFlags |= FIND_REGEXP;
    
      //  We have highlighted text
      VERIFY (m_pBuddy->ReplaceSelection (m_sNewText, m_sNewText.GetLength(), dwSearchFlags));

      //  Manually recalculate points
      if (m_bEnableScopeSelection)
        {
          if (m_ptBlockBegin.y == m_ptFoundAt.y && m_ptBlockBegin.x > m_ptFoundAt.x)
            {
              m_ptBlockBegin.x -= m_pBuddy->m_nLastFindWhatLen;
              m_ptBlockBegin.x += m_pBuddy->m_nLastReplaceLen;
            }
          if (m_ptBlockEnd.y == m_ptFoundAt.y && m_ptBlockEnd.x > m_ptFoundAt.x)
            {
              m_ptBlockEnd.x -= m_pBuddy->m_nLastFindWhatLen;
              m_ptBlockEnd.x += m_pBuddy->m_nLastReplaceLen;
            }
        }
      // recalculate m_ptFirstFound
      if (m_ptFirstFound.y == m_ptFoundAt.y && m_ptFirstFound.x > m_ptFoundAt.x)
        {
          m_ptFirstFound.x -= m_pBuddy->m_nLastFindWhatLen;
          m_ptFirstFound.x += m_pBuddy->m_nLastReplaceLen;
        }

      // calculate the end of the current replacement
      CPoint m_ptCurrentReplacedEnd;
      m_ptCurrentReplacedEnd.y = m_ptFoundAt.y;
      m_ptCurrentReplacedEnd.x = m_ptFoundAt.x + m_pBuddy->m_nLastReplaceLen;

      // m_ptFoundAt.x has two meanings:
      // (1) One is the position of the word that was found.
      // (2) The other is next position to search.
      // The code below calculates the latter.
      if (!m_pBuddy->m_nLastFindWhatLen)
        if (m_ptFoundAt.y + 1 < m_pBuddy->GetLineCount ())
          {
            m_ptFoundAt.x = 0;
            m_ptFoundAt.y++;
          }
        else
          {
            m_bFound = FALSE;
            break;
          }
      else
        {
          m_ptFoundAt.x += m_pBuddy->m_nLastReplaceLen;
          m_ptFoundAt = m_pBuddy->GetCursorPos ();
        }
      nNumReplaced++;

      // find the next instance
      m_bFound = DoHighlightText ( FALSE );

      // detect if we just wrapped at end of file
      if (m_ptFoundAt.y < m_ptCurrentReplacedEnd.y || (m_ptFoundAt.y == m_ptCurrentReplacedEnd.y && m_ptFoundAt.x < m_ptCurrentReplacedEnd.x))
        bWrapped = TRUE;

      // after wrapping, stop at m_ptFirstFound
      // so we don't replace twice when replacement string includes replaced string 
      // (like replace "here" with "there")
      if (bWrapped)
        if (m_ptFoundAt.y > m_ptFirstFound.y || (m_ptFoundAt.y == m_ptFirstFound.y && m_ptFoundAt.x >= m_ptFirstFound.x))
          break;
    }

  // Let user know how many strings were replaced
  CString strMessage;
  CString strNumber;
  strNumber.Format( _T("%d"), nNumReplaced );
  LangFormatString1(strMessage, IDS_NUM_REPLACED, strNumber);

  AfxMessageBox( strMessage, MB_ICONINFORMATION|MB_DONT_DISPLAY_AGAIN, IDS_NUM_REPLACED);
}