15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


SplitterWnd functionality in CPropertyPages

Simon Coghlan -- coghlans@sharelink.com
Friday, February 07, 1997


Environment: NT 4.0 WIN 95 VC++ 4.2b

I need a little help / Guidance on the following scenario..

I have an app that consists entirely of a CPropertySheet as the main =
app, that can be resized at run time to show a page to the users Size =
requirements..

On one of the pages it would be nice to embed a CTreeCtrl and CListCtrl =
into a CSplitterWnd with two panes..

What I need is a way of doing it that works with the CPropertySheet as =
the main app..

It appears that all the CSplitterWnd wants are Views and an =
OnCreateXXXXX thing to initialise against.. As this is a CPropertySheet =
with CPropertyPages ( which are based upon Dialogs that do not have =
OnCreateXXXXX funcionality available { breaks points do not get called } =
) I need some way of setting two panes ( one with a TreeCtrl and the =
other with the ListCtrl ) in the OnInitDialog of the CPropertySheet.=20

I have looked at Split32 available on the MSDN and attempted to =
implement that, but that just fails without showing anything..

So the Question is, Has anybody inserted a CSplitterWnd into a CDiolog =
type situation without CViews or MDI/SDI functionality..

---------
Simon=20
----------<- Smurf-IV ->-------------
Tel : 0121 200 7713
Fax : +44 (0)121 212 0379
Email smurf-iv@sharelink.com
Member of the 'Team of CIS' ;-)
---------<- Fun To All ->------------
We are what we repeatedly do, Excellence, then, is not an act, but a =
habit.
Aristotle
The one who says it cannot be done, should never interrupt the one who =
is doing it.
The Roman Rule








Stuart Downing -- sdowning@fame.com
Monday, February 10, 1997

[Mini-digest: 2 responses]

The child panes of CSplitterWnd are only optionally CView derivatives.  =
You
can use any CWnd derived window.  I assume the OnCreateXXXXX you
are referring to is the CCreateContext object.  You only need this
if you want CSplitterWnd to automatically associate your view (if you're
creating views) with a document.  (Sounds like you can pass in NULL for =
this)

Create your two window classes for the two panes.  They should be=20
declared DYNCREATE, because CSplitterWnd will create the child windows
for you.  Use the CreateView function (once for each window), passing in =

the RUNTIME_CLASS of your pane classes to create the panes.

I've only used CSplitterWnd in the context of a CView, but I don't see
any reason why it can't be used as a child of a CDialog.
-----
Stuart Downing
sdowning@fame.com
FAME Information Services, Inc.

----------
From:  coghlans[SMTP:coghlans@sharelink.com]
Subject:  SplitterWnd functionality in CPropertyPages
Environment: NT 4.0 WIN 95 VC++ 4.2b

It appears that all the CSplitterWnd wants are Views and an =
OnCreateXXXXX thing to initialise against.. As this is a CPropertySheet =
with CPropertyPages ( which are based upon Dialogs that do not have =
OnCreateXXXXX funcionality available { breaks points do not get called } =
) I need some way of setting two panes ( one with a TreeCtrl and the =
other with the ListCtrl ) in the OnInitDialog of the CPropertySheet.=20




-----From: "brianw" 

Simon, 

I don't know about using a splitter in a dialog/property page, but, maybe
this information will help.

After your call to the Create() or CreateStatic() member of CSplitterWnd
one must create a "view", that much is true, however, I have found that
CreateView() doesn't _need_ to take a CView derived class. It can, instead
take a derived class of CFrameWnd, such as in the following:

	if (!m_wndSplitter1.CreateView(0, 0,
		RUNTIME_CLASS( CFrameFolders ), size, pContext))
	{
		TRACE0("Failed to create first pane\n");
		return FALSE;
	}

In the case of my application, my CFrameFolders is derived from CFrameWnd
and has a member of m_treeFolders which is a CTreeCtrl.

I know we aren't supposed to give answers like this but, I recall recently
seeing some messages on the subject of splitters and dialogs in the news
group microsoft.public.vc.mfc, if you have access try looking there.

Hope this is of some help.

