문제

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 ?

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top