0

I am using the default CButton and created 3 buttons programmatically..

BOOL CTestDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    CRect rect;


    GetClientRect(&rect);

    CRect btnRect = CRect(rect.left+50,100,rect.left+150,150);
    button1.Create(_T("ONE"),BS_FLAT | WS_VISIBLE,btnRect,this,1); 

    btnRect.MoveToX(200);
    button2.Create(_T("TWO"),BS_FLAT | WS_VISIBLE,btnRect,this,2); 


    btnRect.MoveToX(350);
    button3.Create(_T("THREE"),BS_FLAT | WS_VISIBLE,btnRect,this,3); 



    return TRUE;  
}

If i see the O/P, always the Buton ONE is highlighted and no TAB is working.

How to support TAB order and how to change the focus. Can someone please help.

Thanks

4

1 回答 1

1

You've created the buttons without the necessary windows styles.

From MSDN:

Apply the following window styles to a button control:

  • WS_CHILD Always

  • WS_VISIBLE Usually

  • WS_DISABLED Rarely

  • WS_GROUP To group controls

  • WS_TABSTOP To include the button in the tabbing order

于 2015-03-03T13:27:00.427 回答