CHtmlView class and focus

╄→гoц情女王★ 提交于 2019-12-11 14:25:03

问题


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 1 Button 2 HTML 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't come back to Button 1.

Let me know if question is not descriptive enough, I will simplify it more. Appreciate your time.


回答1:


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.



来源:https://stackoverflow.com/questions/3458936/chtmlview-class-and-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!