Question

How do I get cursor when dialog is start at OnInitDialog function,

without user to move click it, like as follow pic

enter link description here


Other problem is, when the editbox already fill with text, how do I select the text ?

Was it helpful?

Solution

On OnInitDialog function, I see as follow description,

// return TRUE unless you set the focus to a control

so I define a variable to the editbox, the set focus on it,

then return false in OnInitDialog function.

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
}

For select whole text method is as follow

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top