Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Splitters and windows switching
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Splitters and windows switching

 Post Reply Post Reply
Author
Message
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Topic: Splitters and windows switching
    Posted: 27 June 2009 at 11:12pm
Imagine you have Outlook-stile UI, that is whenever you click on Calendar, Tasks, or Mail items in the left window the right view changes accordingly. So basically there is CSplitterWnd member in the CMainFrm that splits it to Right and Left, then if I create another child frame in the left window I can create several views in it and switch them according to the item clicked in the Left view. Here is the problem: what if some views that I create in Right part should have splitters too? That is if I click Mail I get a view in the Right pane that is split to email items and preview... How do I go about this? I know that I cannot put CSplitterWnd member in CView - it requires CFrameWnd or its derivative... I am attaching a schetch (Splitters.bmp) the way I'd like it to be, but know at the same time that I cannot put m_ViewSplitter in CSplitterView (derived from CView)...
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 28 June 2009 at 7:43am
Hi;

You can put CSplitterWnd in CView derived classes also. We do this day-to-day (see code).
    // Zuerst den Splitter erzeugen
CMyView::OnCreate(...) {
   ...
    if (!wndSplitter_.CreateStatic(this, 2, 1))
        return -1;

    wndSplitter_.SetOwner(this);
    wndSplitter_.SetSplitterStyle(XT_SPLIT_NOFULLDRAG);

    // Create any view
    if (!wndSplitter_.CreateView(0, 0, RUNTIME_CLASS(CMyFirstViewView), CSize(0,0), 0))
    {
        TRACE("Unable to create view\n");
    }

    // Create a CWnd derived object directly
    if (!wndPanes_.Create(WS_VISIBLE|WS_CHILD, CRect(0,0,0,0), &wndSplitter_, wndSplitter_.IdFromRowCol(1,0)))
        return -1;

    wndPanes_.SetOwner(this);
    ...
}

void CMyView::OnSize(UINT nType, int cx, int cy)
{
    CView::OnSize(nType, cx, cy);
    if (wndSplitter_.GetSafeHwnd())
    {
        wndSplitter_.MoveWindow(0,0,cx,cy);
    }
}


But you can also write your own splitter management functions. Take a look at CXTPPropertyGridWnd. It handles the splitting by catching the appropriate messages and take any actions.

Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 28 June 2009 at 3:50pm
That's refreshing... all the post I read so far say that I cannot put splitters in the CView derived classes... I will try that. This brings another question:
When I have a splitter in a view I will have first to create frame window for each part of the splitter since I need to have a toolbar for in each splitted view. So to iterate once again I will have:
- main splitter that devides main frame to LeftFrame and RightFrame
- RightFrame pane will contain Toolbar1 with View1
- It will also have View2
- View1 and View2 will be switchable
- View2 will contain Splitter2
- Splitter2 will split View2 to TopFrame and BottomFrame
- TopFame will contain TopToolbar and TopView
- BottomFrame will contain BottomToolbar and BottomView
 
so do you still think it is possible?
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 28 June 2009 at 3:55pm
Hi;

Why do you think you have to put frames into splitter 2? Just put your CView derived classes into the splitter.
CView objects - as every CWnd derived object - can also contain CXTPCommandBar objects (just include a CXTPCommandBar member into your CView class and initialize it), so no need for frames.
I think there's a sample how to put a CXTPCommandbar object into panes. Take this as a first step.
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 28 June 2009 at 6:30pm
I tried that before and could not make toolbars to work - messaging was somehow broken...
Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 29 June 2009 at 12:47am
Here is more or less all the code...unfortunatly it does not work...I traced it, and see that everything is created without errors, including the ReportControl, but on the right side I see just one plain view...
 

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)

{

// split the main frame window into 2 colums:

// left - for ShortcutBar, right for the rest

m_wndSplitter.CreateStatic(this, 1, 2);

// create ShortcutBar in the left pane

CreateShortcutBar();

// Split the right side window to contain 2 rows, the top one is for caption

if (!m_wndSplitter1.CreateStatic(&m_wndSplitter, // our parent window is the first splitter

2, 1, // the new splitter is 2 rows, 1 column

WS_CHILD | WS_VISIBLE /*| WS_BORDER*/, // style, WS_BORDER is needed

m_wndSplitter.IdFromRowCol(0, 1))) // new splitter is in the first row, 2nd column of first splitter

{

TRACE0("Failed to create caption splitter\n");

return FALSE;

}

// Create the caption bar, this will be inserted

// into row 0, col 0 of nested m_wndSplitter1.

if (!InitializeCaptionBar())

return FALSE;

// create a frame to hold all other windows at the right bottom part of m_wndSplitter1

m_wndSplitter1.CreateView(1, 0, RUNTIME_CLASS(CRightFrame), CSize(0, 800), pContext);

m_pRightFrame = (CRightFrame*)(m_wndSplitter1.GetPane(1,0));

m_pRightFrame->SetDocPtr(m_gpDoc);

 

// set the width of the shortcut bar

m_wndSplitter.SetColumnInfo(0, m_cxTreePane,150); //250

m_wndSplitter.RecalcLayout();

m_wndSplitter1.RecalcLayout();

m_wndSplitter.EnableFlatLook(TRUE);

m_wndSplitter1.EnableFlatLook(TRUE);

m_wndSplitter.SetSplitterStyle(XT_SPLIT_NOFULLDRAG);

m_wndSplitter1.SetSplitterStyle(XT_SPLIT_NOFULLDRAG | XT_SPLIT_NOSIZE | XT_SPLIT_NOBORDER);

m_wndSplitter.SetActivePane(0,0);

return TRUE;

}