-------------------
Brian Welsh
brianw@i1.net
http://www.i1.net/~brianw
----------
> 
> Environment: NT 4.0 WIN 95 VC++ 4.2b
> 
> I need a little help / Guidance on the following scenario..
> 
> I have an app that consists entirely of a CPropertySheet as the main app,
that
> can be resized at run time to show a page to the users Size requirements..
> 
> On one of the pages it would be nice to embed a CTreeCtrl and CListCtrl
into a
> CSplitterWnd with two panes..
> 
> What I need is a way of doing it that works with the CPropertySheet as the
> main app..
> 
> It appears that all the CSplitterWnd wants are Views and an OnCreateXXXXX
> thing to initialise against.. As this is a CPropertySheet with
CPropertyPages
> ( which are based upon Dialogs that do not have OnCreateXXXXX funcionality
> available { breaks points do not get called } ) I need some way of
setting two
> panes ( one with a TreeCtrl and the other with the ListCtrl ) in the
> OnInitDialog of the CPropertySheet. 
> 
> I have looked at Split32 available on the MSDN and attempted to implement
> that, but that just fails without showing anything..
> 
> So the Question is, Has anybody inserted a CSplitterWnd into a CDiolog
type
> situation without CViews or MDI/SDI functionality..
> 
> ---------
> Simon 
> ----------<- Smurf-IV ->-------------
> Tel : 0121 200 7713
> Fax : +44 (0)121 212 0379
> Email smurf-iv@sharelink.com
> Member of the 'Team of CIS' ;-)
> ---------<- Fun To All ->------------
> We are what we repeatedly do, Excellence, then, is not an act, but a
habit.
> Aristotle
> The one who says it cannot be done, should never interrupt the one who is
> doing it.
> The Roman Rule
> 
> 
> 
> 
> 
> 





Simon Coghlan -- coghlans@sharelink.com
Wednesday, February 12, 1997

> [Mini-digest: 2 responses]

> The child panes of CSplitterWnd are only optionally CView derivatives. =
 You
> can use any CWnd derived window.  I assume the OnCreateXXXXX you
> are referring to is the CCreateContext object. =20

No I was referring to the OnCreateDialog and relation to OnInitDialog.. =
The OnCreateContext is not given via the wizard so might be not =
available to the us mere mortals..
=20
> You only need this if you want CSplitterWnd to automatically associate =
your view (if you're
> creating views) with a document.  (Sounds like you can pass in NULL =
for this)

This caused an unhandled assertion with the following Call Stack : -
CFrameWnd::GetActiveView() line 1242 + 3 bytes
CSplitterWnd::GetActivePane(int * 0x00000000, int * 0x00000000) line =
2263 + 8 bytes
CSplitterWnd::CreateView(int 0, int 1, CRuntimeClass * 0x00406640 =
{"CLogFileTreeCtl"}, tagSIZE {...}, CCreateContext * 0x00000000) line =
270 + 18 bytes
CDialog_SplitterDlg::OnCreate(tagCREATESTRUCTA * 0x0012fb24) line 190

Its trying to get the context via the active view.. There are no views =
this is a Dialog..

> Create your two window classes for the two panes.  They should be=20
> declared DYNCREATE, because CSplitterWnd will create the child windows
> for you.  Use the CreateView function (once for each window), passing =
in=20
> the RUNTIME_CLASS of your pane classes to create the panes.

> I've only used CSplitterWnd in the context of a CView, but I don't see
> any reason why it can't be used as a child of a CDialog.

Here is the code segment that produces the above dump..

int CDialog_SplitterDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)=20
{
	if (CDialog::OnCreate(lpCreateStruct) =3D=3D -1)
		return -1;
=09
	m_Splitter.CreateStatic( this, 1, 2 );
	SIZE size;                                 =20
	CRect rect;    =20
	GetClientRect(&rect);  =20
	size.cx=3Drect.right/2;
	size.cy=3Drect.bottom;
	m_Splitter.CreateView(0,1,RUNTIME_CLASS(CLogFileTreeCtl),size, NULL);
	m_Splitter.CreateView(0,0,RUNTIME_CLASS(CLogFileTreeCtl),size, NULL);
 =20
	m_Splitter.ShowWindow(SW_SHOWNORMAL);
	m_Splitter.UpdateWindow();
=09
	return 0;
}=20
No Compilations errors are encountered ( even on level 4 )..

