⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parameter.cpp

📁 该源代码实现了局域网内的信息传递、文件传输
💻 CPP
字号:
// Parameter.cpp : implementation file
//

#include "stdafx.h"
#include "BQQ.h"
#include "Parameter.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CParameter dialog


CParameter::CParameter(CWnd* pParent /*=NULL*/)
	: CDialog(CParameter::IDD, pParent)
{
	//{{AFX_DATA_INIT(CParameter)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CParameter::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CParameter)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CParameter, CDialog)
	//{{AFX_MSG_MAP(CParameter)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CParameter message handlers

void CParameter::OnOK() 
{
	// TODO: Add extra validation here
	int autoRun= 0,autoSave = 0,audio = 0,onTop = 0,p= 0,tips=0,autoRestart=0;
	HKEY RegEntry;
	int open = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_AUTO_RUN, 0, KEY_SET_VALUE, &RegEntry);
	if((p=((CButton*)GetDlgItem(IDC_AUTORUN))->GetCheck())==1)
	{
		autoRun= 1;
		TCHAR fileName[MAX_BUFFER_SIZE+1];
		GetModuleFileName(GetModuleHandle(AfxGetApp()->m_pszAppName), fileName, MAX_BUFFER_SIZE );
		int setval = RegSetValueEx(RegEntry, KEY_PROGRAM, 0, REG_SZ, (LPBYTE)fileName, strlen(fileName)) ;
	}
	else	// delete key
		RegDeleteValue(RegEntry, KEY_PROGRAM);
		RegCloseKey(RegEntry); 
	if((p=((CButton*)GetDlgItem(IDC_AUTORUN))->GetCheck())==1)
		autoRun = 1;
	if((p=((CButton*)GetDlgItem(IDC_AUTOSAVE))->GetCheck())==1)
		autoSave = 1;
	if((p=((CButton*)GetDlgItem(IDC_AUDIO))->GetCheck())==1)
		audio = 1;
	if((p=((CButton*)GetDlgItem(IDC_TIPS))->GetCheck())==1)
		tips = 1;
	if((p=((CButton*)GetDlgItem(IDC_RESTARTSERV))->GetCheck())==1)
		autoRestart = 1;
	int x = ::GetSystemMetrics(SM_CXMAXIMIZED);
	int y =  ::GetSystemMetrics(SM_CYMAXIMIZED);
	if((p=((CButton*)GetDlgItem(IDC_TOPMOST))->GetCheck())==1)
	{
		onTop = 1;
		((CBQQApp*)AfxGetApp())->m_pMainWnd->SetWindowPos(&CWnd::wndTopMost,x/4,y/4,0,0,SWP_NOSIZE);
	}
	else
		((CBQQApp*)AfxGetApp())->m_pMainWnd->SetWindowPos(&CWnd::wndNoTopMost,x/4,y/4,0,0,SWP_NOSIZE);
	((CBQQApp*)AfxGetApp())->WriteProfileInt("privatesetting","autorun",autoRun);
	((CBQQApp*)AfxGetApp())->WriteProfileInt("privatesetting","autoSave",autoSave);
	((CBQQApp*)AfxGetApp())->WriteProfileInt("privatesetting","audio",audio);
	((CBQQApp*)AfxGetApp())->WriteProfileInt("privatesetting","onTop",onTop);
	((CBQQApp*)AfxGetApp())->WriteProfileInt("privatesetting","Tips",tips);
	((CBQQApp*)AfxGetApp())->WriteProfileInt("privatesetting","autoRestart",autoRestart);
	CDialog::OnOK();
}

BOOL CParameter::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	int autoRun= 0,autoSave = 0,audio = 0,onTop = 0,p= 0,tips=0,autoRestart=0;
	autoRun = ((CBQQApp*)AfxGetApp())->GetProfileInt("privatesetting","autorun",0);
	autoSave =((CBQQApp*)AfxGetApp())->GetProfileInt("privatesetting","autoSave",2);
	audio =((CBQQApp*)AfxGetApp())->GetProfileInt("privatesetting","audio",0);
	onTop =((CBQQApp*)AfxGetApp())->GetProfileInt("privatesetting","onTop",0);
	tips=((CBQQApp*)AfxGetApp())->GetProfileInt("privatesetting","Tips",0);
	autoRestart=((CBQQApp*)AfxGetApp())->GetProfileInt("privatesetting","autoRestart",2);
	if(autoRun==1)
		((CButton*)GetDlgItem(IDC_AUTORUN))->SetCheck(BST_CHECKED);
	if(autoSave>0)
		((CButton*)GetDlgItem(IDC_AUTOSAVE))->SetCheck(BST_CHECKED);
	if(audio==1)
		((CButton*)GetDlgItem(IDC_AUDIO))->SetCheck(BST_CHECKED);
	if(onTop==1)
		((CButton*)GetDlgItem(IDC_TOPMOST))->SetCheck(BST_CHECKED);
	if(tips==1)
		((CButton*)GetDlgItem(IDC_TIPS))->SetCheck(BST_CHECKED);
	if(autoRestart>0)
		((CButton*)GetDlgItem(IDC_RESTARTSERV))->SetCheck(BST_CHECKED);
	((CButton*)GetDlgItem(IDC_HTKET))->SetCheck(BST_CHECKED);
	((CButton*)GetDlgItem(IDC_AUDIO))->SetCheck(BST_CHECKED);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -