Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - How to reorder CXTPTabClientWnd tabs by code?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to reorder CXTPTabClientWnd tabs by code?

 Post Reply Post Reply
Author
Message
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1210
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Topic: How to reorder CXTPTabClientWnd tabs by code?
    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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1210
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.