Print Page | Close Window

SDI and Tab Manager

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=659
Printed Date: 24 December 2024 at 8:10am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: SDI and Tab Manager
Posted By: naggerman
Subject: SDI and Tab Manager
Date Posted: 26 April 2004 at 3:26pm

Hi,

I think this question was already posted before, and it was told to wait for 8.70.

If I have multiple views to a single document in an SDI application and want to use tabs to switch between these views. How do I do that with the new tab manager?

Thanks!

Henrik

 




Replies:
Posted By: ipaqlinux48
Date Posted: 28 April 2004 at 12:51pm
In version 8.70, there is a new control: CXTPTabControl. I've also an SDI application which uses multiple views of the same document. However, this control doesn't send notification messages to the parent window (e.g. when the user closes a tab, switches to another tab, etc...). Maybe, version 8.71 ?


Posted By: Oleg
Date Posted: 29 April 2004 at 9:57am
You can inherit CXTPTabControl and inherit OnNavigateButtonClick and SetSelectedItem methods.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: ddyer
Date Posted: 29 April 2004 at 4:15pm

Oleg,

In the TabManager sample is something called CXTPTabClientWnd.  Is there a way to use this in an SDI application (have each view (tab client) point to the same document)?

Im probably way off, but what if CMyAppView (the generated view class) acted as a placeholder who's only job in life is to provide its window to one of its member variables that is a CXTPTabClientWnd.  Then when I want to create a new view as a tab client,  I ask my host view's CXTPTabClientWnd to do so.

I wanted to ask first because the docs for TabClientWnd are sparse and mention MDI a lot.



Posted By: Oleg
Date Posted: 30 April 2004 at 12:32am
CXTPTabClientWnd  can be used only for MDI frame.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: ddyer
Date Posted: 30 April 2004 at 11:02am

How would one then use CXTPTabControl to manage views?  I have a simple generated CView from an SDI app and it has one member variable, m_tabCtrl (an XTPTabControl).

I call m_tabCtrl's Create in the view's OnCreate method.  The OnCreate,  AddATab and CreateView methods shown below try to add one of my app's views to the tabCtrl.

Nothing seems to work right.  Im not sure if I need to do something with my view's OnSize or OnPaint or OnDraw, but I just can't get this to work.  I've tried various onsize, onpaint, ondraw tests but haven't gotten anywhere really. 

Oleg, I know you are a busy guy, but do you have any thoughts on this?

Regards,
Doug

//////////////////////////////////////////////////////////// //////////////
int CMyMainView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 if (CView::OnCreate(lpCreateStruct) == -1)
  return -1;

 if (m_tabCtrl.Create(NULL, NULL, 0, CRect(0,0,0,0), this, 0, NULL) == FALSE)
  return -1;

  return 0;
}

//////////////////////////////////////////////////////////// //////////////
void CMyMainView::AddATab(void)
{
 frame = CreateView(RUNTIME_CLASS(CMyApplicationView), GetDocument());

 CXTPTabManagerItem *mi =
  m_tabCtrl.InsertItem(m_tabCtrl.GetItemCount(), title,
                         frame->GetSafeHwnd(), 0);
 frame->SendMessage(WM_INITIALUPDATE);
 m_tabCtrl.SetSelectedItem(mi);
}

//////////////////////////////////////////////////////////// //////////////
CFrameWnd* CMyMainView::CreateView(CRuntimeClass *type, CDocument *doc)
{
 CFrameWnd *pFrame = new
CFrameWnd;
 CCreateContext context;
 ::ZeroMemory(&context, sizeof
(context));
 context.m_pNewViewClass = type;
 context.m_pCurrentDoc = doc;
 context.m_pCurrentFrame = m_tabCtrl.GetParentFrame();

 pFrame->Create(NULL, NULL,
 
WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CRect(0, 0, 0, 0),
  &m_tabCtrl, NULL, 0, &context);

 if (pFrame->GetSafeHwnd()) {
  pFrame->ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
  pFrame->GetWindow(GW_CHILD)->ModifyStyleEx(WS_EX_CLIEN TEDGE, 0,  
  SWP_FRAMECHANGED);
 }

 pFrame->SetActiveView((CView*)pFrame->GetWindow( GW_CHILD));
 return pFrame;
}



Posted By: ipaqlinux48
Date Posted: 01 May 2004 at 1:30am

You forget the OnSize message handler. You should have something like this so that m_tabCtrl occupies the complete parent window:

// Resize the list control contained in the view to
// fill the entire view when the view's window is
// resized. CMyView is a CView derived class.
void CMyMainView::OnSize(UINT nType, int cx, int cy)
{
   CView::OnSize(nType, cx, cy);
   // Resize tab control to fill the whole view.
   m_tabCtrl.MoveWindow (0, 0, cx, cy);
}

I hope this solves your problem.

Oh by the way, just remove the WS_CLIPCHILDREN window style for your view. Otherwise the screen will flicker as soon as your view is resized.



Posted By: naggerman
Date Posted: 02 May 2004 at 10:04am

Hi Doug,

I tried your code, too. It works after adding the OnSize handling and adding WS_VISIBLE and WS_CHILD flags to the m_tabCtrl.Create. Your code was creating an invisible tab control.

Regards,

Henrik



Posted By: ddyer
Date Posted: 03 May 2004 at 7:50am

LOL thanks guys... sometimes you can't see the forest for the trees.  Hey, maybe I WANTED an invisible tab, ever think of that?   Also, my onsize method was calling tabCtrl.OnSize() rather than the much more obvious MoveWindow.  Thanks!

BTW, if you replace CMyApplicationView with a CXTListView for the sake of discussion,  and assume you have a few tabs created, anyone notice the listview flickers like mad whenever the tabs are clicked or the window is resized?   The tabs themselves do not flicker, so I don't think its the creation of the tabCtrl member.

How do you get rid of this flickering? 

Thanks
Doug



Posted By: ipaqlinux48
Date Posted: 03 May 2004 at 8:03am

Use the WS_CLIPCHILDREN window style for your tab control.



Posted By: ddyer
Date Posted: 03 May 2004 at 8:14am

Thanks!  This tabcontrol is significantly better than cxttabview.... users can drag-rearrange the tabs.  Hopefully today Ill finish moving over all the features I had in my old cxttabview subclass.



Posted By: ddyer
Date Posted: 03 May 2004 at 12:21pm

Hey here is something that would be great if anyone is up to it:  Using the existing CXTTabControl inside a basic CView (as shown above), anyone think they can bring to life the Tab Group features demonstrated by CXTPTabClientWnd and shown in the TabManager sample application?

The group feature Im refering too is what allows you to create horizontal and vertical tab collections.  To see it in vc++, open a few source files and right-mouse-click on one of their tabs to see "New Tab XXX Group").  To see it in the TabManager sample demo, create a few tabbed docs, then drag a tab to the center of the doc area... you should be presented with the New Tab XXX Group menu.

It looks like there is a lot of maintenance code for this ready to go, its just a matter of taking the TabClientWnd class and replacing it with one that is more SDI-centric. 



Posted By: Karnize
Date Posted: 05 May 2004 at 2:33am

Hello,

CXTPTabControl looks great, but I have one question. Does it support multiline tabs or only singleline? I was not able to see it in samples.



Posted By: Oleg
Date Posted: 05 May 2004 at 10:50am
Only singleline now. Maybe in th future we will add multiline mode too.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



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