Exemplo n.º 1
0
// Error report function
void CHyperLink::ReportError(int nError)
{
	CUString str;
   
	switch (nError) {
        case 0:                       str = _W("The operating system is out\nof memory or resources."); break;
        case ERROR_FILE_NOT_FOUND:    str = _W("The specified file was not found."); break;
		case ERROR_PATH_NOT_FOUND:	  str = _W("The specified path was not found."); break;	
        case ERROR_BAD_FORMAT:        str = _W("The .EXE file is invalid\n(non-Win32 .EXE or error in .EXE image)."); break;
        case SE_ERR_ACCESSDENIED:     str = _W("The operating system denied\naccess to the specified file."); break;
        case SE_ERR_ASSOCINCOMPLETE:  str = _W("The filename association is\nincomplete or invalid."); break;
        case SE_ERR_DDEBUSY:          str = _W("The DDE transaction could not\nbe completed because other DDE transactions\nwere being processed."); break;
        case SE_ERR_DDEFAIL:          str = _W("The DDE transaction failed."); break;
        case SE_ERR_DDETIMEOUT:       str = _W("The DDE transaction could not\nbe completed because the request timed out."); break;
        case SE_ERR_DLLNOTFOUND:      str = _W("The specified dynamic-link library was not found."); break;
        //case SE_ERR_FNF:			  str = _W("Windows 95 only: The specified file was not found."); break; 
		case SE_ERR_NOASSOC:          str = _W("There is no application associated\nwith the given filename extension."); break;
        case SE_ERR_OOM:              str = _W("There was not enough memory to complete the operation."); break;
    	//case SE_ERR_PNF:              str = _T("The specified path was not found."); break;
		case SE_ERR_SHARE:            str = _W("A sharing violation occurred. "); break;
        default:                      str.Format(_W("Unknown Error (%d) occurred."), nError); break;
    }

	str = _W( "Can't open link:\n\n" ) + str;
    CDexMessageBox( str, MB_ICONEXCLAMATION | MB_OK);
}
Exemplo n.º 2
0
void CGenreTable::Save( CUString strFileName )
{
	FILE* pFile = NULL;
	TCHAR lpszLine[ 255 ] = { '\0',};
	int i = 0;

    CUStringConvert strCnv;
	
    pFile = CDexOpenFile( strFileName, _W( "w" ) );

	if ( NULL != pFile )
	{
		for ( i = 0 ; i < (int)v_Entries.size(); i++ )
		{
			if ( CanBeModified( i ) )
			{
				CUString strLine;
                CUStringConvert strCnv;

				GENRETABLEENTRY newEntry = v_Entries[i] ;

				strLine.Format( _W( "%d\t%s\t%s\n" ), newEntry.nID3V1ID, (LPCWSTR)newEntry.strGenre, (LPCWSTR)newEntry.strCDDBGenre );

				_fputts( strCnv.ToT( strLine ), pFile );
			}
		}

		fclose( pFile );
	}
}
Exemplo n.º 3
0
LRESULT CDTDViewGroup::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    if (m_pDocument->m_viewGroups.GetSize() == 1)
    {
        CUString msg;
        _bstr_t pathName;

        if (m_pDocument->m_pathName.length())
            pathName = m_pDocument->m_pathName;
        else
            pathName = m_pDocument->m_fileTitle;

        msg.Format("Save changes to %S?", (BSTR)pathName);

        int id = ::MessageBox(NULL/*TODO*/, msg, "WebEditor", MB_YESNOCANCEL | MB_ICONEXCLAMATION);
        if (id == IDCANCEL) return 0;

        if (id == IDYES)
        {
            // TODO save
        }
    }

    LRESULT lResult;
    bHandled = baseClass::ProcessWindowMessage(m_hWnd, uMsg, wParam, lParam, lResult);
    return lResult;
}
Exemplo n.º 4
0
void CGenreEditDlg::OnInsertnew() 
{
	CUString strLang;
    CUStringConvert strCnv;

	UpdateList( m_nLastSelection );

	int i = m_nInsertPosition;

	CUString strNmbr;

	strLang = g_language.GetString( IDS_NEW_GENRE_NAME );

	m_List.InsertItem( i, strCnv.ToT( strLang ) );

    m_List.SetItemText( i, 1, strCnv.ToT( g_GenreTable.GetCDDBGenre( 0 ) ) );

	strNmbr.Format( _W( "%d" ) , 255 );

    m_List.SetItemText( i, 2, strCnv.ToT( strNmbr ) );

	m_List.SetCurSel( i );
	SetControls( i );

	m_nInsertPosition++;

}
Exemplo n.º 5
0
void CLanguage::ReportMissingID( int nID, const CUString& strEnglish, int nType ) const
{
    if ( g_nReportMissing )
    {
        BOOL		bAdd = TRUE;
        CUString    strWrite;
        CString		strRead;
        CStdioFile	cFile;
        CUStringConvert strCnv;

        switch ( nType )
        {
        case 0:
            strWrite.Format( _W( "#%04X# \"%s\"" ), nID, (LPCWSTR)strEnglish );
            break;
        case 1:
            strWrite.Format( _W( "#M%04X# \"%s\"" ), nID, (LPCWSTR)strEnglish );
            break;
        case 2:
            strWrite.Format( _W( "#D%08X# \"%s\"" ), nID, (LPCWSTR)strEnglish );
            break;
        }

        EncodeTab( strWrite );

        if ( cFile.Open(	_T( "c:\\temp\\missing.txt" ),
                            CFile::modeReadWrite | CFile::modeNoTruncate | CFile::modeCreate ) )
        {
            while ( cFile.ReadString( strRead ) )
            {
                if ( strWrite.Find( CUString( strRead ) ) >=0 )
                {
                    bAdd = FALSE;
                    break;
                }
            }
            if ( bAdd )
            {
                cFile.WriteString( strCnv.ToT( strWrite + _W( "\n" ) ) );
            }
            cFile.Close();
        }
    }
}
Exemplo n.º 6
0
void DbError(_com_error &e)
{
	_bstr_t bstrSource(e.Source());
	_bstr_t bstrDescription(e.Description());
      
	CUString msg;
	msg.Format("\n\tSource :  %s \n\tdescription : %s \n ",(LPCSTR)bstrSource,(LPCSTR)bstrDescription);

	MessageBox(NULL, msg, "", MB_OK);
}
Exemplo n.º 7
0
void CEncoderNttVqfDllDlg::FillMinBitrateTable()
{
	// Depending on the settings, fill the bit-rate tables
	m_MinBitrate.ResetContent();

	int nItems=sizeof(nttVqfBitrates)/sizeof(nttVqfBitrates[0] );
	
	int i;

	for ( i = 0; i < nItems; i++ )
	{
		CUString strItem;
		strItem.Format( _W( "%d kbps" ), nttVqfBitrates[ i ] );
        CUStringConvert strCnv;
        m_MinBitrate.AddString( strCnv.ToT( strItem ) );
	}
}
Exemplo n.º 8
0
void CCueSheet::OnBnClickedButton1()
{
	CreateSheet();

    CUStringConvert strCnv;
    CUStringConvert strCnv1;

    CDInfo& cdInfo = m_pDoc->GetCDInfo();
    CUString cueSheetName;
    DWORD cdID = cdInfo.GetDiscID();

    cueSheetName.Format( _W( "%s%08X.cue" ), 
        (LPCWSTR)g_config.GetMP3OutputDir(),
        cdID );

    CUString strFilter = g_language.GetString( IDS_CUESHEETFILESELECTION );

    CFileDialog cueFileDlg(
        FALSE,
        _T( ".cue" ),
        strCnv.ToT( cueSheetName ),
        OFN_OVERWRITEPROMPT,
        strCnv1.ToT( strFilter ) );

    if ( IDOK == cueFileDlg.DoModal() )
    {
        CUString strFileName = CUString( cueFileDlg.GetPathName() );
        FILE* pFile = CDexOpenFile( strFileName, _W( "w" ) );

        if ( pFile )
        {
#ifdef UNICODE
            BYTE btBOM[] = { 0xEF, 0xBB, 0xBF };
            fwrite( &btBOM, sizeof( btBOM ), 1, pFile );
#endif
            LPCSTR lpszUtf = strCnv.ToUTF8( m_strCueSheet );
            fwrite( lpszUtf, 
                    strlen( lpszUtf ), 
                    1, 
                    pFile );
            fclose( pFile );
        }

    }
}
Exemplo n.º 9
0
BOOL CGenreEditDlg::OnInitDialog() 
{
	CUString strLang;

	CDialog::OnInitDialog();
	
	// translate dialog resources
	g_language.InitDialogStrings( this, IDD );

    CUStringConvert strCnv;

	strLang = g_language.GetString( IDS_GENRE_NAME );
	m_List.InsertColumn( 0, strCnv.ToT( strLang ), LVCFMT_LEFT, 130, 0 );
	strLang = g_language.GetString( IDS_GENRE_CDDB_NAME );
	m_List.InsertColumn( 1, strCnv.ToT( strLang ), LVCFMT_LEFT, 100, 0 );
	strLang = g_language.GetString( IDS_GENRE_ID3V1ID );
	m_List.InsertColumn( 2, strCnv.ToT( strLang ), LVCFMT_LEFT, 70, 0 );

	m_nInsertPosition = 0;
	
	// Fill Category
	for (WORD i=0; i < g_GenreTable.GetNumGenres(); i++)
	{
		if ( g_GenreTable.CanBeModified( i ) )
		{
			CUString strNmbr;
			strNmbr.Format( _W( "%d" ) , g_GenreTable.GetID3V1ID( i) );
             
            m_List.InsertItem( m_nInsertPosition, strCnv.ToT( g_GenreTable.GetGenre( i ) ) );
			m_List.SetItemText( m_nInsertPosition, 1, strCnv.ToT( g_GenreTable.GetCDDBGenre( i ) ) );
			m_List.SetItemText( m_nInsertPosition, 2, strCnv.ToT( strNmbr ) );
			m_nInsertPosition++;
		}
	}

	m_Spin.SetRange( 0, 255 );

	m_List.SetCurSel( 0 );

	SetControls( 0 );

	return TRUE;
}
Exemplo n.º 10
0
void CMP3ToWavDlg::OnTimer(UINT nIDEvent) 
{
	CUString strLang;
	CString strTmp;
	CUString strTime;

	strTmp.Format( _T( " (%d/%d)" ), m_wCurrentTrack+1, m_nTotalFiles );

	// Update the time statistics based on the percentage completed
	m_TimeTrack.Calculate( m_nPercentCompleted );

	// Call the default dialog timer event
	CDialog::OnTimer( nIDEvent );

	// Update progress bar position
	m_Progress.SetPos( m_nPercentCompleted );

	m_strFileName = m_strWavFileName + strTmp;

	if ( m_strFileName.GetLength() > 65 )
	{
		int nPos = m_strFileName.Find( _T( ":" ) );

		if ( nPos < 0 )
			nPos = 0;

		m_strFileName = m_strFileName.Left( nPos + 2 ) +
						_T( " ... " ) +
						m_strFileName.Right( 60 ) ;

	}


	// Get time estimate
	strLang = g_language.GetString( IDS_ELAPSED_TIME );

	strTime.Format( strLang, (LPCWSTR)m_TimeTrack.GetElapsedString(), (LPCWSTR)m_TimeTrack.GetRemainingString(), (LPCWSTR)m_TimeTrack.GetEstimateString() );

	m_strTimeInfo = strTime;

	// Update the controls
	UpdateData(FALSE);
}
Exemplo n.º 11
0
void CRipInfoDB::SetRipInfo(CUString strRipInfo)
{
	// Open file for append
    CUStringConvert strCnv;

    m_pFile = CDexOpenFile( m_strFileName, _W( "a+" ) );

	if ( NULL != m_pFile )
	{
        CUString strOut;

        strOut.Format( _W( "[%03d][I] : %s\n" ), m_nTrack, (LPCWSTR)strRipInfo  );

		_fputts( strCnv.ToT( strOut ), m_pFile );

		fclose( m_pFile );

		m_pFile = NULL;
	}
}
Exemplo n.º 12
0
void CRipInfoDB::SetRipInfoFinshedOK(CUString strRipInfo, ULONG crc )
{
    CUStringConvert strCnv;

	// Open file for append
    m_pFile = CDexOpenFile( m_strFileName, _W( "a+" ) );

	if ( m_pFile )
	{
        CUString strOut;

        strOut.Format( _W( "[%03d][C] : %s CRC=%08X\n" ), m_nTrack, (LPCWSTR) strRipInfo, crc );

		_fputts( strCnv.ToT( strOut ), m_pFile );

		fclose( m_pFile );

		m_pFile = NULL;
	}
}
Exemplo n.º 13
0
void CLanguage::SearchLanguageFiles( )
{
    CUString	strSearchName;
    CFileFind	fileFind;
    BOOL		bFound = FALSE;

//    PVOID pTest = (PVOID)m_strLanguageDir;
//CString str;
//CString str1 =_T( "CSTRING1" );
//CString str2 =_T( "CSTRING2" );
//CUString str3( _W("CUSTRING" ));
//    str.Format(	_W( "%s" ),str1 );
//    str.Format(	_W( "%s" ),(LPCWSTR)str3 );
//    str.Format(	_W( "%s\\lang\\*%s" ),
//							str1,
//							str3);


//    CUString* p1 = &str3;
//    CString* p2 = &str1;

    // build the filename search string
    strSearchName.Format( _W( "%s\\lang\\*%s" ), (LPCWSTR)m_strLanguageDir, (LPCWSTR)m_strLangFileExt );

    CUStringConvert strCnv;

    bFound = fileFind.FindFile( strCnv.ToT( strSearchName ) );

    while ( bFound )
    {
        bFound = fileFind.FindNextFile();

        CUString strFileName = fileFind.GetFileName();

        CUString strLanguage = strFileName.Left( strFileName.GetLength() - m_strLangFileExt.GetLength() );

        m_vLangFiles.push_back( strLanguage );
    }
    sort( m_vLangFiles.begin(), m_vLangFiles.end() );
}
Exemplo n.º 14
0
UINT CAutoDetect::OnStartDetectionCache(void *lpParam)
{
    const int bufferSize = 65535;
	// create the stream buffer
	BYTE* pbtStream = new BYTE[ bufferSize ];

	// Read one chunk
    for ( DWORD loop = 1; loop < 100; loop++ )
    {
        DWORD numSectors = loop;
        LONG  sector = 0;

        __int64 startTime = PerformanceCounterGetTime();
        

        while ( numSectors > 0 )
        {
            DWORD readSectors = min( numSectors, 20 );
	        if	( CDEX_ERROR == CR_ReadBlockDirect( pbtStream, bufferSize, sector,  readSectors  ) )
	        {
		        ASSERT( FALSE );
		        return CDEX_ERROR;
	        }
            numSectors -= readSectors;
            sector += readSectors;
        }

        double deltaTime = PerformanceCounterGetDelta( startTime, PerformanceCounterGetTime() );

        CUString strOut;
        strOut.Format( _W( "sectors: %d  bytes: %d time(ms)=%10.3f transfer rate: %12.5f\n" ), loop, loop * 2352,deltaTime,(double)loop * 2352.0 / deltaTime / 1024.0 / 1024.0 );
        CUStringConvert strCnv; 
        OutputDebugString( strCnv.ToT( strOut ) );
    }
    delete [] pbtStream;
    return CDEX_OK;
}
Exemplo n.º 15
0
void CWebSite::OnRescan(GUID* iid)
{
	ATLASSERT(0);
	try
	{
		WCHAR sql[256];
		swprintf(sql, L"INSERT INTO files (filename) VALUES ('%s')", L"test.htm");

		_variant_t	va;
		m_siteDataConnection->Execute(sql, &va, ADODB::adCmdText);

		m_siteDataConnection->Close();
	}
	catch (_com_error &e)
   {
      _bstr_t bstrSource(e.Source());
      _bstr_t bstrDescription(e.Description());
      
		CUString msg;
      msg.Format("\n\tSource :  %s \n\tdescription : %s \n ",(LPCSTR)bstrSource,(LPCSTR)bstrDescription);

		MessageBox(NULL, msg, "", MB_OK);
   }
}
Exemplo n.º 16
0
CUString CTimeTrack::GetEstimateString()
{
	CUString strTmp;
	strTmp.Format( _W( "%02d:%02d" ), m_dwEstimated / 60, m_dwEstimated % 60 );
	return strTmp;
}
Exemplo n.º 17
0
CUString CTimeTrack::GetSpeedString()
{
	CUString strTmp;
	strTmp.Format( _W( "%4.1f" ), m_fSpeed);
	return strTmp;
}
Exemplo n.º 18
0
CDEX_ERR CEncoderFaacDll::OpenStream(CUString strOutFileName,DWORD dwSampleRate,WORD nChannels)
{
	CDEX_ERR	bReturn		= CDEX_OK;
	bool		bStereo		= true;
	CUString		strLang;

    CUStringConvert strCnv;

	ENTRY_TRACE( _T( "CEncoderFaacDll::OpenStream( %s, %d %d" ),
                strCnv.ToT( strOutFileName + _W( "." ) + GetExtension() ),
				dwSampleRate,
				nChannels );


	// setup number of input channels
	m_nInputChannels = nChannels;

	// setup number of output channels
	if ( ( m_nMode & 0xFFFF ) == BE_MP3_MODE_MONO )
	{
		bStereo = false;
	}

	// mixer setup
	if ( ( false == bStereo ) && ( 2 == nChannels ) )
	{
		m_bDownMixToMono  = TRUE;
	}
	else
	{
		m_bDownMixToMono = FALSE;
	}

	if (  ( true == bStereo ) && ( 1 == nChannels ) )
	{
		m_bUpMixToStereo = TRUE;
	}
	else
	{
		m_bUpMixToStereo = FALSE;
	}

		
	// try to get a handle
	m_handle = faacEncOpen( dwSampleRate,
							(bStereo == true )? 2 : 1,
							&m_dwInBufferSize,
							&m_dwOutBufferSize );


	if ( NULL == m_handle )
	{
		CUString strMsg;

		strLang = g_language.GetString( IDS_LOADLIBRARY_FAILED );

		strMsg.Format(	strLang , (LPCWSTR)CUString( ( g_config.GetAppPath() + _W( "\\" ) + m_strEncoderPath ) ) );

		CDexMessageBox( strMsg );
		
		LTRACE( _T( "CEncoderFaacDll::OpenStream Failed to get handle" ) );

		bReturn = CDEX_ERROR;
	}

	if ( CDEX_OK == bReturn )
	{
		// get current config
		m_pConfig = faacEncGetCurrentConfiguration( m_handle );

		// set settings
		if ( GetUserN1() & 0x08 )
		{
			m_pConfig->mpegVersion = FAAC_MPEG4;
		}
		else
		{
			m_pConfig->mpegVersion = FAAC_MPEG2;
		}

		m_pConfig->bitRate = m_nBitrate * 1000;

		m_pConfig->allowMidside = ( GetUserN1() & 0x02 ) ? TRUE : FALSE;

		m_pConfig->useLfe = ( GetUserN1() & 0x04 ) ? TRUE : FALSE;; /* ? */
		m_pConfig->useTns = ( GetUserN1() & 0x01 ) ? TRUE : FALSE;
		m_pConfig->inputFormat = FAAC_INPUT_16BIT;
		m_pConfig->aacObjectType = ( GetUserN2() & 0x07 );
		m_pConfig->shortctl = SHORTCTL_NORMAL;

		switch ( ( GetUserN1() >> 8 ) & 0x0F )
		{
			case 0: m_pConfig->bandWidth = 16000; break;
			case 1: m_pConfig->bandWidth = 18000; break;
			case 2: m_pConfig->bandWidth = 19500; break;
			default: m_pConfig->bandWidth = 19500; break;
		}

		// set new config
		if ( FALSE == faacEncSetConfiguration( m_handle, m_pConfig ) )
		{
			CUString strMsg;

			strLang = g_language.GetString( IDS_LOADLIBRARY_FAILED );

			strMsg.Format(	strLang , (LPCWSTR)CUString( g_config.GetAppPath() + _W( "\\" ) + m_strEncoderPath ) );

			CDexMessageBox( strMsg );
			
			LTRACE( _T( "CEncoderFaacDll::OpenStream Failed to set config" ) );

			bReturn = CDEX_ERROR;
		}

	}
Exemplo n.º 19
0
void CMainFrame::OnLanguageSelection( UINT nID ) 
{
    CDocTemplate*	pTemplate = NULL;
    POSITION		pos;
    CDocument*		pDocument = NULL;

	int nLanguageSelection = nID - ID_LANGUAGE_START;


	if ( 0 == nLanguageSelection )
	{
		WORD nLanguage;

		CHyperLink myLink;

		CUString strVersions;
		// FIXME
		strVersions.Format( _W("cdexversion=1.70&beta=8&cdexdir=%s" ), (LPCWSTR)g_config.GetAppPath() );

		for ( nLanguage=0; nLanguage < g_language.GetNumLanguageStrings(); nLanguage++)
		{
			CUString strLangName( g_language.GetLanguageString( nLanguage ) );
			CUString strLangVersion;
			strLangVersion.Format( _W("%s=%s"), (LPCWSTR)strLangName, (LPCWSTR)g_language.GetRevisionLevel( strLangName ) );
			strVersions += _W( "&" ) + strLangVersion;
		}

//		myLink.GotoURL( _T("www.cdex.n3.net/lang/langcheck.php?") + strVersions , SW_SHOW );
		myLink.GotoURL( _T("cdexos.sourceforge.net/lang/cdex_v1.70"), SW_SHOW );
	}
	else
	{
//		nLanguageSelection--;

		// Switch to selected language
		CString strMenu;

		m_pPopupMenu->GetMenuString( nLanguageSelection, strMenu, MF_BYPOSITION );

		g_language.SetLanguage( CUString( strMenu ) );

		// get document template
		pos = AfxGetApp()->GetFirstDocTemplatePosition();

		pTemplate = AfxGetApp()->GetNextDocTemplate( pos );

		POSITION docpos = pTemplate->GetFirstDocPosition( );

		// Loop through documents in this template
		while ( docpos )
		{
			VERIFY( pDocument = pTemplate->GetNextDoc(docpos) );

			// update all view attached to this document
			pDocument->UpdateAllViews( NULL,WM_CDEX_INITIAL_UPDATE, NULL );
		}

		g_config.SetLanguage( g_language.GetLanguage() );
		g_config.Save();

		SetLanguageMenu( );
	}
}
Exemplo n.º 20
0
HRESULT CSwatchesList::OnDraw(ATL_DRAWINFO& di)
{
	RECT& rc = *(RECT*)di.prcBounds;
	HDC hDC = di.hdcDraw;

	if (m_swatches)
	{
		Draw3DRect(hDC, m_areaRect.left-1, m_areaRect.top-1, m_areaRect.Width()+2, m_areaRect.Height()+2, RGB(0,0,0), RGB(0,0,0));

		long scrollposY; m_vert->get_pos(&scrollposY);

		if (IntersectClipRect(hDC, m_areaRect.left, m_areaRect.top, m_areaRect.right, m_areaRect.bottom))
		{
			POINT oldOrg;
			SetViewportOrgEx(hDC, m_areaRect.left, m_areaRect.top - scrollposY, &oldOrg);
		// For CMYK conversion
			/*
			TCHAR colorDirectory[MAX_PATH];
			DWORD cbSize = sizeof(colorDirectory);
			GetColorDirectory(NULL, colorDirectory, &cbSize);

			HPROFILE hDestProfile = NULL;
			{
				TCHAR profilePath[MAX_PATH];
				_makepath(profilePath, NULL, colorDirectory, "sRGB Color Space Profile.ICM", NULL);

				PROFILE profile = {0};
				profile.dwType = PROFILE_FILENAME;
				profile.pProfileData = profilePath;
				profile.cbDataSize = (_tcslen(profilePath)+1)*sizeof(TCHAR);
				hDestProfile = OpenColorProfile(&profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING);
				ATLASSERT(hDestProfile);
			}

			HPROFILE hTargetProfile = NULL;
			{
				TCHAR profilePath[MAX_PATH];
				_makepath(profilePath, NULL, colorDirectory, targetProfile, NULL);

				PROFILE profile = {0};
				profile.dwType = PROFILE_FILENAME;
				profile.pProfileData = profilePath;
				profile.cbDataSize = (_tcslen(profilePath)+1)*sizeof(TCHAR);
				hTargetProfile = OpenColorProfile(&profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING);
				ATLASSERT(hTargetProfile);
			}

			LOGCOLORSPACE lcp = {0};
			lcp.lcsSignature = LCS_SIGNATURE;
			lcp.lcsVersion = 0x400;
			lcp.lcsSize = sizeof(lcp);
			lcp.lcsCSType = LCS_sRGB;
			lcp.lcsFilename;// = NULL; // ??

			HTRANSFORM hTransform = CreateColorTransform(&lcp, hDestProfile, hTargetProfile, BEST_MODE);
			ATLASSERT(hTransform);
			*/

		// Pattern for drawing ColorType symbols
			WORD bmdata[8] =
			{
				0xaaaa,
				0x5555,
				0xaaaa,
				0x5555,
				0xaaaa,
				0x5555,
				0xaaaa,
				0x5555,
			};

			HBITMAP hPatBitmap = CreateBitmap(8, 8, 1, 1, bmdata);
			ATLASSERT(hPatBitmap);

			HBRUSH hPatBrush = CreatePatternBrush(hPatBitmap);
			ATLASSERT(hPatBrush);
			DeleteObject(hPatBitmap);

		//
			HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);

			LOGFONT lf;
			GetObject(hFont, sizeof(lf), &lf);
			lf.lfWeight = FW_BOLD;

			HFONT hFontSelected = CreateFontIndirect(&lf);
			HFONT hOldFont = (HFONT)GetCurrentObject(hDC, OBJ_FONT);

			long nswatches;
			m_swatches->get_length(&nswatches);

			int y = 0;

			for (int i = 0; i < nswatches; i++)
			{
				CComPtr<IPDSwatch> swatch;
				m_swatches->item(i, &swatch);

				//Rectangle(hDC, itemrect.left, itemrect.top, itemrect.right+1, itemrect.bottom+1);
				MoveToEx(hDC, 0, y+m_itemHeight, NULL);
				LineTo(hDC, m_areaRect.Width()+1, y+m_itemHeight);

				CRect itemrect(0, y+1, m_areaRect.Width(), y+m_itemHeight-1);
	//			itemrect.top += 1;
	//			itemrect.bottom -= 1;

				bool bSelected = IsSwatchSelected(swatch);

				if (bSelected)
					FillSolidRect(hDC, itemrect.left, itemrect.top+1, itemrect.Width(), itemrect.Height()-1, (bSelected)? GetSysColor(COLOR_HIGHLIGHT): GetSysColor(COLOR_WINDOW));

				int swatchSize = m_itemHeight-4;
				int swatchTop = (m_itemHeight-swatchSize)/2;
		//		CRect swatchRect(itemrect.left + 4, itemrect.top+itemrect.Height()/2-8, itemrect.left + 4 + 16, itemrect.top+itemrect.Height()/2-8+16);
				CRect swatchRect(itemrect.left + 4, itemrect.top+swatchTop, itemrect.left + 4 + swatchSize, itemrect.top+swatchTop+swatchSize);

				if (bSelected)
				{
					SelectObject(hDC, hFontSelected);
					SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
				}
				else
				{
					SelectObject(hDC, hFont);
					SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
				}

				SetBkMode(hDC, TRANSPARENT);

				BSTR bname;
				swatch->get_name(&bname);
				_bstr_t name = _bstr_t(bname, false);

				PDSwatchType swatchType;
				swatch->get_swatchType(&swatchType);

				CRect trect = itemrect;
				trect.left = swatchRect.right + 4;
				trect.right -= 30;

				if (swatchType == SWATCH_NONE)
				{
					FillSolidRect(hDC, &swatchRect, RGB(255, 255, 255));

					HPEN hPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
					HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);

					MoveToEx(hDC, swatchRect.left+1, swatchRect.bottom-1, NULL);
					LineTo(hDC, swatchRect.right-1, swatchRect.top+1);

					SelectObject(hDC, hOldPen);
					DeleteObject(hPen);

					HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));
					Rectangle(hDC, swatchRect.left, swatchRect.top, swatchRect.right, swatchRect.bottom);
					SelectObject(hDC, hOldBrush);
				}
				else if (swatchType == SWATCH_COLOR ||
							swatchType == SWATCH_TINT)
				{
					CComPtr<IPDColor> color;
					CComQIPtr<IPDSwatchColor> swatchColor;

					if (swatchType == SWATCH_COLOR)
					{
						swatchColor = swatch;
						swatchColor->get_color(&color);
					}
					else
					{
						CComQIPtr<IPDSwatchTint> swatchTint = swatch;
						swatchTint->get_swatchColor(&swatchColor);

						swatchTint->get_finalColor(&color);

						CRect trect2 = trect;
						trect.right -= 28;
						trect2.left = trect.right;

						double tint;
						swatchTint->get_tint(&tint);

						CUString str;
						str.Format("%d %%", (int)(tint*100));

						DrawText(hDC, str, str.GetLength(), &trect2, DT_SINGLELINE | DT_VCENTER);
					}

					PDColorMode colorMode;
					color->get_colorMode(&colorMode);

					COLORREF clr;

					if (colorMode == COLORMODE_RGB)
					{
						double red; color->getChannel(0, &red);
						double green; color->getChannel(1, &green);
						double blue; color->getChannel(2, &blue);

						clr = RGB(red, green, blue);
					}
					else if (colorMode == COLORMODE_CMYK)
					{
	/*					if (hTransform)
						{
							double cyan; color->getChannel(0, &cyan);
							double magenta; color->getChannel(1, &magenta);
							double yellow; color->getChannel(2, &yellow);
							double black; color->getChannel(3, &black);

							COLOR incolor;
							incolor.cmyk.cyan = cyan*65535/255;
							incolor.cmyk.magenta = magenta*65535/255;
							incolor.cmyk.yellow = yellow*65535/255;
							incolor.cmyk.black = black*65535/255;

							COLOR outcolor;
							BOOL bSuccess = TranslateColors(hTransform, &incolor, 1, COLOR_CMYK, &outcolor, COLOR_RGB);
							ATLASSERT(bSuccess);

							clr = RGB(
								outcolor.rgb.red*255.0/65535,
								outcolor.rgb.green*255.0/65535,
								outcolor.rgb.blue*255.0/65535);
						}
						else
						*/
							clr = -1;
					}

					if (clr != -1)
					{
						HBRUSH hBrush = CreateSolidBrush(clr);
						HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

						Rectangle(hDC, swatchRect.left, swatchRect.top, swatchRect.right, swatchRect.bottom);

						SelectObject(hDC, hOldBrush);
						DeleteObject(hBrush);
					}

					{
						CRect rc(itemrect.right-15, itemrect.top+4, itemrect.right-15+10, itemrect.top+4+10);

						if (colorMode == COLORMODE_RGB)
						{
							Rectangle(hDC, rc.left, rc.top-1, rc.right+1, rc.bottom+1);

							FillSolidRect(hDC, rc.left+1, rc.top, 3, rc.Height(), RGB(255, 0, 0));
							FillSolidRect(hDC, rc.left+4, rc.top, 3, rc.Height(), RGB(0, 255, 0));
							FillSolidRect(hDC, rc.left+7, rc.top, 3, rc.Height(), RGB(0, 0, 255));
						}
						else if (colorMode == COLORMODE_CMYK)
						{
							//
							{
								HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 255));
								HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

								POINT pts[3] =
								{
									rc.left, rc.top,
									rc.left+rc.Width(), rc.top,
									rc.left+rc.Width()/2, rc.top+rc.Height()/2,
								};

								Polygon(hDC, pts, 3);

								SelectObject(hDC, hOldBrush);
								DeleteObject(hBrush);
							}

							//
							{
								HBRUSH hBrush = CreateSolidBrush(RGB(255, 255, 0));
								HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

								POINT pts[3] =
								{
									rc.right, rc.top,
									rc.right, rc.top+rc.Height(),
									rc.right-rc.Width()/2, rc.top+rc.Height()/2,
								};

								Polygon(hDC, pts, 3);

								SelectObject(hDC, hOldBrush);
								DeleteObject(hBrush);
							}

							//
							{
								HBRUSH hBrush = CreateSolidBrush(RGB(0, 0, 0));
								HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

								POINT pts[3] =
								{
									rc.left, rc.bottom,
									rc.left+rc.Width(), rc.bottom,
									rc.left+rc.Width()/2, rc.bottom-rc.Height()/2,
								};

								Polygon(hDC, pts, 3);

								SelectObject(hDC, hOldBrush);
								DeleteObject(hBrush);
							}

							//
							{
								HBRUSH hBrush = CreateSolidBrush(RGB(0, 255, 255));
								HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

								POINT pts[3] =
								{
									rc.left, rc.top,
									rc.left, rc.top+rc.Height(),
									rc.left+rc.Width()/2, rc.top+rc.Height()/2,
								};

								Polygon(hDC, pts, 3);

								SelectObject(hDC, hOldBrush);
								DeleteObject(hBrush);
							}
						}
					}

					{
						CRect rc(m_areaRect.right-28, y+4, m_areaRect.right-28+10, y+4+10);

						PDColorType colorType;
						swatchColor->get_colorType(&colorType);

						int oldBkMode = SetBkMode(hDC, OPAQUE);
						COLORREF oldTextClr = SetTextColor(hDC, RGB(100,100,100));
						COLORREF oldBkClr = SetBkColor(hDC, RGB(255,255,255));

						if (colorType == COLORTYPE_PROCESS)
						{
							HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hPatBrush);
							Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
							SelectObject(hDC, hOldBrush);
						}
						else if (colorType == COLORTYPE_SPOT)
						{
							Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);

							HPEN hPen = CreatePen(PS_SOLID, 1, RGB(120, 120, 120));
							HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hPatBrush);
							HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);

							Ellipse(hDC, rc.left+2, rc.top+2, rc.right-2, rc.bottom-2);

							SelectObject(hDC, hOldBrush);
							SelectObject(hDC, hOldPen);
							DeleteObject(hPen);
						}
						else
							ATLASSERT(0);

						SetBkMode(hDC, oldBkMode);
						SetTextColor(hDC, oldTextClr);
						SetBkColor(hDC, oldBkClr);
					}
				}
				else if (swatchType == SWATCH_GRADIENT)
				{
					Gdiplus::Graphics graphics(hDC);

					CComQIPtr<IPDSwatchGradient> swatchGradient = swatch;

					CComPtr<IPDGradient> gradient;
					swatchGradient->get_gradient(&gradient);

					PDGradientType gradientType;
					gradient->get_type(&gradientType);

					Gdiplus::Rect rc(swatchRect.left, swatchRect.top, swatchRect.Width(), swatchRect.Height());

					CArray<Gdiplus::REAL, Gdiplus::REAL> offsets;
					CArray<Gdiplus::Color,Gdiplus::Color&> colors;

					CreateGradient(offsets, colors, gradient);

					if (gradientType == GRADIENT_LINEAR)
					{
						Gdiplus::LinearGradientBrush brush(rc, Gdiplus::Color(0,0,0), Gdiplus::Color(0,0,0), Gdiplus::LinearGradientModeHorizontal);
						brush.SetInterpolationColors(colors.GetData(), offsets.GetData(), colors.GetSize());

						graphics.FillRectangle(&brush, rc);
					}
					else if (gradientType == GRADIENT_RADIAL)
					{
						Gdiplus::GraphicsPath path;
						path.AddEllipse(rc);

						Gdiplus::PathGradientBrush brush(&path);
						brush.SetInterpolationColors(colors.GetData(), offsets.GetData(), colors.GetSize());

						graphics.FillRectangle(&brush, rc);
					}
					else
						ATLASSERT(0);
				}
				else if (swatchType == SWATCH_PATTERN)
				{
					Gdiplus::Graphics graphics(hDC);

					CComQIPtr<IPDSwatchPattern> swatchPattern = swatch;

					CComPtr<IPDObjectGroup> objectGroup;
					swatchPattern->get_objectGroup(&objectGroup);

					RectD bbox;
					objectGroup->getExpandedBBox(&bbox);

					int width = swatchRect.Width();
					int height = (bbox.Height * width/bbox.Width);//+0.5;

					if (height > swatchRect.Height())
					{
						height = swatchRect.Height();
						width = (bbox.Width * height/bbox.Height);//+0.5;
					}
					ATLASSERT(width <= bbox.Width);

					double magnify = width/bbox.Width;

					int left = (swatchRect.Width()-width)/2;
					int top = (swatchRect.Height()-height)/2;

					CComPtr<IPDRenderer> renderer;
					renderer.CoCreateInstance(CLSID_PDRenderer);
					if (renderer)
					{
						Gdiplus::Bitmap bitmap(width, height);
						{
							Gdiplus::Graphics bmgraphics(&bitmap);
							bmgraphics.FillRectangle(&Gdiplus::SolidBrush(Gdiplus::Color(255, 255, 255)), 0, 0, width, height);

						//	Gdiplus::Graphics& bmgraphics = graphics;

						//	CComQIPtr<IPDObjectTransformable> transformable = objectGroup;
						//	RectD bounds;
						//	transformable->get_bounds(&bounds);

						//	bmgraphics.TranslateTransform(swatchRect.left+left, swatchRect.top+top);

							bmgraphics.ScaleTransform(magnify, magnify);
							bmgraphics.TranslateTransform(-bbox.X, -bbox.Y);
						//	bmgraphics.TranslateTransform(-bounds.X, -bounds.Y);

							renderer->put_magnify(magnify);
							renderer->put_targetHDC((HDC)&bmgraphics);

							renderer->RenderObject(objectGroup);
						}

						graphics.DrawImage(&bitmap, swatchRect.left+left, swatchRect.top+top);
					}
				}

				DrawText(hDC, name, name.length(), &trect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);

				y += m_itemHeight;
			}

			SelectObject(hDC, hOldFont);

			DeleteObject(hFontSelected);
			DeleteObject(hPatBrush);
	/*
			if (hTransform) DeleteColorTransform(hTransform);
			if (hDestProfile) CloseColorProfile(hDestProfile);
			*/

			SetViewportOrgEx(hDC, oldOrg.x, oldOrg.y, NULL);
		}
	}

	return S_OK;
}
Exemplo n.º 21
0
void CSVGGradientEditCtl::OnButtonDown(UINT nFlags, POINT point, int iButton, BOOL bDblClk) 
{
	if (point.x > m_previewRect.left-8 && point.y < m_previewRect.right+8 &&
		point.y > m_previewRect.top && point.y < m_previewRect.bottom)
	{
		if (m_canEditStops)
		{
			POINT pt = point;
			pt.x -= m_previewRect.left;

			CComQIPtr<ILSVGStopElement> onStop;// = NULL;

			CComQIPtr<ILSVGStopElement> stop;
			m_gradient->get_firstChild((ILDOMNode**)&stop);

			CComQIPtr<ILDOMNode> beforeNode = stop;

			while (stop != NULL)
			{
				double offset;
				CComQIPtr<ILSVGAnimatedNumber> aoffset;
				stop->get_offset(&aoffset);
				aoffset->get_baseVal(&offset);

				int x = (int)(offset*m_previewRect.Width());

				if (abs(pt.x-x) < 8)
				{
					onStop = stop;
				}

				CComQIPtr<ILDOMNode> nextSibling;
				stop->get_nextSibling(&nextSibling);
				stop = nextSibling;

				if (pt.x > x)
				{
					beforeNode = stop;
				}
			}

			if (iButton == 0)
			{
				if (onStop)	// Already used
				{
	#if 0	// Have this
					CElement* pElement = m_pElement->m_pDocument->m_pTree->FindDOMElement((IDOMNode*)onStop);
					m_pElement->m_pDocument->SetTargetElement(pElement, 0);
	#endif
					m_activeStop = onStop;	// hm instead of above (change this)
				}
				else
				{
					if (beforeNode == NULL)
					{
						m_gradient->get_firstChild(&beforeNode);
					}

					CUString str;

					float offset = (float)pt.x / m_previewRect.Width();

					CComQIPtr<ILDOMDocument> document;
					m_pElement->get_ownerDocument(&document);

					CComQIPtr<ILSVGStopElement> stop;
					document->createElementNS(L"http://www.w3.org/2000/svg", L"stop", (ILDOMElement**)&stop);

					CComQIPtr<ILSVGAnimatedNumber> aoffset;
					stop->get_offset(&aoffset);
					aoffset->put_baseVal(offset);

					CComQIPtr<ILSVGStylable> stylable = stop;

					CComQIPtr<ILCSSStyleDeclaration> style;
					stylable->get_style(&style);

					str.Format("#%2.2X%2.2X%2.2X", m_colorSpread[pt.x].red, m_colorSpread[pt.x].green, m_colorSpread[pt.x].blue);
					style->setProperty(L"stop-color", _bstr_t(str), L"");

					str.Format("%g", m_colorSpread[pt.x].alpha/255.0);
					style->setProperty(L"stop-opacity", _bstr_t(str), L"");

					m_gradient->insertBefore(stop, _variant_t(beforeNode), NULL);

	#if 0	// Have this
					CElement* pElement = m_pElement->m_pDocument->m_pTree->FindDOMElement((IDOMNode*)stop);
					m_pElement->m_pDocument->SetTargetElement(pElement, 0);
	#endif
					m_activeStop = stop;	// hm instead of above (change this)
				}

				if (m_activeStop != NULL)
				{
					SetCapture();
					m_dragging = TRUE;

				//	OnMouseMove(nFlags, point);
				}
			}
			else
			{
	#if 0
				if (onStop)
				{
					m_pElement->m_pDocument->ActivateElement((CElement*)m_pElement->m_parent, 0);
					onStop->parentNode->removeChild(onStop);
				}
	#endif
			}
		}
	}
}
Exemplo n.º 22
0
STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
{
	USES_CONVERSION;

#if 0
	if (bInstall)
	{
		CComPtr<ILXUIDocument> document;
		document.CoCreateInstance(CLSID_LXUIDocument);
		if (document)
		{
			VARIANT_BOOL success;
			document->load(CComVariant(CComBSTR(pszCmdLine)), &success);
			if (success)
			{
				CComPtr<ILDOMElement> documentElement;
				document->get_documentElement(&documentElement);

				CComPtr<ILDOMElement> shellNamespace = ::GetElementByTagName(documentElement, L"shellnamespace", FALSE);
				if (shellNamespace)
				{
					CComBSTR clsidString;
					shellNamespace->getAttribute(L"clsid", &clsidString);

					CComBSTR progid;
					shellNamespace->getAttribute(L"progid", &progid);

					CComBSTR label;
					shellNamespace->getAttribute(L"label", &label);

					CComBSTR info;
					shellNamespace->getAttribute(L"info", &info);

					CString strClsidKey;
					strClsidKey.Format("CLSID\\%S", (BSTR)clsidString);
					_SetRegKey(strClsidKey, W2A(label));
					_SetRegKey(strClsidKey, W2A(info), "InfoTip");
					_SetRegKey(strClsidKey, W2A(pszCmdLine), "path");
					_SetRegKey(strClsidKey + "\\InprocServer32", "C:\\WINNT\\System32\\LXUI.dll");
					_SetRegKey(strClsidKey + "\\InprocServer32", "Apartment", "ThreadingModel");

					_SetRegKey(strClsidKey + "\\ShellFolder", NULL);
					// TODO: 'Attributes' DWORD

					_SetRegKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\" + CString("Desktop") + "\\Namespace\\" + W2A(clsidString), W2A(label));
				//	_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\ProgID", "LTesting.LTest.1");

					_SetRegKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\ShellExtensions\\Approved" + CString(W2A(clsidString)), "Sigurd");
				}
				else
				{
#if 0
					_SetRegKey("LTesting.LTest.1", "LTest Class");
					_SetRegKey("LTesting.LTest.1\\CLSID", "{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}");
					_SetRegKey("LTesting.LTest.1\\Insertable", "");

					_SetRegKey("LTesting.LTest", "LTest Class");
					_SetRegKey("LTesting.LTest\\CLSID", "{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}");
					_SetRegKey("LTesting.LTest\\CurVer", "LTesting.LTest.1");

					char* clsidString = "{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}";

					CUString str;

					str.Format("CLSID\\%s", clsidString);
					_SetRegKey(str, "LTest Class");

					_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\ProgID", "LTesting.LTest.1");

					_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\VersionIndependentProgID", "LTesting.LTest");

					_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\Programmable", NULL);

					_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\InprocServer32", "C:\\WINNT\\System32\\LXUI.dll");

					_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\InprocServer32", "Apartment", "ThreadingModel");

					_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\Control", NULL);

					_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\Insertable", NULL);

					_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\TypeLib", "{907526D5-5F3A-469D-B3F5-71FCF58B9E10}");
					//_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\MiscStatus", "1", "131473");
					//_SetRegKey("CLSID\\{06090DC5-EE21-4eca-B8AB-11FFA3F1A393}\\MiscStatus", "0");
						/*
						ProgID = s 'LHTML.LHTMLActiveDocument.1'
						VersionIndependentProgID = s 'LHTML.LHTMLActiveDocument'
						ForceRemove 'Programmable'
						InprocServer32 = s '%MODULE%'
						{
							val ThreadingModel = s 'Apartment'
						}
						ForceRemove 'Control'
						ForceRemove 'ToolboxBitmap32' = s '%MODULE%, 109'
						'MiscStatus' = s '0'
						{
							 '1' = s '131473'
						}
						'TypeLib' = s '{5F49CB47-4F80-41B2-80F0-0412BE94A52F}'
						'Version' = s '1.0'
						*/
#endif
				}
			}
		}
	}
	else
	{
	}
#endif

	return 0;
}
Exemplo n.º 23
0
void CCueSheet::CreateSheet()
{	
	LTRACE2( _T( "CCDexView::OnToolsGeneratecuesheet " ) );

	m_strCueSheet = _W( "" );

    CDInfo& cdInfo = m_pDoc->GetCDInfo();

    DWORD cdID = cdInfo.GetDiscID();

	CUString cueSheetName;
    cueSheetName.Format( _W( "%08X.cue" ), cdID );


    CUString strTmp;
	if (! cdInfo.GetGenre().IsEmpty())
    {
        strTmp.Format( _W("REM GENRE \"%s\"\n"), (LPCWSTR)cdInfo.GetGenre() );
		m_strCueSheet += strTmp;
    }

	if (! cdInfo.GetYear().IsEmpty())
    {
        strTmp.Format( _W("REM DATE %s\n"), (LPCWSTR)cdInfo.GetYear() );
		m_strCueSheet += strTmp;
    }


	strTmp.Format( _W("REM DISCID %08lx\n"), (LPCWSTR)cdInfo.GetDiscID() );
	m_strCueSheet += strTmp; 

	strTmp.Format( _W("REM VOLID %lX\n"), (LPCWSTR)cdInfo.GetVolID() );
	m_strCueSheet += strTmp; 

	strTmp.Format( _W("REM CDDBCAT %s\n"), (LPCWSTR)cdInfo.GetCDDBCat() );
	m_strCueSheet += strTmp; 

	strTmp.Format( _W("REM COMMENT \"CDex %s\"\n"), (LPCWSTR)g_config.GetVersion() );
	m_strCueSheet += strTmp; 

	m_strCueSheet += _W("REM\n");

    if ( m_addISRC.GetCheck() )
    {
        strTmp.Format(  _W("CATALOG %s\n"), (LPCWSTR)cdInfo.GetMCN() );
	    m_strCueSheet += strTmp; 
    }

	strTmp.Format( _W("PERFORMER \"%s\"\n"), (LPCWSTR)cdInfo.GetArtist());
	m_strCueSheet += strTmp; 

	strTmp.Format(  _W("TITLE \"%s\"\n"), (LPCWSTR)cdInfo.GetTitle() );
	m_strCueSheet += strTmp; 

    m_strCueSheet += _W("FILE \"range.wav\" WAVE\n" );

	int	count = 1;
	int offset = 0; // dlg.GetFirstTrack() == 0 ? cdInfo.GetStartSector(cdInfo.GetTrack( 0 )) : 0;

    for (int i = 0; i < cdInfo.GetNumTracks(); ++i, ++count)
	{
		strTmp.Format(  _W("  TRACK %02d AUDIO\n"), count );
		m_strCueSheet += strTmp; 

		strTmp.Format(  _W("    TITLE \"%s\"\n"), (LPCWSTR)cdInfo.GetTrackName( i ) );
		m_strCueSheet += strTmp; 
		
        if (g_config.GetSplitTrackName())
		{
			strTmp.Format(  _W("    PERFORMER \"%s\"\n"), (LPCWSTR)cdInfo.GetArtist());
			m_strCueSheet += strTmp; 
		}
        else
        {
			strTmp.Format(  _W("    PERFORMER \"%s\"\n"), (LPCWSTR)cdInfo.GetArtist());
			m_strCueSheet += strTmp; 
        }

        if ( m_addISRC.GetCheck() )
        {
            strTmp.Format(  _W("    ISRC %s\n"), (LPCWSTR)cdInfo.GetISRC( i ) );
		    m_strCueSheet += strTmp; 
        }

		if ( m_checkPreGaps.GetCheck() )
		{
			int dwGapSize = cdInfo.GetGap( i );

			// Calculate sectors to time
			int nF= (int)( dwGapSize % 75 );
			int nS= (int)( (dwGapSize / 75 ) %60 );
			int nM= (int)( (dwGapSize / 75 ) /60 );

			strTmp.Format(  _W("    PREGAP %02d:%02d:%02d\n"), nM, nS, nF );
			m_strCueSheet += strTmp; 
		}

		DWORD dwStart = offset + cdInfo.GetStartSector( cdInfo.GetTrack( i ) ) /*- dlg.GetFirstSector() */;

		// Calculate sectors to time
		int nF= (int)( dwStart % 75 );
		int nS= (int)( (dwStart / 75 ) %60 );
		int nM= (int)( (dwStart / 75 ) /60 );

		strTmp.Format(  _W("    INDEX 01 %02d:%02d:%02d\n"), nM, nS, nF );
		m_strCueSheet += strTmp; 
	}

    CUString strMsg( m_strCueSheet );

	strMsg.Replace( _W( "\n" ), _W( "\r\n" ) );

    CUStringConvert strCnv;
    m_editCueSheet.SetWindowText( strCnv.ToT( strMsg ) );
}
Exemplo n.º 24
0
UINT CAutoDetect::OnStartDetection(void *lpParam)
{
	bThreadActive=TRUE;
	int nInsertItem=0;
	int Endian=0;
	CUString strTmp;
	CUString strOk;
	CUString strRead;
	CUString strEbl;
	CUString strEnd;
	CUString strDens;
	CUString strAtapi;

	g_pThread->BeginWaitCursor();

	CAutoDetect* pDlg=(CAutoDetect*)lpParam;

	CDROMPARAMS cdTest;
	CR_GetCDROMParameters(&cdTest);


	CUString ReadMethodDescr[]={	_W("MMC     "),
								_W("Standard"),
								_W("Nec     "),
								_W("Sony    "),
								_W("MMC1    "),
								_W("MMC2    "),
								_W("MMC3    "),
								_W("Read C1 "),
								_W("Read C2 "),
								_W("Read C3 "),
								_W("MMC4    "),
								_W("????????")};

	CUString EnableDescr[]={		g_language.GetString( IDS_NONE ),
								g_language.GetString( IDS_STANDARD ),
								_W( "????" )};

	// Write header to Log file
	dbgFile.printf( "ATAPI\tREAD\t\tENABLE\t\t%DENS\tENDIAN\tRESULT\n" );

	for (int atapi = 0; atapi < NUMATAPI; atapi++ )
	{
		if ( 0 == atapi )
		{
			cdTest.DriveTable.bAtapi = FALSE;
			strAtapi = g_language.GetString( IDNO );
		}
		else
		{
			cdTest.DriveTable.bAtapi = TRUE;
			strAtapi = g_language.GetString( IDYES );
		}


		for (int rm = 0; rm < NUMREADMETHODS; rm++ )
		{
			strRead=ReadMethodDescr[ rm ];

			for (int en=0;en<NUMENABLEMODES;en++)
			{
				strEbl = EnableDescr[ en ];

				for (int ds=0;ds<NUMDENSITIES;ds++)
				{
					cdTest.DriveTable.nDensity = CheckDensities[ds];

					strDens.Format( _W( "%2x" ), cdTest.DriveTable.nDensity );

                    CUStringConvert strCnv;
                    CUStringConvert strCnv1;
                    CUStringConvert strCnv2;
                    CUStringConvert strCnv3;

					// Log what we are doing to file
					dbgFile.printf("%s\t%s\t%s\t%s\t",
                        strCnv.ToACP( strAtapi ),
                        strCnv1.ToACP( strRead ),
                        strCnv2.ToACP( strEbl ),
                        strCnv3.ToACP( strDens ) );

					cdTest.DriveTable.ReadMethod= READMETHOD( rm );

					switch ( cdTest.DriveTable.ReadMethod )  
					{
						case READMMC:
						case READMMC2:
						case READMMC3:
						case READMMC4:
							cdTest.DriveTable.SetSpeed= SPEEDMMC;
						break;
						case READSONY:
							cdTest.DriveTable.SetSpeed= SPEEDSONY;
						break;
						case READ10:
						case READNEC:
						case READC1:
						case READC2:
						case READC3:
						default:
							cdTest.DriveTable.SetSpeed= SPEEDNONE;
						break;
					}

					cdTest.DriveTable.EnableMode= ENABLEMODE(en);
					cdTest.DriveTable.Endian = ENDIAN_LITTLE;

					CDEX_ERR err = TestDrive( cdTest );

					strEnd = _T( "-" );

					if (err==CDEX_OK)
					{
						strOk = g_language.GetString( IDS_PASS );

						if ( ENDIAN_LITTLE == cdTest.DriveTable.Endian )
						{
							strEnd = g_language.GetString( IDS_LITTLEENDIAN );
						}
						else
						{
							strEnd = g_language.GetString( IDS_BIGENDIAN );
						}
					}
					else
					{
						strOk = g_language.GetString( IDS_FAIL );
					}


 					pDlg->m_List.InsertItem( nInsertItem, strCnv.ToT( strRead ) );
					pDlg->m_List.SetItemText( nInsertItem,1,strCnv.ToT( strAtapi ) );
					pDlg->m_List.SetItemText( nInsertItem,2,strCnv.ToT( strEbl ) );
					pDlg->m_List.SetItemText( nInsertItem,3,strCnv.ToT( strDens ) );
					pDlg->m_List.SetItemText( nInsertItem,4,strCnv.ToT( strEnd ) );
					pDlg->m_List.SetItemText( nInsertItem,5,strCnv.ToT( strOk ) );
					
					myDriveTable[nCurrentDrive++]=cdTest.DriveTable;

					ASSERT(nCurrentDrive<=nNumTableEntries);

					// Log success
					dbgFile.printf("%s\t%s\n",strEnd,strOk);

					nInsertItem++;

					::Sleep(0);

					if (pDlg->m_bAbort)
					{
						pDlg->	GetDlgItem(IDC_ABORT)->EnableWindow(FALSE);
						pDlg->GetDlgItem(IDOK)->EnableWindow(TRUE);
						g_pThread->EndWaitCursor();
						return 0;
					}
				}
			}
		}
	}

	pDlg->	GetDlgItem(IDC_ABORT)->EnableWindow(FALSE);
	pDlg->GetDlgItem(IDOK)->EnableWindow(TRUE);
	g_pThread->EndWaitCursor();

	return 0;
}
Exemplo n.º 25
0
CUString CTimeTrack::GetRemainingString()
{
	CUString strTmp;
	strTmp.Format( _W( "%02d:%02d" ), m_dwRemaining / 60, m_dwRemaining % 60 );
	return strTmp;
}
Exemplo n.º 26
0
CDEX_ERR CEncoderLameDll::OpenStream(CUString strOutFileName,DWORD dwSampleRate,WORD nChannels)
{
	CDEX_ERR bReturn = CDEX_OK;

	CUString strLang;
    CUStringConvert strCnv;

	ENTRY_TRACE( _T( "CEncoderLameDll::OpenStream( %s, %ld, %d" ),
				strCnv.ToT( strOutFileName + _W( "." ) + GetExtension() ),
				dwSampleRate,
				nChannels );


	DWORD dwInSampleRate = dwSampleRate;

	m_strStreamFileName = strOutFileName;

	// clear all config settings
	memset( &m_beConfig, 0, sizeof(m_beConfig) );

	// set the number of input channels
	m_nInputChannels = nChannels;

	// Divide sample rate by two for MPEG2
	if ( ( GetVersion() >=1 ) && ( dwInSampleRate >= 32000 ) )
	{
		m_dResampleRatio = 2.0;
		dwSampleRate = dwInSampleRate / 2;
	}

	// mask mode, just to be sure (due to an old hack)
	m_nMode &= 0x0F;

	// Do we have to downmix/upmix ?
	if ( BE_MP3_MODE_MONO == m_nMode )
	{
		if ( 2 == nChannels )
		{
			m_bDownMixToMono = TRUE;
		}
		else
		{
			m_bDownMixToMono = FALSE;
		}
	}
	else 
	{
		if ( 1 == nChannels )
		{
			m_bUpMixToStereo = TRUE;
		}
		else
			m_bUpMixToStereo=FALSE;
	}

	int	nCRC		= m_bCRC;
	int nVBR		= (nCRC>>12)&0x0F;
	int nVbrMethod	= (nCRC>>16)&0x0F;

	m_beConfig.dwConfig						= BE_CONFIG_LAME;
	m_beConfig.format.LHV1.dwStructVersion	= 1;
	m_beConfig.format.LHV1.dwStructSize		= sizeof(m_beConfig);
	m_beConfig.format.LHV1.dwSampleRate		= dwSampleRate;
	m_beConfig.format.LHV1.dwReSampleRate	= m_nOutSampleRate;
	m_beConfig.format.LHV1.nMode			= m_nMode; 
	m_beConfig.format.LHV1.dwBitrate		= m_nBitrate;
	m_beConfig.format.LHV1.dwMaxBitrate		= m_nMaxBitrate;
	m_beConfig.format.LHV1.dwMpegVersion	= (dwSampleRate>=32000)?MPEG1:MPEG2;
	m_beConfig.format.LHV1.dwPsyModel		= 0;
	m_beConfig.format.LHV1.dwEmphasis		= 0;
	m_beConfig.format.LHV1.bCRC				= nCRC&0x01;;
	m_beConfig.format.LHV1.bCopyright		= m_bCopyRight;
	m_beConfig.format.LHV1.bPrivate			= m_bPrivate;
	m_beConfig.format.LHV1.bOriginal		= m_bOriginal;

	// allways write the VBR header, even for CBR file
	m_beConfig.format.LHV1.bWriteVBRHeader	= TRUE;

	if ( nVbrMethod > 0 )
	{
		m_beConfig.format.LHV1.bEnableVBR		= TRUE;
		m_beConfig.format.LHV1.nVbrMethod		= (VBRMETHOD)(nVbrMethod-1) ;

		// is this the ABR method ?
		if ( ( VBR_METHOD_ABR + 1 ) == nVbrMethod )
		{
			// get the average bit rate
			m_beConfig.format.LHV1.dwVbrAbr_bps= LOWORD( GetUserN1() )*1000;
			m_beConfig.format.LHV1.nVBRQuality = 0 ;
		}
		else
		{
			// no ABR selected
			m_beConfig.format.LHV1.dwVbrAbr_bps = 0;
			m_beConfig.format.LHV1.nVBRQuality = nVBR ;
		}
	}

	// Get Quality from third nibble
	m_beConfig.format.LHV1.nPreset=( (nCRC >> 8 ) & 0x0F );

	m_fpOut= CID3Tag::SaveInitialV2Tag( strOutFileName + _W( "." ) + GetExtension(), GetId3V2PadSize() );
    //m_fpOut = CDexOpenFile( strOutFileName + _W( "." ) + GetExtension(), _W( "wb+" ) );

	if ( NULL == m_fpOut )
	{
		CUString strErr;

		strLang = g_language.GetString( IDS_ENCODER_ERROR_COULDNOTOPENFILE );

		strErr.Format( strLang, (LPCWSTR)CUString( strOutFileName + _W( "." ) + GetExtension() ) );

        CDexMessageBox( strErr );

		bReturn  = CDEX_FILEOPEN_ERROR;
	}


	if ( CDEX_OK == bReturn )
	{
		int nReturn = m_InitStream(	&m_beConfig,
									&m_dwInBufferSize,
									&m_dwOutBufferSize,
									&m_hbeStream );

		switch ( nReturn )
		{
			case CDEX_OK:
				// do nothing
			break;
			case -1:
				strLang = g_language.GetString( IDS_ENCODER_ERROR_SAMPLERATEBITRATEMISMATCH );
				CDexMessageBox( strLang );
				bReturn = CDEX_ERROR;
			break;
			case -2:
				strLang = g_language.GetString( IDS_ENCODER_ERROR_INVALIDINPUTSTREAM );
				CDexMessageBox( strLang );
				bReturn = CDEX_ERROR;
			break;
			default:
				strLang = g_language.GetString( IDS_ENCODER_ERROR_INVALIDINPUTSTREAM );
				CDexMessageBox( strLang );
				bReturn = CDEX_ERROR;
			break;

		}
	}

	if ( CDEX_OK == bReturn )
	{

		if ( ( GetVersion() >= 1 ) && ( dwInSampleRate >= 32000 ) )
		{
			// Add multiplcation factor for resampling
			m_dwInBufferSize *= 2;
		}

		if ( m_bDownMixToMono )
		{
			m_dwInBufferSize *= 2;
		}


		// Allocate Output Buffer size
		m_pbOutputStream = new BYTE[ m_dwOutBufferSize ];

		// Only expect halve the number of samples
		// in case we have to upsample
		if ( m_bUpMixToStereo )
		{
			// Allocate upsample Buffer size
			m_psInputStream = new SHORT[ m_dwInBufferSize ];

			m_dwInBufferSize /= 2;

		}
	}

	if ( CDEX_OK == bReturn ) 
	{
		// Initialize the input stream
		bReturn = InitInputStream();
	}


	EXIT_TRACE( _T( "CEncoderLameDll::OpenStream, return value %d" ), bReturn );

	return bReturn;
}
Exemplo n.º 27
0
void COpenFileDlg::AddRecursiveFiles( const CUString& strDir,int nItem )
{
	CFileFind	fileFind;
	CUString		pathAndFileType = strDir + CUString( _W( "\\*.*" ));
	BOOL		bStop=FALSE;

    CUStringConvert strCnv;

	// Iterate through the items in the listbox and populate the listconrol.
	if (fileFind.FindFile( strCnv.ToT( pathAndFileType ) ) )
	{
		do
		{
			bStop=(fileFind.FindNextFile()==0);
			CUString strFileName = CUString( fileFind.GetFileName() );
			CUString strFileRoot = CUString( fileFind.GetRoot() );
			CUString strFileType;

			if (	TRUE == fileFind.IsDirectory() && 
					FALSE == fileFind.IsDots() &&
					TRUE == m_bRecursiveDir )
			{
				AddRecursiveFiles( strDir + CUString( _W( "\\" ) ) + strFileName, nItem );
			}

			if (fileFind.IsDirectory()==FALSE && fileFind.IsDots()==FALSE)
			{
				int nPos=strFileName.ReverseFind( _T( '.' ) );
				

				if (nPos>0)
				{
					CUString strExt;
					strExt = strFileName.Right(strFileName.GetLength()-nPos-1);

					strFileType = strExt;

					strExt.MakeUpper();

					if ( CompareExt( strExt ) == TRUE )
					{
						CUString strFileSize;
						CUString strFileDate;
						CTime	fileTime;

						// Get the data/time stamp of this file
						fileFind.GetLastWriteTime( fileTime );

						// Format date time string
						strFileDate.Format( _W( "%4d/%02d/%02d %02d:%02d" ), fileTime.GetYear(), fileTime.GetMonth(), fileTime.GetDay(), fileTime.GetHour(), fileTime.GetMinute() );

						strFileSize.Format( _W( "%10.2f" ), fileFind.GetLength() / ( 1024.0 * 1024.0 ) );

                        CUStringConvert strCnv;

						m_ctrlRequestedFiles.InsertItem( nItem, strCnv.ToT( strFileName ));

						m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_TYPE, strCnv.ToT( strFileType ) );

						m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_DATE ,strCnv.ToT( strFileDate ) );

						m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_PATH, strCnv.ToT( strFileRoot ) );

						m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_SIZE, strCnv.ToT( strFileSize ) );

						m_ctrlRequestedFiles.SetItemData( nItem, (DWORD)fileTime.GetTime() );

						nItem++;
					}
				}
			}
		} while (bStop!=TRUE);
	}	


	m_bSortAscending=TRUE;
}
Exemplo n.º 28
0
CDEX_ERR CWAV::StripRiffWavHeader(CUString strFileName)
{
	FILE* fpIn	= CDexOpenFile( strFileName + _W( ".wav" ), _W( "rb" ) );

    if (fpIn == NULL)
	{
		CUString strLang;
		CUString strMsg;

		strLang = g_language.GetString( IDS_ERROR_COULDNOTOPENFILE );
		strMsg.Format( strLang, (LPCWSTR)( strFileName + _W( ".wav" ) ) );

        CDexMessageBox( strMsg );

		return CDEX_ERROR;
	}
	
	// Get file size;
	fseek(fpIn, 0, SEEK_END);
	int nFileSize = ftell( fpIn );
	
	
	// seek back to beginning of the file
	fseek(fpIn, 0, SEEK_SET);
	
	// read first 8 bytes
	fread( gpsSamples, 1, 8, fpIn );
	
	// check if this is a RIFF-WAVE file
	if (strstr((LPSTR)gpsSamples, "RIFF") == NULL)
	{
		CUString strLang;
		CUString strMsg;

		strLang = g_language.GetString( IDS_ERROR_NOTARIFFWAVFILE );

		strMsg.Format( strLang, (LPCWSTR)( strFileName + _W( ".wav" ) ) ); 

        CDexMessageBox( strMsg );

		fclose( fpIn );

		return CDEX_ERROR;
	}
	// read following 4 bytes
	fread(gpsSamples, 1, 4, fpIn);

	if ( NULL == strstr( (LPSTR)gpsSamples, "WAVE" ) )
	{
		CUString strLang;
		CUString strMsg;

		strLang = g_language.GetString( IDS_ERROR_NOTARIFFWAVFILE );

		strMsg.Format( strLang, (LPCWSTR)( strFileName + _W( ".wav" ) ) ); 

        CDexMessageBox( strMsg );

		fclose( fpIn );

		return CDEX_ERROR;
	}
	
	fread(gpsSamples, 1, 4 + 4, fpIn);
	
	if (strstr((LPSTR)gpsSamples, "fmt") == NULL)
	{
		CUString strLang;
		CUString strMsg;

		strLang = g_language.GetString( IDS_ERROR_COULDNOTFINDFORMATTAG );

		strMsg.Format( strLang, (LPCWSTR)( strFileName + _W( ".wav " ) ) ); 
        
        CDexMessageBox( strMsg );

		fclose( fpIn );

		return CDEX_ERROR;
	}
	
	WAVEFORMATEX wfx;
	
	// read WAVE Header
	fread(&wfx, sizeof(wfx), 1, fpIn);
	
	if (wfx.wFormatTag != WAVE_FORMAT_MPEGLAYER3 && wfx.wFormatTag != WAVE_FORMAT_MPEG)
	{
		CUString strLang;
		CUString strMsg;

		strLang = g_language.GetString( IDS_ERROR_NOTARIFFWAVFILE );

		strMsg.Format( strLang, (LPCWSTR)( strFileName + _W( ".wav" ) ) ); 

        CDexMessageBox( strMsg );

		fclose( fpIn );

		return CDEX_ERROR;
	}
	
	
	// seek data tag
	int i = 8;
	BOOL bFound = FALSE;
	
	while ((i < nFileSize) && (bFound == FALSE))
	{
		fseek(fpIn, i, SEEK_SET);
		fread(gpsSamples, 1, 4, fpIn);
		if ( NULL != strstr( (LPSTR)gpsSamples, "data" ) )
		{
			// Skip another 4 bytes for data value
			bFound = TRUE;
			fseek(fpIn, i + 8, SEEK_SET);
		}
		i++;
	}
	
	if (i>nFileSize - 4)
	{
		fclose(fpIn);
		CUString strLang;
		strLang = g_language.GetString( IDS_ERROR_DATATAGNOTFOUND );

        CDexMessageBox( strLang );

		return CDEX_ERROR;
	}
	
	// And delete the WAV file first
	CDexDeleteFile( strFileName + _W( ".mp3" ) );
	
	// Create output file
    FILE* fpOut	= CDexOpenFile( strFileName + _W( ".mp3" ), _W( "wb" ) );
	
	
	// How many samples to convert
	DWORD dwSamplesToConvert =(nFileSize - ftell(fpIn));
	
	while (dwSamplesToConvert>0)
	{
		// Determine how many byte to convert this time
		DWORD dwBlockSize = min(dwSamplesToConvert, BLOCKSIZE);
		
		// read chunck
		fread(gpsSamples, dwBlockSize, sizeof(BYTE), fpIn);
		
		// And write the byte back to the file
		fwrite(gpsSamples, dwBlockSize, sizeof(BYTE), fpOut);
		
		// Decrement the number of bytes to convert
		dwSamplesToConvert -= dwBlockSize;
	}
	
	// And close the wave file
	fclose(fpIn);
	fclose(fpOut);
	
	return CDEX_OK;
}
Exemplo n.º 29
0
long CXMiLFilesControl::CopyMoveFile(TCHAR* parentpath/*CSiteDir* pParent*/, _bstr_t filepath, VARIANT_BOOL bSilent, CProgressDlg* dlg)
{
	long nFilesCopied = 0;

	DWORD attributes = GetFileAttributes(filepath);
	TCHAR* filepart = PathFindFileName(filepath);

	TCHAR destpath[1024];
	wsprintf(destpath, "%s/%s", parentpath, filepart);

	if (attributes & FILE_ATTRIBUTE_DIRECTORY)
	{
		long folder_id = m_filesystem->FindOrCreateFolder(_bstr_t(destpath), L"");

		if (folder_id)
		{
			HANDLE hFindFile;
			WIN32_FIND_DATA	wfd;

			char	search[MAX_PATH];
			wsprintf(search, "%S\\*.*", (BSTR)filepath);

			if ((hFindFile = FindFirstFile(search, &wfd)) != INVALID_HANDLE_VALUE)
			{
				do
				{
					if (wfd.cFileName[0] != '.')
					{
						char pathName[_MAX_PATH];
						_makepath(pathName, NULL, filepath, wfd.cFileName, NULL);

						nFilesCopied += CopyMoveFile(destpath /*pParentDir*/, pathName, bSilent, dlg);

#if 0
						if (dlg)
						{
							if (dlg->m_bCancel) break;
						}
#endif
					}
				}
				while (FindNextFile(hFindFile, &wfd));

				FindClose(hFindFile);
			}
		}
		else
		{
			if (!bSilent)
			{
				CUString str;
				str.Format("Couldn't create folder %S", (BSTR)filepath);
				::MessageBox(m_hWnd, str, "LXFramework", MB_OK);
			}
		}
	}
	else
	{
		SAFEARRAY* dataArray = NULL;
		long dataSize = 0;

		FILE* fp = fopen(filepath, "rb");
		if (fp)
		{
			fseek(fp, 0, SEEK_END);
			dataSize = ftell(fp);
			fseek(fp, 0, SEEK_SET);

			dataArray = SafeArrayCreateVector(VT_UI1, 0, dataSize);
			if (dataArray)
			{
				fread((dataArray)->pvData, 1, dataSize, fp);
			}

			fclose(fp);
		}
		else
		{
			if (!bSilent)
			{
				CUString str;
				str.Format("Couldn't open %S", (BSTR)filepath);
				::MessageBox(m_hWnd, str, "LXFramework", MB_OK);
			}
		}

		if (dataArray)
		{
			long file_id;
			try
			{
				m_filesystem->SaveArrayAsFile(_bstr_t(destpath), dataArray, L"", &file_id);

				nFilesCopied++;
			}
			catch (_com_error &e)
			{
				if (!bSilent)
				{
					CUString str;
					str.Format("Failed to copy %s", filepart);
					::MessageBox(m_hWnd, str, "LXFramework", MB_OK);
				}
			}

			SafeArrayDestroy(dataArray);
		}

#if 0
		if (dlg)
		{
			dlg->m_pos += dataSize/10;
			dlg->Invalidate();

			MSG msg;
			while (PeekMessage(&msg, dlg->m_hWnd, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
#endif
	}

	return nFilesCopied;
}