PRB: Cannot Change Tabs In Dynamically Created SysTabControl OCX (246044)



The information in this article applies to:

  • Microsoft Visual Studio, Enterprise Edition 6.0
  • Microsoft Visual Studio 97

This article was previously published under Q246044

SYMPTOMS

Unable to change tabs in a Microsoft Tabbed Dialog Control if the control is added dynamically.

CAUSE

The control does not know that it is loaded.

RESOLUTION

Add the following code after the creation of the control:
// Assume pMSTabCtl is a pointer to an instance of a CSSTabCtl object
LPUNKNOWN pUnk = pMSTabCtl->GetControlUnknown();
LPOLECONTROL pCtl;
pUnk->QueryInterface(&pCtl);
pCtl->FreezeEvents(TRUE);
pCtl->FreezeEvents(FALSE);
pCtl->Release();
				

MORE INFORMATION

Steps to Reproduce Behavior

Add the Microsoft Tabbed Dialog Control to an MFC application using the Component Gallery. This adds the CSSTabCtl, COleFont, and CPicture classes to the application.Declare a variable that is a pointer to a CSSTabCtl, for example, pMSTabCtl.Dynamically add the control to a window. See the following code for an example of this:
pMSTabCtl = new CSSTabCtl;
ASSERT( pMSTabCtl );
VERIFY( pMSTabCtl->Create( NULL, <BR/>
                           WS_VISIBLE | WS_CHILD | WS_MAXIMIZEBOX,
                           CRect( 10, 10, 300, 200 ),
                           this, ID_XXXXX, NULL, FALSE, NULL ) );
				
Run the application and try selecting different tabs.

Modification Type:MinorLast Reviewed:8/15/2005
Keywords:kbContainer kbCtrl kbprb KB246044