请大侠赐教:为什么CPropertySheet类为什么显示以后切换到别的程序后在回来就显示不出来了我的测试环境是:vc6.0在模式对话框中嵌入了一个CPropertySheet类的对象
添加完页后,用
m_ps->Create(this , WS_CHILD );
m_ps->MoveWindow(&rect,TRUE);
m_ps->ShowWindow(SW_SHOW);
显示之,可是如果不切换程序没有任何问题,但是如果切换了其他的程序后就显示不出来了
请牛人帮忙指点,怎样解决这个问题!
添加完页后,用
m_ps->Create(this , WS_CHILD );
m_ps->MoveWindow(&rect,TRUE);
m_ps->ShowWindow(SW_SHOW);
显示之,可是如果不切换程序没有任何问题,但是如果切换了其他的程序后就显示不出来了
请牛人帮忙指点,怎样解决这个问题!
Originally posted by: Sergey Kostrov
I would like to describe how to solve the problem related with CPropertySheet class, WS_EX_CONTROLPARENT style, and ActiveX. For more information you need to look at Microsoft's article: Q149501:
"PRB: Child CPropertySheet Hangs If Focus Is Switched" So, a couple of days ago I've started to design ActiveX control with propery pages, and of course, I've descovered this problem. Microsoft's Q149501 article describes solution of the problem, but unfortunately it doesn't work. Microsoft has suggested to make the following: RESOLUTION
Override OnInitDialog() for the child CPropertySheet,
and add the WS_EX_CONTROLPARENT style. Here is an example of code from Microsoft: // CMySheet is derived from CPropertySheet
BOOL CMySheet::OnInitDialog()
{
ModifyStyleEx (0, WS_EX_CONTROLPARENT);
return CPropertySheet::OnInitDialog();
} Once again, it doesn't work! Here is my proposals how to solve the problem: Step 1 - you need to make almost the same like Microsoft's proposal, but with small exception. That is, first should be a call of
CPropertySheet::OnInitDialog()
then a call of
ModifyStyleEx( 0, WS_EX_CONTROLPARENT ) BOOL CVsiPps::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog(); ModifyStyleEx( 0, WS_EX_CONTROLPARENT ); return bResult;
} Step 2 - you need to modify extended style of your ActiveX control. It should look like this: BOOL CVsiControlsCtrl::PreCreateWindow( CREATESTRUCT& cs )
{
cs.lpszClass = _T("STATIC"); cs.dwExStyle |= WS_EX_CONTROLPARENT; return COleControl::PreCreateWindow(cs);
} It works and I hope it'll help to everyone. Sincerely,
Sergey Kostrov
PRB: Child CPropertySheet Hangs If Focus Is Switched
ID: Q149501The information in this article applies to:The Microsoft Foundation Class, version 1.0
Microsoft Visual C++, 32-bit Editions, version 4.0a--------------------------------------------------------------------------------
SYMPTOMS
If a modeless CPropertySheet is a child of a CDialog or another CPropertySheet, the program will hang in the following situations: The focus is switched back to a PropertyPage that previously had the focus.
The focus is placed on a control on a PropertyPage, and then the focus is switched to another window (for example, Program Manager).
The focus is on a control on a PropertyPage and the PropertySheet is closed.
The program hangs because the child CPropertySheet continuously receives a WM_GETDLGCODE message. CAUSE
By default, CPropertyPages have a WS_EX_CONTROLPARENT style. However, CPropertySheets do not have this style. This style allows a user to press the TAB key to move from a control inside the page to one in the sheet. When the focus is switched from the CPropertyPage, code that handles default command buttons loops through all the controls in the pages and the sheet. Cycling through controls is done using GetNextDlgTabItem(). The loop cycles through controls in the page in the child CPropertySheet and finds its way to controls in the parent page or parent dialog. At this point, GetNextDlgTabItem() is not able to find controls inside the child CPropertySheet because it doesn't have a WS_EX_CONTROLPARENT style. The loop never ends because it never finds the original control that had the focus. RESOLUTION
Override OnInitDialog() for the child CPropertySheet, and add the WS_EX_CONTROLPARENT style. STATUS
This is a problem with the implementation of the Property Sheet common control, and not MFC's CPropertySheet wrapper. MORE INFORMATIONSample Code // CMySheet is derived from CPropertySheet
BOOL CMySheet::OnInitDialog()
{
ModifyStyleEx (0, WS_EX_CONTROLPARENT);
return CPropertySheet::OnInitDialog();
} /* Compile options needed: default
*/ Additional query words: WS_CHILD Property Sheet lock freeze page modal Keywords : kbMFC kbPropSheet KbUIDesign kbVC kbGrpMFCATL
Version : WINDOWS:1.0; winnt:4.0a
Platform : WINDOWS winnt
Issue type : kbprb
Technology : kbvc