📄 setparam.cpp
字号:
// SetParam.cpp : implementation file
//
#include "stdafx.h"
#include "FileTransClt.h"
#include "SetParam.h"
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetParam dialog
CSetParam::CSetParam(CWnd* pParent /*=NULL*/)
: CDialog(CSetParam::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetParam)
//}}AFX_DATA_INIT
}
void CSetParam::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetParam)
DDX_Text(pDX, IDC_EDIT_PATH, m_defPath);
DDX_Text(pDX, IDC_DOWNTHEADNUM, m_threadNum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetParam, CDialog)
//{{AFX_MSG_MAP(CSetParam)
ON_BN_CLICKED(IDOK, OnSet)
ON_BN_CLICKED(IDC_BTN_VIEW, OnView)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetParam message handlers
void CSetParam::OnSet()
{
// TODO: Add your control notification handler code here
UpdateData(true);
CString strFormat;
strFormat.Format( "%d",m_threadNum );
WritePrivateProfileString( "paramsetting","threadsintotal",strFormat,"C:\\Settings.ini" );
CDialog::OnOK();
}
void CSetParam::OnView()
{
UpdateData(true);
TCHAR path[80];
BROWSEINFO browInfo = {0};
browInfo.lpszTitle = "Setting default path...";
LPITEMIDLIST selItem=SHBrowseForFolder( &browInfo );
if( selItem != NULL )
{
// get the name of the folder and put it in path
SHGetPathFromIDList ( selItem, path );
//Set the current directory to path
SetCurrentDirectory ( path );
m_defPath.Format( "%s",CharToStr( path ) );
WritePrivateProfileString( "paramsetting","defaultsavepath",m_defPath,"C:\\Settings.ini" );
UpdateData(false);
}
}
BOOL CSetParam::OnInitDialog()
{
CDialog::OnInitDialog();
m_threadNum = CSetParam::GetDefThrTotal();
m_defPath = CSetParam::GetDefSavePath();
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
LRESULT CSetParam::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::WindowProc(message, wParam, lParam);
}
CString CSetParam::CharToStr(char* p)
{
CString str;
int i=0;
while( p[i] )
{
str.Insert( i,p[i] );
i++;
}
return str;
}
int CSetParam::GetDefThrTotal()
{
int threadNum;
char* pTemp;
pTemp = new char[80];
GetPrivateProfileString( "paramsetting","threadsintotal","0",pTemp,2,"C:\Settings.ini" );
threadNum = atoi(pTemp);
if( threadNum == 0 )
threadNum = 3;
return threadNum;
}
CString CSetParam::GetDefSavePath()
{
CString defPath;
char* pTemp;
pTemp = new char[80];
GetPrivateProfileString( "paramsetting","defaultsavepath","defaultpath",pTemp,80,"C:\Settings.ini");
defPath = CharToStr(pTemp);
if( defPath== "defaultpath" )
defPath = "C:\\";
return defPath;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -