Microsoft KB Archive/243457

= BUG: MFC-WinCE Property Page with a Registered ActiveX Control Disappears from the Property Sheet =

Article ID: 243457

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Windows CE Toolkit for Visual C++ 6.0
 * The Resource Editor
 * Microsoft Foundation Class Library 4.2

-



This article was previously published under Q243457



SYMPTOMS
Property page hosting registered CE ActiveX control disappears when the tab for that page is selected. If control is placed on the first page, the property sheet appears for a brief moment, and then disappears. These symptoms are seen on both device and emulator for Windows CE.



CAUSE
Microsoft is researching this problem and will post more information in this article when the information becomes available.



RESOLUTION
At this time, there is no resolution to the problem. To work around the problem, the control can be created dynamically at run-time, rather than using the Resource Editor to drag and drop the control on the dialog resource. For example:

Override the WM_INITDIALOG for the Property Page Class. The Class Wizard generates the following message map:

// Generated message map functions //AFX_MSG Then from the menu item, select Project, Add to Project, Components and Control, and then Registered ActiveX Controls. Locate the control you want to add to the property page.

You should assume, that you want to add the Microsoft CE Grid Control 6.0. Select Microsoft CE Grid Control 6.0 click Insert, OK, and then Close. Add a protected member variable to the Property Page class of type CGridCtrl using the Class View to add the member variable: protected: CGridCtrl m_myGridCtrl; In the handler for WM_INITDIALOG add the following code to create the control: BOOL CMyPropertyPage1::OnInitDialog {  CPropertyPage::OnInitDialog;

// TODO: Add extra initialization here m_myGridCtrl.Create(NULL,                  //LPCTSTR lpszClassName                        NULL,                   //LPCTSTR lpszWindowName                       WS_CHILD|WS_VISIBLE,    //DWORD dwStyle                       CRect(20,20, 200, 200), //const RECT& rect                       this,                   //CWnd* pParentWnd                       500,                    //UINT nID                       NULL);                  //CCreateContext* pContext return TRUE;     // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a simple dialog based application, add a button to it, and in the handler for the button shows a property page and control on it. Create a class CMyPropertySheet derived from CPropertySheet. Using Resource Editor, add two Property Pages IDD_PROPPAGE1, IDD_PROPPAGE2. Create two additional classes CMyPropertyPage1, CMyPropertyPage2 derived from CPropertyPage and associate the two property page resources to it. Add a member variable of type CMyPropertyPage1 and CMyPropertyPage2 to the CMyPropertySheet class, m_page1, m_page2.</li>  In the constructor for CMyPropertySheet add the two following pages: CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(pszCaption, pParentWnd, iSelectPage) {   AddPage(&m_page1); AddPage(&m_page2);

} </li>  In the button handler in the main dialog based application:
 * 1) include "MyPropertySheet.h"

void CSampleDlg::OnButton1 {   CMyPropertySheet m_PropSheet(TEXT("Sample")); m_PropSheet.DoModal; } Rebuild and run, to test that the property sheet works correctly. </li> Using Control Manager make sure you have registered the CE ActiveX Control you want to add to this property sheet (for example, Microsoft CE Grid Control 6.0) for design and emulation.</li> Add the control to the project:

From the menu item, select Project, Add to Project, Components and Control, and then Registered ActiveX Controls. Locate the Microsoft CE Grid Control 6.0. Select Microsoft CE Grid Control 6.0 click Insert, OK, and then Close. From the toolbar drag and drop it on the IDD_PROPPAGE2. (You can also right-click the dialog box resource to insert the ActiveX control). Rebuild and run, click on the button to invoke the property sheet, now click on the second tab of the property sheet, the page disappears.</li> If control is dropped on first page, the property sheet flashes for a fraction of second and then disappears.</li></ol>

Keywords: kbbug kbcontainer kbctrlcreate kbpending kbpropsheet KB243457

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.