MFC 随笔

1.Radio和CheckBox状态设置与判定

设置方法比较统一

int state =((CButton *)GetDlgItem(IDC_CHECK1))->GetCheck();
((CButton *)GetDlgItem(IDC_CHECK1))->SetCheck(TRUE);

2.Edit Control 设置

SetDlgItemText(IDC_EDIT1,10);

3.分割线

将PictureCtrl控件拉成直线,color选项选etched就好了。

4.控件Enable和disable

((CButton *)GetDlgItem(IDC_CHECK1))->EnableWindow(TRUE); //可用
((CButton *)GetDlgItem(IDC_CHECK1))->EnableWindow(False); //不可用

5.RadioBox分组

  1. 设置Tab序号

首先按Ctrl+D,调出空间的Tab顺序。
同组的Ctrl+D,必须连号如18-21所示,35-38。
不同组的无所谓。
在这里插入图片描述

  1. 设置radiobox

设置 radio35 的 属性:group、auto均为true

设置 radio36 的 属性: group设为false, auto均为true

设置 radio37 的 属性:group设为false, auto均为true

设置 radio38 的 属性: group设为false,auto均为true

设置 radio18 的 属性:group、auto均为true

设置 radio19 的 属性: group设为false, auto均为true

设置 radio20 的 属性:group设为false, auto均为true

设置 radio21 的 属性: group设为false,auto均为true

  1. 添加控件对应的变量m_radio_firdir
    在这里插入图片描述

  2. 添加实现函数

添加第一个Radio对应的代码。其他三个Radio同样的复制。

在这里插入图片描述


void CMyDialog::OnBnClickedRadioFir()
{
	UpdateData(TRUE);
	switch (m_radio_firdir)
	{
	case 0:;;
	case 1:
		((CButton*)GetDlgItem(IDC_RADIOXZ2))->EnableWindow(false);
		((CButton*)GetDlgItem(IDC_RADIOXF2))->EnableWindow(false);
		((CButton*)GetDlgItem(IDC_RADIOYZ2))->EnableWindow(TRUE);
		((CButton*)GetDlgItem(IDC_RADIOYF2))->EnableWindow(TRUE);
		break;
	case 2:
	case 3:
		((CButton*)GetDlgItem(IDC_RADIOXZ2))->EnableWindow(TRUE);
		((CButton*)GetDlgItem(IDC_RADIOXF2))->EnableWindow(TRUE);
		((CButton*)GetDlgItem(IDC_RADIOYZ2))->EnableWindow(false);
		((CButton*)GetDlgItem(IDC_RADIOYF2))->EnableWindow(false);
		break;
	default:
		break;
	}
}

6.ini配置文件

在当前文件目录下入文件。VS2010不需要_T()宏,VS2013及以上需要。
要有“.\”。才能在当前目录下配置文件。

CString isRaw = "1";
WritePrivateProfileString("Launch_PointScan", "isRaw", isRaw,".\\Launch_PointScan.ini");

7.exe重启

猜你喜欢

转载自blog.csdn.net/CoomCon/article/details/103245420
MFC