virtual CDocument* OpenDocumentFile(LPCTSTR lpszPathName, BOOL /*bMakeVisible*/)
   {
      CWnd* parent = GetActiveFrame();
      CDocument* doc = NULL;
      CStringArray newfile;
      CString tablename;
   #ifdef x_DEBUG
      tablename = _T("årstal");
      //tablename = _T("tur_tur");
      //tablename = _T("Adresser");
   #endif
      bool ok = ::mdb2dbf(parent, lpszPathName, &newfile, tablename);
      if (ok)
      {
         if (newfile.GetSize())
         {
            for (int i = 0; i < newfile.GetSize(); i++)
            {
	            doc = theApp.m_doctemplate->OpenDocumentFile(newfile.ElementAt(i));
            }
         }
         else // user chose csv
         {
            AfxMessageBox(_T("Done"));
         }
         AfxGetApp()->AddToRecentFileList(lpszPathName);
      }
      else AfxMessageBox(_T("Error"));
      return doc;
   }
示例#2
0
CString	CStkUIApp::GetNextNewStrategyTitle( CString & strExtBuffer, CString strPath )
{
	CString	string;
	VERIFY( string.LoadString( IDS_STRATEGY_NONAME ) );

	CString strExt	=	AfxGetStrategyFileExt( );
	if( !strExt.IsEmpty())
		strExtBuffer	=	strExt;

	CStringArray	astrExistTitle;
	POSITION pos = GetFirstStrategyPosition();
	while( NULL != pos )
	{
		CStrategy * pStrategy = GetNextStrategy( pos );
		astrExistTitle.Add( AfxGetFileTitleNoExt(pStrategy->GetPathName()) );
	}

	CFileFind finder;
	BOOL	bWorking	=	finder.FindFile( AfxGetFilePath( (LPCTSTR)strPath, LPCTSTR("*" + strExt) ) );
	while( bWorking )
	{
		bWorking	=	finder.FindNextFile();
		astrExistTitle.Add( finder.GetFileTitle( ) );
	}
	finder.Close();

	for( int i=1; ; i++ )
	{
		CString	strTemp;
		strTemp.Format( "%s(%d)", string, i );
		
		BOOL	bHas	=	FALSE;
		for( int k=0; k<astrExistTitle.GetSize(); k++ )
		{
			if( 0 == strTemp.CompareNoCase( astrExistTitle.ElementAt(k) ) )
			{
				bHas	=	TRUE;
				break;
			}
		}
		
		if( !bHas )
		{
			string	=	strTemp;
			break;
		}
	}
	return string;
}
示例#3
0
CString CMainTableFunctions::GetDisplayText(int nMaxLines, const CString &OrigText)
{
	CString text = OrigText;
	// assign tabs to 2 spaces (rather than the default 8)
	text.Replace(_T("\t"), _T("  "));

	if(g_Opt.m_bDescShowLeadingWhiteSpace)
		return text;
	// else, remove the leading indent from every line.

	// get the lines
	CString token;
	CStringArray tokens;
	CTokenizer tokenizer(text,"\r\n");
	for(int nLines=0; nLines < nMaxLines && tokenizer.Next(token); nLines++)
	{
		tokens.Add(token);
	}

	// remove each line's indent
	TCHAR chFirst;
	CString line;
	INT_PTR count = tokens.GetSize();
	text = "";
	for(int i=0; i < count; i++)
	{
		line = tokens.ElementAt(i);
		chFirst = line.GetAt(0);
		if(chFirst == ' ' || chFirst == '\t')
		{
			text += "» "; // show indication that the line is modified
			line.TrimLeft();
			text += line;
		}
		else
			text += line;

		text += "\n";
	}

	return text;
}
示例#4
0
BOOL CPageGeneral::OnInitDialog()
{
    CPropertyPage::OnInitDialog();

    // TODO: Add extra initialization here

    this->GetDlgItem(IDC_EDIT_EIS_DATABASE)->SetWindowText(this->GetDatabaseTXT(CRunTime::GetGeneral()->m_strEISDatabase));

    MRET rc = this->LoadDepartment();
    if (rc != ME_OK)
    {
        LOG_ERROR(LL_ERROR | LD_ALL, rc);
    }

    CStringArray aVoiceClass;
    this->m_ModuleTTS.GetVoiceList(&aVoiceClass);

    LONG nIndex;
    for (LONG i = 0; i < aVoiceClass.GetSize(); i++)
        nIndex = this->m_cboVoiceClass.AddString(aVoiceClass.ElementAt(i));

    CString strVoiceDescription;
    if (this->m_cboVoiceClass.GetCount() > CRunTime::GetGeneral()->m_nVoiceClass)
        this->m_cboVoiceClass.GetLBText(CRunTime::GetGeneral()->m_nVoiceClass, strVoiceDescription);
    if (!strVoiceDescription.IsEmpty() && strVoiceDescription == CRunTime::GetGeneral()->m_strVoiceDescription)
        this->m_cboVoiceClass.SetCurSel(CRunTime::GetGeneral()->m_nVoiceClass);
    else
    {
        for (i = 0; i < this->m_cboVoiceClass.GetCount(); i++)
        {
            this->m_cboVoiceClass.GetLBText(i, strVoiceDescription);
            if (strVoiceDescription == CRunTime::GetGeneral()->m_strVoiceDescription)
            {
                this->m_cboVoiceClass.SetCurSel(i);
                CRunTime::GetGeneral()->m_nVoiceClass = i;
            }
        }
    }

    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CColListCtrl::CreateComboBox( int nItem ) 
{
	if( m_nComboBoxColumn < 0 || nItem < 0 )
		return FALSE;

	// Create
	if( !m_comboBox.GetSafeHwnd() )
	{
		CRect	rectItem( 0, 0, 35, 136 );
		GetSubItemRect( nItem, m_nComboBoxColumn, LVIR_BOUNDS, rectItem );
		CRect	rect( 0, 0, rectItem.Width(), rectItem.Height()+120 );
		if( !m_comboBox.Create( WS_CHILD | CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | CBS_HASSTRINGS,
				rect, this, IDC_COLLISTCTRL_COMBOBOX ) )
			return FALSE;

		HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
		if (hFont == NULL)
			hFont = (HFONT)GetStockObject(ANSI_VAR_FONT);
		m_comboBox.SendMessage(WM_SETFONT, (WPARAM)hFont);
	}

	// Add Strings
	if( nItem >= 0 && nItem < m_aptrItemStrings.GetSize() )
	{
		CStringArray	* pastr	=	(CStringArray *) m_aptrItemStrings.ElementAt(nItem);
		if( NULL != pastr && pastr->GetSize() > 0 )
		{
			m_comboBox.ResetContent();
			for( int k=0; k<pastr->GetSize(); k++ )
				m_comboBox.AddString( pastr->ElementAt(k) );
			m_comboBox.SelectString( 0, GetItemText(nItem,m_nComboBoxColumn) );
			return TRUE;
		}
	}
	return FALSE;
}
示例#6
0
void CWizardView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( UPDATE_HINT_WIZARDVIEW != lHint )
	{
		if( ::IsWindow( m_listRecent.GetSafeHwnd() ) )
			m_listRecent.Invalidate( );
		return;
	}
	if( IsWindowVisible() )
		SetFocus( );

	m_listRecent.DeleteAllItems( );

	//	insert items
	CStkUIApp * pApp = AfxGetStkUIApp();
	CRecentFileList * pRecent = NULL;
	if( pApp )
		pRecent = pApp->GetRecentFileList( );

	CString	strOpened;
	strOpened.LoadString( IDS_STRATEGYOPENED );

	CStringArray	astrAdded;

	int	count	=	0;
	if( pRecent )
	{
		for( int i=pRecent->GetSize()-1; i>=0; i-- )
		{
			CString strPath = (*pRecent)[i];
			if( strPath.IsEmpty() )
				continue;
			if( 0 != access(strPath,0) )
			{
				pRecent->Remove(i);
				continue;
			}

			TCHAR	szFullPath[_MAX_PATH];
			AfxFullPath( szFullPath, strPath );
			strPath	=	szFullPath;

			CString strName	=	CStrategy::GetName( strPath );
			BOOL	bOpened	=	pApp->IsFileOpened( strPath );
			int nItem = m_listRecent.InsertItem( count, strPath, bOpened ? 1 : 0 );
			m_listRecent.SetItemText( nItem, 0, strName );
			m_listRecent.SetItemText( nItem, 1, strPath );
			if( bOpened )
				m_listRecent.SetItemText( nItem, 3, strOpened );
			astrAdded.Add( strPath );
			
			CString	strTime;
			CFileStatus	status;
			if( CFile::GetStatus( strPath, status ) )
			{
				strTime = status.m_mtime.Format( "%Y-%m-%d" );
				m_listRecent.SetItemText( nItem, 2, strTime );
			}
			count ++;
		}
	}

	CString strExt	=	AfxGetStrategyFileExt( );
	if( !strExt.IsEmpty())
	{
		CFileFind finder;
		BOOL	bWorking	=	finder.FindFile( AfxGetFilePath( (LPCTSTR)AfxGetProfile().GetProjectPath(), LPCTSTR("*" + strExt) ) );
		while( bWorking )
		{
			bWorking	=	finder.FindNextFile();
			CString	strPath	=	finder.GetFilePath();

			int i;
			for( i=0; i<astrAdded.GetSize(); i++ )
			{
				if( 0 == strPath.CompareNoCase( astrAdded.ElementAt(i) ) )
					break;
			}
			if( i < astrAdded.GetSize() )
				continue;

			CString strName	=	CStrategy::GetName( strPath );
			BOOL	bOpened	=	pApp->IsFileOpened( strPath );
			int nItem = m_listRecent.InsertItem( count, strPath, bOpened ? 1 : 0 );
			m_listRecent.SetItemText( nItem, 0, strName );
			m_listRecent.SetItemText( nItem, 1, strPath );
			if( bOpened )
				m_listRecent.SetItemText( nItem, 3, strOpened );

			CString	strTime;
			CFileStatus	status;
			if( CFile::GetStatus( strPath, status ) )
			{
				strTime = status.m_mtime.Format( "%Y-%m-%d" );
				m_listRecent.SetItemText( nItem, 2, strTime );
			}
			count ++;

			if( count >= 256 )
				break;
		}
		finder.Close();
	}

	m_listRecent.Invalidate( );
}