BOOL CRightFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)

{

m_pReportFormView = new CReportFormView;

((CView*)m_pReportFormView)->Create(NULL, NULL, 0L, CXTPFrameWnd::rectDefault, this, VIEW_REPORT, pContext);

m_pReportFormView->ShowWindow(SW_HIDE);

m_pReportFormView->SetDlgCtrlID(VIEW_REPORT);

m_pReportFormView->SetDocPtr(m_gpDoc);

// this view will contain a splitter and will split to 2 rows:

// top for holding CReportControl

// and bottom for holding another CReportControl

//

m_pSplitterView = new CSplitterView;

((CView*)m_pSplitterView)->Create(NULL, NULL, 0L, CXTPFrameWnd::rectDefault, this, VIEW_SPLIT, pContext);

m_pSplitterView->ShowWindow(SW_SHOW);

m_pSplitterView->SetDlgCtrlID(VIEW_SPLIT);

m_pSplitterView->SetDocPtr(m_gpDoc);

m_nCurrentViewID = VIEW_SPLIT;

RecalcLayout();

return TRUE;

}

int CRightFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CXTPFrameWnd::OnCreate(lpCreateStruct) == -1)

return -1;

if (!InitCommandBars())

return -1;

CXTPCommandBars* pCommandBars = GetCommandBars();

// toolbar

//

CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Report Toolbar"), xtpBarTop);

if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_REPORT_BAR))

{

TRACE0("Failed to create Report toolbar\n");

return -1;

}

pCommandBar->EnableDocking(0);

if (XTPImageManager()->IsAlphaIconsSupported())

{

XTPImageManager()->SetIcons(IDR_REPORT_BAR, IDB_REPORT_BAR);

}

else

{

XTPImageManager()->SetIcons(IDR_REPORT_BAR);

}

m_pReportBar = pCommandBar;

m_pReportBar->SetVisible(TRUE);

m_pCurrentBar = m_pReportBar;

return 0;

}

int CSplitterView::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CView::OnCreate(lpCreateStruct) == -1)

return -1;

if (!m_wndSplitter2.CreateStatic(this, 2, 1))

return -1;

m_wndSplitter2.SetOwner(this);

m_wndSplitter2.SetSplitterStyle(XT_SPLIT_NOFULLDRAG);

// Create top frame

if (!m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CCenterRightFrame), CSize(0,0), 0))

{

TRACE("Unable to create CCenterRightFrame\n");

return -1;

}

// Create top frame

if (!m_wndSplitter2.CreateView(1, 0, RUNTIME_CLASS(CBottomRightFrame), CSize(0,0), 0))

{

TRACE("Unable to create CBottomRightFrame\n");

return -1;

}

return 0;

}

int CCenterRightFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CXTPFrameWnd::OnCreate(lpCreateStruct) == -1)

return -1;

if (!InitCommandBars())

return -1;

CXTPCommandBars* pCommandBars = GetCommandBars();

CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Discovery ControlBar"), xtpBarTop);

if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_DISCOVERY_TOOLBAR))

{

TRACE0("Failed to create Discovery toolbar\n");

return -1;

}

pCommandBar->EnableDocking(0);

CString csStr = L" ";

CString csStr2;

csStr2.LoadString(IDS_CENTER_FRAME_TITLE);

csStr += csStr2;

pCommandBar->GetControls()->Add(xtpControlLabel, 0)->SetCaption(csStr);

if (XTPImageManager()->IsAlphaIconsSupported())

{

XTPImageManager()->SetIcons(IDR_DISCOVERY_TOOLBAR, IDB_DISCOVERY_TOOLBAR);

}

else

{

XTPImageManager()->SetIcons(IDR_DISCOVERY_TOOLBAR);

}

InitReportCtrl();

return 0;

}

Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 29 June 2009 at 12:55am
BTW, I have v13 and nowhere CXTPPropertyGridWnd can be found. All calls to CreateStatis are made from frame windows in all samples...
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.156 seconds.