问题描述
我有在MFC中编写的对话框应用程序。
对话框上有3个子控件。
2按钮(按钮1&按钮2)和HTML控件(从CHtmlView派生的类)
HTML控件已导航到具有2个复选框的HTML页面(复选框1和复选框2) 。
控制焦点的Z轴顺序应该是:
按钮1
按钮2
HTML控件,然后再次按钮1
当焦点转到HTML控件时。我想把它设置为复选框1&然后在按Tab键之后,它将被设置为复选框2.
但是当我按下选项卡时焦点在复选框2,我想将其设置为按钮1。
ie
我想要的焦点循环如下:按钮1 - >按钮2 - >在HTML控制中的复选框1 - > HTML控制中的复选框2 - >然后再次按钮1
问题:
当焦点设置为HTML控件时,它不会设置为复选框1,并且在焦点对准时按下选项卡后复选框2焦点不
返回按钮1。
让我知道如果问题不够描述,我会简化它。
感谢您的时间。
我无法测试,但可以尝试将WS_EX_CONTROLPARENT样式添加到HTML控制。
int OnInitDialog(...)
{
HWND html = GetDlgItem ID_HTML);
DWORD ex_style = GetWindowLong(html,GWL_EXSTYLE);
SetWindowLong(html,GWL_EXSTYLE,ex_tyle | WS_EX_CONTROLPARENT);
return 0;
}
我希望它能工作。
I am having Dialog Box Application written in MFC.Dialog is having 3 child controls on it.2 Buttons (Button 1 & Button 2) and a HTML Control (Class derived from CHtmlView)HTML Control has been navigated to a HTML page having 2 checkboxes (Check Box 1 & Check Box 2).
Control Z-Order for focus should be like:Button 1Button 2HTML Control then again Button 1
When focus goes to HTML Control. I want it to set to Check Box 1 & then after pressing tab it will be set to Check Box 2.But When I press tab while the focus in on Check Box 2, I want it to set to Button 1.
i.e.I want focus cycle like : Button 1 -> Button 2 -> Check Box 1 in HTML Control -> Check Box 2 in HTML Control -> then again Button 1
Problem:When the focus is set to HTML Control, it doesn't get set to Check Box 1 and after pressing tab while focus is on Check Box 2 focus doesn'tcome back to Button 1.
Let me know if question is not descriptive enough, I will simplify it more.Appreciate your time.
I can't test it but you may try to add the WS_EX_CONTROLPARENT style to the HTML control.
int OnInitDialog(...)
{
HWND html = GetDlgItem(dialog, ID_HTML);
DWORD ex_style = GetWindowLong(html, GWL_EXSTYLE);
SetWindowLong(html, GWL_EXSTYLE, ex_tyle | WS_EX_CONTROLPARENT);
return 0;
}
I hope it works.
这篇关于CHtmlView类和焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!