Property Sheets and ActiveX controls
Carlos Carvajal -- carvajal@platinum.com Friday, November 01, 1996 Environment: Windows 95, VC++ 4.2b I am trying to popup a CPropertySheet from an ActiveX control. When I use VC++ 4.0 everything is fine. If I use VC++ 4.2 I get an assertion failure when the propertysheets DoModal is ending. I traced into the MFC code and found the the propertysheets parent window variable was getting plastered. So when the propertysheet was erasing itself and trying to reenable its parent an ASSERT_VALID on its parent failed. If I replace the propertysheet with a dialog it is fine, or if I place the propertysheet into a view it is also fine. I have fixed the problem for the moment by building my own property sheet that inherits from CPropertySheet and overloads the DoModal. I copied the DoModal code from the CPropertySheet but added some code to it to make a copy of the parent pointer and use the copy instead of the member variable that gets plastered. Is there a fix for this, or am I doing something else wrong?
Mike Blaszczak -- mikeblas@nwlink.com Sunday, November 03, 1996 At 07:37 11/1/96 -0600, "Carlos Carvajal"wrote: >Environment: Windows 95, VC++ 4.2b >I am trying to popup a CPropertySheet from an ActiveX control. When I use >VC++ 4.0 everything is fine. If I use VC++ 4.2 I get an assertion failure >when the propertysheets DoModal is ending. > [...] >Is there a fix for this, or am I doing something else wrong? It's really impossible to tell. You've not explained how you're bringing up the controls property sheet, so there's just no way to know if what you're doing is correct or not--you don't show us what you're doing! .B ekiM http://www.nwlink.com/~mikeblas/ I'm afraid I've become some sort of speed freak. These words are my own. I do not speak on behalf of Microsoft.
Allan Dystrup -- and@kmd.dk Tuesday, November 05, 1996 Hi Carlos ! Please see enclosed conversation I recently had with MS regarding PropSheets in an ActiveX context. I think it solves your problem. Allan Dystrup Kommunedata, Denmark ---------- > From: Carlos Carvajal> To: MFC Newsgroup > Subject: Property Sheets and ActiveX controls > Date: 1. november 1996 14:37 > > Environment: Windows 95, VC++ 4.2b > > I am trying to popup a CPropertySheet from an ActiveX control. When I use > VC++ 4.0 everything is fine. If I use VC++ 4.2 I get an assertion failure > when the > propertysheets DoModal is ending. I traced into the MFC code and found the > the > propertysheets parent window variable was getting plastered. So when the > propertysheet was erasing itself and trying to reenable its parent an > ASSERT_VALID on > its parent failed. If I replace the propertysheet with a dialog it is > fine, or if I place the propertysheet > into a view it is also fine. I have fixed the problem for the moment by > building my own property > sheet that inherits from CPropertySheet and overloads the DoModal. I > copied the DoModal > code from the CPropertySheet but added some code to it to make a copy of > the parent > pointer and use the copy instead of the member variable that gets > plastered. Is there a > fix for this, or am I doing something else wrong? ENCLOSURE__________________________________________________________ Hi Allan, I sent your explanation to USA without modifications. This is the reply I received today: Regards, Borge Trongmo - - - - I have seen this problem before, but only under Windows 95 with an old version of COMCTL32.DLL. The problem occurs when CPropertySheet is a child of a CPropertyPage or CDialog. The application will hang if focus is changed. I've attached an article that talks about this and how to get around it. This has since been fixed in a newer version of COMCTL32.DLL that comes with Internet Explorer 3.0. I thought this fix was also in the COMCTL32.DLL that shipped with NT 4.0. You can try installing Internet Explorer 3.0 on NT 4.0 or you can add the source code workaround below. Thanks, ST Developer Support Q149501 - BUG: Child CPropertySheet Hangs If Focus Is Switched ----------------------------------------------------------------------- The information in this article applies to: - The Microsoft Foundation Classes (MFC) included with: Microsoft Visual C++, 32-bit Edition, version 4.0 ----------------------------------------------------------------------- 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 ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. MORE INFORMATION ================ Sample Code ----------- // CMySheet is derived from CPropertySheet BOOL CMySheet::OnInitDialog() { ModifyStyleEx (0, WS_EX_CONTROLPARENT); return CPropertySheet::OnInitDialog(); } <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
| Вернуться в корень Архива |