我使用默认的 CButton 并以编程方式创建了 3 个按钮..
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;
}
如果我看到 O/P,总是突出显示 Buton ONE,并且没有 TAB 正在工作。
如何支持TAB顺序以及如何改变焦点。有人可以帮忙吗。
谢谢
最佳答案
您创建的按钮没有必要的 windows 样式。
来自 MSDN :
Apply the following window styles to a button control:
总是 WS_CHILD
WS_VISIBLE 通常
WS_DISABLED 很少
WS_GROUP 对控件进行分组
WS_TABSTOP 将按钮包含在 Tab 键顺序中
关于c++ - MFC:以编程方式控制 TAB 顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28827394/