Print Page | Close Window

How to reorder CXTPTabClientWnd tabs by code?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=10625
Printed Date: 15 November 2025 at 1:58am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to reorder CXTPTabClientWnd tabs by code?
Posted By: mgampi
Subject: How to reorder CXTPTabClientWnd tabs by code?
Date Posted: 14 May 2008 at 4:29pm
Hi,
does anybody know how to reorder CXTPTabClientWnd tabs by code?
In detail: I want to sort the opened documents by name.


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



Replies:
Posted By: mgampi
Date Posted: 19 May 2008 at 11:16am
Hi;
for anyone who's interrested in this; the solution is to derive from CXTPTabClientWnd and add a sort function that removes all items and afterwards add them again in sorted order:
 
void CXRSortableTabClientWnd::Sort() {
 // Get the set of all opened MDI client windows
 std::set<CMDIChildWnd*> clients;
 xrApp->GetMDIClientMap(clients);
 // Insert the set into a multimap sorted by document title
 std::multimap<_tstring, CMDIChildWnd*> sorted;
 for (std::set<CMDIChildWnd*>::const_iterator i=clients.begin(); i!=clients.end(); ++i) {
  CString strItem=GetItemText(*i);
  sorted.insert(std::make_pair(_tstring(strItem), *i));
 }
 m_bLockReposition = TRUE;
 // Remove all current tab items
 m_pActiveWorkspace->DeleteAllItems();
 XTPWorkspaceNewTabPosition position=GetNewTabPositon();
 SetNewTabPosition(xtpWorkspaceNewTabRightMost);
 // Add tab items in a sorted manner
 for (std::multimap<_tstring, CMDIChildWnd*>::const_iterator i=sorted.begin();i!=sorted.end(); ++i) {
  CXTPTabManagerItem* pFoundItem = AddItem(i->second);
  pFoundItem->SetHandle(i->second->GetSafeHwnd());
 }
 m_bLockReposition = FALSE;
 SetNewTabPosition(position);
 Reposition();
}


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net