So what am I missing.. This does not appear to be as simple as one seems =
upon first glance..


-----
coghlans[SMTP:coghlans@sharelink.com]
Subject:  SplitterWnd functionality in CPropertyPages
Environment: NT 4.0 WIN 95 VC++ 4.2b

It appears that all the CSplitterWnd wants are Views and an =
OnCreateXXXXX thing to initialise against.. As this is a CPropertySheet =
with CPropertyPages ( which are based upon Dialogs that do not have =
OnCreateXXXXX funcionality available { breaks points do not get called } =
) I need some way of setting two panes ( one with a TreeCtrl and the =
other with the ListCtrl ) in the OnInitDialog of the CPropertySheet.=20

So the Question is, Has anybody inserted a CSplitterWnd into a CDiolog
type situation without CViews or MDI/SDI functionality..
=20




Stuart Downing -- sdowning@fame.com
Thursday, February 13, 1997

>----------
From:  coghlans[SMTP:coghlans@sharelink.com]
>Sent:  Wednesday, February 12, 1997 10:36 AM
>
>> The child panes of CSplitterWnd are only optionally CView derivatives. =
> You
>> can use any CWnd derived window.  I assume the OnCreateXXXXX you
>> are referring to is the CCreateContext object. =20
>
>No I was referring to the OnCreateDialog and relation to OnInitDialog.. =

CCreateContext is a structure that you declare, initialize
and hand over to MFC so that when it creates CViews for you,
it will hook them to the appropriate CDocuments.  I don't think
you want to derive your panes from CView (see below) so you
shouldn't have to care about this.  
I think by "OnCreateDialog" you mean "CMyDialog::OnCreate"
(the handler for the WM_CREATE message)

>The OnCreateContext is not given via the wizard so might be not =
>available to the us mere mortals..
>=20

MFC doesn't have any "OnCreateContext" methods.

I have to put my pants on one leg at a time, just like everyone else. :)
(Please, no offense, ladies)
[Moderator's note: Also, no offense to really dumb people who have
to put their pants on one arm at a time...]

>This caused an unhandled assertion with the following Call Stack : -
>CFrameWnd::GetActiveView() line 1242 + 3 bytes
>CSplitterWnd::GetActivePane(int * 0x00000000, int * 0x00000000) line =
>2263 + 8 bytes
>CSplitterWnd::CreateView(int 0, int 1, CRuntimeClass * 0x00406640 =
>{"CLogFileTreeCtl"}, tagSIZE {...}, CCreateContext * 0x00000000) line =
>270 + 18 bytes
>CDialog_SplitterDlg::OnCreate(tagCREATESTRUCTA * 0x0012fb24) line 190
>
>Its trying to get the context via the active view.. There are no views =
>this is a Dialog..

Hmmm.  Take a look at WINSPLIT.CPP and search for all the calls
to GetParentFrame, (which is causing your trouble, since you're
not a child of a frame).  You should see that it's called in 
the following methods...
* StartTracking - prechecks that pane is CView derived before calling
so don't derive your panes from CView
* OnCommand - Virtual so you can override it.  You probably want to 
override this and just call CDialog::OnCommand
* OnNotify - Same story as OnCommand
* SetActivePane - Same as StartTracking
* GetActivePane - Virtual.  Override.  Involves some
work to understand what the requirements are of this method
in various contexts.  This exercise is left to the reader. :)

Create a new window class derived from CSplitterWnd and override
as described above.  Use this in your dialog.

>So what am I missing.. This does not appear to be as simple as one seems =
>upon first glance..

Same thing I was missing.  CSplitterWnd was written with a CFrameWnd
parent in mind, but it's not out the question that you can get
it to work in the context of a dialog.  You might not be out of
the woods yet.  There may be some other parent-frame assumptions
built into the code that are less obvious that I'm missing.
-----
Stuart Downing
sdowning@fame.com
FAME Information Services, Inc.






Become an MFC-L member | Вернуться в корень Архива |