Example #1
0
//
/// Displays a message box with an error message loaded from the resource file.
//
void
TUrlLink::ReportError(int error)
{
  uint resId;
  switch (error) {
    case 0:                       resId = IDS_OUTOFMEMORY; break;
    case SE_ERR_PNF:              resId = IDS_PATHNOTFOUND; break;
    case SE_ERR_FNF:              resId = IDS_FILENOTFOUIND; break;
    case ERROR_BAD_FORMAT:        resId = IDS_FILEINVALID; break;
    case SE_ERR_ACCESSDENIED:     resId = IDS_ACCESSDENIED; break;
    case SE_ERR_ASSOCINCOMPLETE:  resId = IDS_INVALIDASSOC; break;  //  Win32/Win16
    case SE_ERR_DDEBUSY:          resId = IDS_DDEBISY; break;        //  Win32/Win16
    case SE_ERR_DDEFAIL:          resId = IDS_DDEFAILED; break;      //  Win32/Win16
    case SE_ERR_DDETIMEOUT:       resId = IDS_DDETYMEOUT; break;    //  Win32/Win16
    case SE_ERR_DLLNOTFOUND:      resId = IDS_FILENOTFOUIND; break;
    case SE_ERR_NOASSOC:          resId = IDS_NOINSTANCE; break;    //  Win32/Win16
    case SE_ERR_OOM:              resId = IDS_OUTOFMEMORY; break;
    case SE_ERR_SHARE:            resId = IDS_SHAREDERROR; break;    //  Win32/Win16
    default:{
      FormatMessageBox(IDS_UNCKNOWNERR, 0, MB_ICONEXCLAMATION | MB_OK, error);
      return;
    }
  }
  //str = "Unable to open hyperlink:\n\n" + str;
  MessageBox(resId, _T(""), MB_ICONEXCLAMATION | MB_OK);
  return;
}
LRESULT AFX_MSG_CALL CFilePage::OnCopyDirError(WPARAM wParam, LPARAM /*lParam*/)
{
    DWORD dwError = (DWORD)wParam;
    FTL::CFAPIErrorInfo apiErrorInfo(dwError);
    FormatMessageBox(m_hWnd, TEXT("OnError"), MB_OK, TEXT("Err:%d\n%s"), 
        dwError, apiErrorInfo.GetConvertedInfo());
    return 0;
}
Example #3
0
//
/// Calls SetFileName and Read to replace the file currently being edited with a
/// file whose name is supplied.
//
void
TEditFile::ReplaceWith(LPCTSTR fileName)
{
  if (Read(fileName))
  {
    Invalidate();
    SetFileName(fileName);
  }
  else
  {
    FormatMessageBox(IDS_UNABLEREAD, 0, MB_ICONEXCLAMATION | MB_OK, fileName);
  }
}
Example #4
0
//
/// Returns true if the text of the associated edit control can be cleared
/// which is if the text has not been changed, or if the user Oks the
/// clearing of the text
//
bool
TEditFile::CanClear()
{
  if (IsModified())
  {
    tstring untitled(LoadString(IDS_UNTITLEDFILE));

    int result = FormatMessageBox(IDS_FILECHANGED, 0, MB_YESNOCANCEL|MB_ICONQUESTION,
      FileName ? (LPCTSTR)FileName : untitled.c_str());

    return result==IDYES ? Save() : result != IDCANCEL;
  }
  return true;
}
Example #5
0
//
/// Saves changes to the contents of the Editor to a file. If Editor->IsModified
/// returns false, Save returns true, indicating there have been no changes since
/// the last open or save.
//
bool
TEditFile::Save()
{
  if (IsModified())
  {
    if (!FileName)
      return SaveAs();

    if (!Write())
    {
      FormatMessageBox(IDS_UNABLEWRITE, 0, MB_ICONEXCLAMATION | MB_OK, FileName);
      return false;
    }
  }
  return true;  // editor's contents haven't been changed
}
Example #6
0
//
/// Saves the contents of the Editor to a file whose name is retrieved from the
/// user, through execution of a File Save dialog box. If the user selects OK,
/// SaveAs calls SetFileName and Write. Returns true if the file was saved.
//
bool
TEditFile::SaveAs()
{
  if (FileName)
    ::_tcscpy(FileData.FileName, FileName);

  else
    *FileData.FileName = 0;

  if (TFileSaveDialog(this, FileData).Execute() == IDOK)
  {
    if (Write(FileData.FileName))
    {
      SetFileName(FileData.FileName);
      return true;
    }
    FormatMessageBox(IDS_UNABLEWRITE, 0, MB_ICONEXCLAMATION | MB_OK, FileName);
  }
  return false;
}
Example #7
0
//
/// Performs a search or replace operation base on information in SearchData.
//
void
TEditSearch::DoSearch()
{
  do {
    if (Search(-1, SearchData.FindWhat, bool(SearchData.Flags&FR_MATCHCASE),
               bool(SearchData.Flags&FR_WHOLEWORD),
               !(SearchData.Flags&FR_DOWN)) >= 0) 
	{
      if (SearchData.Flags & (FR_REPLACE|FR_REPLACEALL))
        Insert(SearchData.ReplaceWith);
    }
    else 
	{
      if (SearchData.Flags & (FR_FINDNEXT|FR_REPLACE)) 
	  {
        FormatMessageBox(IDS_CANNOTFIND, 0, MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL, (LPCTSTR)SearchData.FindWhat);
      }
      else if (SearchData.Flags & FR_REPLACEALL)
        break;
    }
  } while (SearchData.Flags & FR_REPLACEALL);
}
void CMFToolbar::GetQuote()
{
    BOOL bRet = FALSE;
	// if we have a web browser pointer then try to navigate to The Motley Fool site to retrieve stock quotes.
	if (m_pBrowser)
	{
		VARIANT vEmpty;
		VariantInit(&vEmpty);
		m_pBrowser->Stop();
		_bstr_t bsSite;
		// if the user has entered stock quotes then append them to the url
		if (m_EditWnd.GetWindowTextLength())
		{
			BSTR bstrTickers = NULL;
			m_EditWnd.GetWindowText(&bstrTickers);
			//bsSite = "http://quote.fool.com/news/symbolnews.asp?Symbols=";
			bsSite = bstrTickers;
			SysFreeString(bstrTickers);
		}
        FormatMessageBox(m_hWnd, TEXT("GetQuote"), MB_OK, TEXT("%s"), OLE2CT(bsSite));
        return;
		// if the user has not entered any stock quotes then just take them to The Motley Fool website.
		//else
		//	bsSite = "http://www.fool.com";
		// have the webrowser navigate to the site URL requested depending on user input.
        CFUnicodeFile textFile(tfeUnicode);
        API_VERIFY(textFile.Create(bsSite));
        if (bRet)
        {
            API_VERIFY(textFile.WriteFileHeader(NULL));
            API_VERIFY(textFile.WriteString(TEXT("CMFToolbar::GetQuote Test")));
            API_VERIFY(textFile.Close());
        }
		//m_pBrowser->Navigate(bsSite, &vEmpty, &vEmpty, &vEmpty, &vEmpty);
	}
}