Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » How to find tab in CExtTabPageContainerOneNoteWnd Collapse All
Subject Author Date
Adrian M Jul 4, 2005 - 10:50 AM

Hi,


My app creates and removes tabs in a CExtTabPageContainerOneNoteWnd window dynamically. Because I need to remove these tabs in random order I can’t use the indexes generated by PageInsert, instead I need to be able to find tabs based on some criteria, but I couldn’t find any such method in the class or its base.


How can I find a tab? Or is there another way to remove tabs in random order?


Thanks,


Adrian


 

Technical Support Jul 4, 2005 - 1:07 PM

The CExtTabPageContainerWnd class is based on CExtTabWnd, which allows you to associate the 32-bit application-specific value with the item, and then find this tab item by this value. It seems this is what you need.
When we designed the CExtTabPageContainerWnd class, we simply forgot to add similar methods. You can add this yourself, just open the CExtTabPageContainerWnd header and insert the following code:

      LONG PageFindByLParam(
            LPARAM lParam,
            LONG nIndexStartSearch = -1,
            bool bIncludeVisible = true,
            bool bIncludeInvisible = false
            ) const
      {
            ASSERT_VALID( this );
            return m_pWndTab->ItemFindByLParam(
                  lParam,
                  nIndexStartSearch,
                  bIncludeVisible,
                  bIncludeInvisible
                  );
      }
 
      LPARAM PageLParamGet( LONG nIndex ) const
      {
            ASSERT_VALID( this );
            return m_pWndTab->ItemLParamGet( nIndex );
      }
 
      void PageLParamSet(
            LONG nIndex,
            LPARAM lParam = 0
            )
      {
            ASSERT_VALID( this );
            m_pWndTab->ItemLParamSet( nIndex, lParam );
      }
 

Adrian M Jul 4, 2005 - 8:21 PM

There seem to be some problems with this approach. I set the lparam to some value and when I tried to remove the tab I got an assert on the black line below:

ULONG CExtTabPageContainerWnd::SetupHookWndSinkToChilds(

HWND hWnd,

UINT * pDlgCtrlIDs, // = NULL

ULONG nCountOfDlgCtrlIDs, // = 0

bool bDeep // = false

)

{

ASSERT( hWnd != NULL );

if( hWnd == NULL )

return 0;

ASSERT( ::IsWindow(hWnd) );

The previous method is called from:

bool CExtTabPageContainerWnd::OnTabWndSelectionChange(

LONG nOldItemIndex,

LONG nNewItemIndex,

bool bPreSelectionTest

)

{

ASSERT_VALID( this );

nOldItemIndex;

if( ! bPreSelectionTest )

{

//_RepositionBarsImpl();

_RealignAllImpl();

RemoveAllWndHooks();

HWND hWndNew = (HWND)m_pWndTab->ItemLParamGet(nNewItemIndex);

SetupHookWndSinkToChilds(

hWndNew,

NULL,

0,

true

);

}

return true;

}


and I see that some window handle is already stored as an lparam internally, so setting the lparam may corrupt the internal state of the object.


Any ideas on this?


Thanks,


Adrian

Technical Support Jul 5, 2005 - 1:00 PM

You are right. LParam is used for internal purposes. It stores an HWND handle to the window associated with the page. So you cannot change its value.

However you can store HWND handles to your pages somewhere and then search the pages by these handles. In the next intermediate library release, we will add only the PageFindByLParam method to search pages by its handles. You can receive the window handle with PageHwndGet (or PageHwndGetSafe) just after the page is inserted.

Adrian M Jul 4, 2005 - 2:02 PM

That will work. Will these methods be also added to the next release? Just want to make sure that my code won’t be broken when I install a new release.


Thanks,


Adrian