在 OnInitDialog 函数处启动对话框时如何获取光标,
没有用户移动点击它,如下图
另一个问题是,当编辑框已经填充了文本时,我该如何选择文本?
在 OnInitDialog 函数上,我看到如下描述,
// return TRUE unless you set the focus to a control
所以我为编辑框定义了一个变量,将焦点放在它上面,
然后在 OnInitDialog 函数中返回 false。
BOOL CInputTestPoint::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此加入額外的初始化
m_editTestPointName.SetFocus();
//return TRUE; // return TRUE unless you set the focus to a control
return false;
// EXCEPTION: OCX 屬性頁應傳回 FALSE
}
对于选择全文方法如下
define CEdit to the edit box and m_editTestPointName.SetSel(0, strTestPointName.GetLength(), true);
((CEdit *)GetDlgItem(IDC_EDIT_INPUT_TP))->SetSel(0, strTestPointName.GetLength(), true);