📄 richimp3.cpp
字号:
// RichiMP3.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "RichiMP3.h"
#include "RichiMP3Dlg.h"
#include <io.h>
#include <direct.h>
#include "GWExtTransSplashWnd.h"
#include <stdlib.h>
#include <fstream.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRichiMP3App
BEGIN_MESSAGE_MAP(CRichiMP3App, CWinApp)
//{{AFX_MSG_MAP(CRichiMP3App)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRichiMP3App construction
CRichiMP3App* GetApp()
{
return (CRichiMP3App*) AfxGetApp();
}
CRichiMP3App::CRichiMP3App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
POSITION pos=m_PictureList.GetHeadPosition();
while(pos!=NULL)
delete m_PictureList.GetNext(pos);
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CRichiMP3App object
CRichiMP3App theApp;
/////////////////////////////////////////////////////////////////////////////
// CRichiMP3App initialization
BOOL CRichiMP3App::InitInstance()
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Parse the command line to see if launched as OLE server
if (RunEmbedded() || RunAutomated())
{
// Register all OLE server (factories) as running. This enables the
// OLE libraries to create objects from other applications.
COleTemplateServer::RegisterAll();
}
else
{
// When a server application is launched stand-alone, it is a good idea
// to update the system registry in case it has been damaged.
COleObjectFactory::UpdateRegistryAll();
}
CoInitialize(0);
ReadData();// support to use direct Sound
GWExtTransSplashWnd * pSplashWnd = new GWExtTransSplashWnd(IDB_SPLASH,TRUE,RGB(0,0,0), 3000);
pSplashWnd->Create();
CRichiMP3Dlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
int CRichiMP3App::ExitInstance()
{
CoUninitialize();
WriteData();
return CWinApp::ExitInstance();
}
BOOL CRichiMP3App::PreTranslateMessage(MSG* pMsg)
{
// CG: The following lines were added by the Splash Screen component.
// if (CSplashWnd::PreTranslateAppMessage(pMsg))
//return TRUE;
return CWinApp::PreTranslateMessage(pMsg);
}
void CRichiMP3App::WriteData()
{
CString m_sPath;
CString str=theApp.m_pszHelpFilePath;
m_sPath=str.Left(str.ReverseFind('\\'));
::SetCurrentDirectory(m_sPath);
//
CString string;
string = m_sPath + "\\mp3.m3u";
CFile fi;
if(fi.Open(string,CFile::modeCreate|CFile::modeWrite))
{
fi.Close();
}
Write(string);
}
void CRichiMP3App::ReadData()
{
m_PictureList.RemoveAll();
CString m_sPath;
CString str=theApp.m_pszHelpFilePath;
m_sPath=str.Left(str.ReverseFind('\\'));
::SetCurrentDirectory(m_sPath);
CString string;
string = m_sPath +"\\mp3.m3u";
Read(string);
}
bool CRichiMP3App::Read(const char * cFileName)
{
char buf[1024];
ifstream ifs(cFileName);
while (ifs.good())
{
ifs.getline(buf, 1024);
CString cs(buf);
if(!cs.IsEmpty())
{
CPictureObject *pObj = new CPictureObject;
pObj->SetFileName(cs);
AddPictureObject(pObj);
}
}
return true;
}
bool CRichiMP3App::Write(const char * cFileName)
{
ASSERT(cFileName);
ofstream ofs(cFileName);
POSITION pos = m_PictureList.GetHeadPosition();
while(pos != NULL)
{
CPictureObject *pObj = (CPictureObject *)m_PictureList.GetNext(pos);
ofs <<pObj->GetFileName()<<"\n";
}
return true;
}
void CRichiMP3App::AddPictureObject(CPictureObject *pObj)
{
m_PictureList.AddTail(pObj);
}
void CRichiMP3App::RemovePictureObject(CPictureObject *pObj)
{
POSITION posi=m_PictureList.Find(pObj);
if(posi!=NULL)
m_PictureList.RemoveAt(posi);
}
void CRichiMP3App::ResetSelectObject()
{
m_PictureList.RemoveAll();
}
void CRichiMP3App::WinHelp(DWORD dwData, UINT nCmd)
{
if (nCmd == HELP_INDEX || nCmd == HELP_CONTENTS)
nCmd = HELP_FINDER;
CWinApp::WinHelp(dwData, nCmd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -