Files
SimpleRemoter/server/2015Remote/SettingDlg.cpp
yuanyuanxiang 135a3439d1 修复文件管理对话框崩溃的缺陷
非模态的文件管理对话框在关闭时需要析构,但是这导致2次打开后再关闭时崩溃,该缺陷已修复。
2019-01-11 21:40:11 +08:00

99 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SettingDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "2015Remote.h"
#include "SettingDlg.h"
#include "afxdialogex.h"
// CSettingDlg 对话框
IMPLEMENT_DYNAMIC(CSettingDlg, CDialog)
CSettingDlg::CSettingDlg(CWnd* pParent)
: CDialog(CSettingDlg::IDD, pParent)
, m_nListenPort(0)
, m_nMax_Connect(0)
{
}
CSettingDlg::~CSettingDlg()
{
}
void CSettingDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_PORT, m_nListenPort);
DDX_Text(pDX, IDC_EDIT_MAX, m_nMax_Connect);
DDX_Control(pDX, IDC_BUTTON_SETTINGAPPLY, m_ApplyButton);
}
BEGIN_MESSAGE_MAP(CSettingDlg, CDialog)
ON_BN_CLICKED(IDC_BUTTON_SETTINGAPPLY, &CSettingDlg::OnBnClickedButtonSettingapply)
ON_EN_CHANGE(IDC_EDIT_PORT, &CSettingDlg::OnEnChangeEditPort)
ON_EN_CHANGE(IDC_EDIT_MAX, &CSettingDlg::OnEnChangeEditMax)
END_MESSAGE_MAP()
// CSettingDlg 消息处理程序
BOOL CSettingDlg::OnInitDialog()
{
CDialog::OnInitDialog();
int nPort = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("Settings", "ListenPort");
//读取ini 文件中的监听端口
int nMaxConnection = ((CMy2015RemoteApp*)AfxGetApp())->m_iniFile.GetInt("Settings", "MaxConnection");
m_nListenPort = nPort;
m_nMax_Connect = nMaxConnection;
UpdateData(FALSE);
return TRUE;
}
void CSettingDlg::OnBnClickedButtonSettingapply()
{
UpdateData(TRUE);
((CMy2015RemoteApp *)AfxGetApp())->m_iniFile.SetInt("Settings", "ListenPort", m_nListenPort);
//向ini文件中写入值
((CMy2015RemoteApp *)AfxGetApp())->m_iniFile.SetInt("Settings", "MaxConnection", m_nMax_Connect);
m_ApplyButton.EnableWindow(FALSE);
m_ApplyButton.ShowWindow(SW_HIDE);
}
void CSettingDlg::OnEnChangeEditPort()
{
// TODO: 如果该控件是 RICHEDIT 控件,它将不
// 发送此通知,除非重写 CDialog::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask()
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
// 给Button添加变量
m_ApplyButton.ShowWindow(SW_NORMAL);
m_ApplyButton.EnableWindow(TRUE);
}
void CSettingDlg::OnEnChangeEditMax()
{
// TODO: 如果该控件是 RICHEDIT 控件,它将不
// 发送此通知,除非重写 CDialog::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask()
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
HWND hApplyButton = ::GetDlgItem(m_hWnd,IDC_BUTTON_SETTINGAPPLY);
::ShowWindow(hApplyButton,SW_NORMAL);
::EnableWindow(hApplyButton,TRUE);
}