Discussion:
Determine size of CFormView panes attached to CSplitterWnd?
(too old to reply)
David Bilsby
2008-04-01 12:26:54 UTC
Permalink
All
I am creating an SDI with a splitter and several views based on the
CFormView. I can create and attach them to the CSplitterWnd control
fine, but I want to be able to set the splitters split sizes based on
the size of the form view attached to it.

The form views are defined in a template resource and so have a fixed
size. How to I get this size and then set the splitters pane sizes? The
information must be stored somewhere as when you shrink the splitter via
the divider bar, at some point the pane containing the form view gets a
set of scroll bars added, hence the pane size must be smaller than the
original form views size.

Help much appreciated.

Cheers

David
Jonathan Wood
2008-04-01 16:01:04 UTC
Permalink
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?

It's hard to say without seeing what you are describing but isn't the scroll
range determined by the CFormView? You just need to tell the splitter
window.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by David Bilsby
All
I am creating an SDI with a splitter and several views based on the
CFormView. I can create and attach them to the CSplitterWnd control fine,
but I want to be able to set the splitters split sizes based on the size
of the form view attached to it.
The form views are defined in a template resource and so have a fixed
size. How to I get this size and then set the splitters pane sizes? The
information must be stored somewhere as when you shrink the splitter via
the divider bar, at some point the pane containing the form view gets a
set of scroll bars added, hence the pane size must be smaller than the
original form views size.
Help much appreciated.
Cheers
David
David Bilsby
2008-04-01 16:20:34 UTC
Permalink
Hi
Sorry I probably was not clear enough.

I want to be able to call the SetRowInfo/SetColumnInfo members, however
I do not know what size the CFormView is. If I try and call
GetClientRect() it simply returns the size of the splitter pane which
may be bigger or smaller than the CFormView it contains. I just want to
be able to find the size of the CFormView as set in the resource
template and then size my main window and the splitter panes appropriately.

Hope that makes more sense.

Cheers

David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
Ajay Kalra
2008-04-01 18:12:31 UTC
Permalink
Post by David Bilsby
Hi
Sorry I probably was not clear enough.
I want to be able to call the SetRowInfo/SetColumnInfo members, however
I do not know what size the CFormView is. If I try and call
GetClientRect() it simply returns the size of the splitter pane which
may be bigger or smaller than the CFormView it contains. I just want to
be able to find the size of the CFormView as set in the resource
template and then size my main window and the splitter panes appropriately.
Hope that makes more sense.
Cheers
David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
If you call GetClientRect on the view itself, you should get the right
size. Where are you calling this from?

---
Ajay
David Bilsby
2008-04-03 10:31:38 UTC
Permalink
Jonathan

I have tried this but I only get the size of the view after it is added
to the splitter pane.

The problem seems to be, or at least my problem which could be self
induced, is that I create a static splitter window (CSplitterWnd) and
then add the views. These views are added by a CRuntimeClass pointer,
hence there is no tangible CView at this stage to run the
GetClientRect() on. When you add the view you specify a size parameter
to AddView() which I do not know how to fill in, hence the original
problem.

To get around this I thought I could just come up with a size for the
create view and then adjust it later with the SetRowInfo(), etc calls.
So once I have added the view I can get the CWnd for the view with
GetPane() and this is then my tangible view created for the splitter.
However if I now lookup the size of this view it reports the splitter
pane size I set when I added the view rather than the original size if
the view.

Surely I am doing something obviously wrong here as this cannot be that
difficult! The problem as I see it is that I never create the view
instance in my code and hence cannot do the size lookup there. The view
create is hidden inside the splitter class AddView() call.

Cheers

David.

P.S. As far as I could tell you posted the reply to me to the newsgroup
not to my email, so I don't understand the thread comments after.
Post by Ajay Kalra
Post by David Bilsby
Hi
Sorry I probably was not clear enough.
I want to be able to call the SetRowInfo/SetColumnInfo members, however
I do not know what size the CFormView is. If I try and call
GetClientRect() it simply returns the size of the splitter pane which
may be bigger or smaller than the CFormView it contains. I just want to
be able to find the size of the CFormView as set in the resource
template and then size my main window and the splitter panes appropriately.
Hope that makes more sense.
Cheers
David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
If you call GetClientRect on the view itself, you should get the right
size. Where are you calling this from?
---
Ajay
Tom Serface
2008-04-03 13:19:29 UTC
Permalink
You can get a pointer to the view using something like:

CMyView *m_pMyView;

m_pMyView = (CMyView*)m_wndMySplitter.GetPane(0,0);

If you know the pane where the view was added.

Tom
Post by Jonathan Wood
Jonathan
I have tried this but I only get the size of the view after it is added to
the splitter pane.
The problem seems to be, or at least my problem which could be self
induced, is that I create a static splitter window (CSplitterWnd) and then
add the views. These views are added by a CRuntimeClass pointer, hence
there is no tangible CView at this stage to run the GetClientRect() on.
When you add the view you specify a size parameter to AddView() which I do
not know how to fill in, hence the original problem.
To get around this I thought I could just come up with a size for the
create view and then adjust it later with the SetRowInfo(), etc calls. So
once I have added the view I can get the CWnd for the view with GetPane()
and this is then my tangible view created for the splitter. However if I
now lookup the size of this view it reports the splitter pane size I set
when I added the view rather than the original size if the view.
Surely I am doing something obviously wrong here as this cannot be that
difficult! The problem as I see it is that I never create the view
instance in my code and hence cannot do the size lookup there. The view
create is hidden inside the splitter class AddView() call.
Cheers
David.
P.S. As far as I could tell you posted the reply to me to the newsgroup
not to my email, so I don't understand the thread comments after.
Post by Ajay Kalra
Post by David Bilsby
Hi
Sorry I probably was not clear enough.
I want to be able to call the SetRowInfo/SetColumnInfo members, however
I do not know what size the CFormView is. If I try and call
GetClientRect() it simply returns the size of the splitter pane which
may be bigger or smaller than the CFormView it contains. I just want to
be able to find the size of the CFormView as set in the resource
template and then size my main window and the splitter panes
appropriately.
Hope that makes more sense.
Cheers
David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
If you call GetClientRect on the view itself, you should get the right
size. Where are you calling this from?
---
Ajay
David Bilsby
2008-04-03 14:51:38 UTC
Permalink
Tom
Yes I can do that but as I said below if you then call GetClientRect()
on the CView/CFormView returned by the GetPane(), the size returned is
the size of the pane specified when you did the AddView() on the
CSplitterWnd, that is the view has taken on the size of the splitter
pane and that is what it is returning to you not the size it was defined
as in its resource template.

David.
Post by Tom Serface
CMyView *m_pMyView;
m_pMyView = (CMyView*)m_wndMySplitter.GetPane(0,0);
If you know the pane where the view was added.
Tom
Post by Jonathan Wood
Jonathan
I have tried this but I only get the size of the view after it is
added to the splitter pane.
The problem seems to be, or at least my problem which could be self
induced, is that I create a static splitter window (CSplitterWnd) and
then add the views. These views are added by a CRuntimeClass pointer,
hence there is no tangible CView at this stage to run the
GetClientRect() on. When you add the view you specify a size parameter
to AddView() which I do not know how to fill in, hence the original
problem.
To get around this I thought I could just come up with a size for the
create view and then adjust it later with the SetRowInfo(), etc calls.
So once I have added the view I can get the CWnd for the view with
GetPane() and this is then my tangible view created for the splitter.
However if I now lookup the size of this view it reports the splitter
pane size I set when I added the view rather than the original size if
the view.
Surely I am doing something obviously wrong here as this cannot be
that difficult! The problem as I see it is that I never create the
view instance in my code and hence cannot do the size lookup there.
The view create is hidden inside the splitter class AddView() call.
Cheers
David.
P.S. As far as I could tell you posted the reply to me to the
newsgroup not to my email, so I don't understand the thread comments
after.
Post by Ajay Kalra
Post by David Bilsby
Hi
Sorry I probably was not clear enough.
I want to be able to call the SetRowInfo/SetColumnInfo members, however
I do not know what size the CFormView is. If I try and call
GetClientRect() it simply returns the size of the splitter pane which
may be bigger or smaller than the CFormView it contains. I just want to
be able to find the size of the CFormView as set in the resource
template and then size my main window and the splitter panes appropriately.
Hope that makes more sense.
Cheers
David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
If you call GetClientRect on the view itself, you should get the right
size. Where are you calling this from?
---
Ajay
Tom Serface
2008-04-03 17:09:51 UTC
Permalink
Ah, sorry, I missed that part. I remember having this problem in the past
when I wanted my default view for a splitter and formview to not have the
formview scroll. I ended up using the resizable lib code to have it resize
controls, but for the default size I wanted it to fit so I ended up just
changing the values until it ran as expected. Part of the problem is that
the dialog resources is in a different type of unit than the window that is
created so I couldn't figure out a good way to calculate it from the current
size of the resource. I'm sure there is a way, but I only had to do this
once and trial and error was easier.

Tom
Tom
Yes I can do that but as I said below if you then call GetClientRect() on
the CView/CFormView returned by the GetPane(), the size returned is the
size of the pane specified when you did the AddView() on the CSplitterWnd,
that is the view has taken on the size of the splitter pane and that is
what it is returning to you not the size it was defined as in its resource
template.
David.
Post by Tom Serface
CMyView *m_pMyView;
m_pMyView = (CMyView*)m_wndMySplitter.GetPane(0,0);
If you know the pane where the view was added.
Tom
Post by Jonathan Wood
Jonathan
I have tried this but I only get the size of the view after it is added
to the splitter pane.
The problem seems to be, or at least my problem which could be self
induced, is that I create a static splitter window (CSplitterWnd) and
then add the views. These views are added by a CRuntimeClass pointer,
hence there is no tangible CView at this stage to run the
GetClientRect() on. When you add the view you specify a size parameter
to AddView() which I do not know how to fill in, hence the original
problem.
To get around this I thought I could just come up with a size for the
create view and then adjust it later with the SetRowInfo(), etc calls.
So once I have added the view I can get the CWnd for the view with
GetPane() and this is then my tangible view created for the splitter.
However if I now lookup the size of this view it reports the splitter
pane size I set when I added the view rather than the original size if
the view.
Surely I am doing something obviously wrong here as this cannot be that
difficult! The problem as I see it is that I never create the view
instance in my code and hence cannot do the size lookup there. The view
create is hidden inside the splitter class AddView() call.
Cheers
David.
P.S. As far as I could tell you posted the reply to me to the newsgroup
not to my email, so I don't understand the thread comments after.
Post by Ajay Kalra
Post by David Bilsby
Hi
Sorry I probably was not clear enough.
I want to be able to call the SetRowInfo/SetColumnInfo members, however
I do not know what size the CFormView is. If I try and call
GetClientRect() it simply returns the size of the splitter pane which
may be bigger or smaller than the CFormView it contains. I just want to
be able to find the size of the CFormView as set in the resource
template and then size my main window and the splitter panes appropriately.
Hope that makes more sense.
Cheers
David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
If you call GetClientRect on the view itself, you should get the right
size. Where are you calling this from?
---
Ajay
Jonathan Wood
2008-04-02 00:07:56 UTC
Permalink
Can I ask that you keep this posts in the newsgroups where you have the
benefit of having multiple seeing them and having the opportunity to chime
in? Thanks.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by David Bilsby
Hi
Sorry I probably was not clear enough.
I want to be able to call the SetRowInfo/SetColumnInfo members, however I
do not know what size the CFormView is. If I try and call GetClientRect()
it simply returns the size of the splitter pane which may be bigger or
smaller than the CFormView it contains. I just want to be able to find the
size of the CFormView as set in the resource template and then size my
main window and the splitter panes appropriately.
Hope that makes more sense.
Cheers
David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
Tom Serface
2008-04-02 00:38:41 UTC
Permalink
Jonathan,

Did you mean to email this to him?

Tom
Post by Jonathan Wood
Can I ask that you keep this posts in the newsgroups where you have the
benefit of having multiple seeing them and having the opportunity to chime
in? Thanks.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by David Bilsby
Hi
Sorry I probably was not clear enough.
I want to be able to call the SetRowInfo/SetColumnInfo members, however I
do not know what size the CFormView is. If I try and call GetClientRect()
it simply returns the size of the splitter pane which may be bigger or
smaller than the CFormView it contains. I just want to be able to find
the size of the CFormView as set in the resource template and then size
my main window and the splitter panes appropriately.
Hope that makes more sense.
Cheers
David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
Jonathan Wood
2008-04-02 16:53:17 UTC
Permalink
I guess... I just responded to an email that was sent me.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by Tom Serface
Jonathan,
Did you mean to email this to him?
Tom
Post by Jonathan Wood
Can I ask that you keep this posts in the newsgroups where you have the
benefit of having multiple seeing them and having the opportunity to
chime in? Thanks.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by David Bilsby
Hi
Sorry I probably was not clear enough.
I want to be able to call the SetRowInfo/SetColumnInfo members, however
I do not know what size the CFormView is. If I try and call
GetClientRect() it simply returns the size of the splitter pane which
may be bigger or smaller than the CFormView it contains. I just want to
be able to find the size of the CFormView as set in the resource
template and then size my main window and the splitter panes
appropriately.
Hope that makes more sense.
Cheers
David.
Post by Jonathan Wood
I'm not certain I understand exactly. Can't you just call
SetRowInfo/SetColumnInfo and then RecalcLayout?
It's hard to say without seeing what you are describing but isn't the
scroll range determined by the CFormView? You just need to tell the
splitter window.
Joseph M. Newcomer
2008-04-02 05:09:10 UTC
Permalink
I cheated. I created a CStatic frame control as large as my dialog, marked it as
invisible, changed its name from IDC_STATIC to IDC_FRAME, and then did a
GetWindowRect/ScreenToClient to find out how wide it was.
joe
Post by David Bilsby
All
I am creating an SDI with a splitter and several views based on the
CFormView. I can create and attach them to the CSplitterWnd control
fine, but I want to be able to set the splitters split sizes based on
the size of the form view attached to it.
The form views are defined in a template resource and so have a fixed
size. How to I get this size and then set the splitters pane sizes? The
information must be stored somewhere as when you shrink the splitter via
the divider bar, at some point the pane containing the form view gets a
set of scroll bars added, hence the pane size must be smaller than the
original form views size.
Help much appreciated.
Cheers
David
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
David Bilsby
2008-04-03 15:12:07 UTC
Permalink
All
Thanks for all the suggestions, sadly most I have tried and do not
work. However by a set of coincidences I have found a partial solution
to this problem which sort of ties up with the behaviour I was seeing.

As I said originally if you resize the window or adjust the splitter
bar, at some point the CFormView added a set of scrollbars when the pane
became smaller than the views resource template defined it to be.
Therefore the CFormView must have this information somewhere inside it.

This is indeed the case and it is stored away in a CSize called
m_totalDev. Unfortunately this is protected, however the total view size
can be retrieved by a call to GetTotalSize() (or GetDeviceScrollSizes()
but this returns a hole load of other stuff as well).

With this I can get the size, which I think are in pixels (MSDN says
they are logical units), of the two CFormViews making up my splitter. I
can then use the SetColumnInfo() member to set the widths of the panes
appropriately.

The problem I still have is that despite all of this, if I try and set
the parent window size with MoveWindow() to the pane width or heights,
there must be a few pixels I am missing in the calculation somewhere as
the panes still get scrollbars added.

I first get the CFormView size with GetTotalSize(). Then I get the main
frames client size with GetClientRect(). I then get the windows actual
screen size with GetWindowRect(). From the main frames client rect and
the windows rect I can calculate the extra width and height of the
window borders. This I can add onto the height of my largest CFormView
and also the combined width of my two CFormViews (as they are setup 2
columns 1 row in the splitter).

The problem seems to be however that the CStatusBar in my SDI is not
taken into account by the GetWindowRect() calculation. Also the width
calculation I do does not include the width of the splitter bar, in fact
I have no idea how to find the width of this. NOTE: If you do a
GetClientRect() on the two CFormViews you get the same cumulative value
as the the GetClientRect() lookup on the main frame, therefore the
client rectangle as retrieved does not seem to take into account the
splitter bar either.

In summary. The partial solution to the problem is to use
GetTotalSize(), however this only works on a CFormView derived class.

David.
Post by David Bilsby
All
I am creating an SDI with a splitter and several views based on the
CFormView. I can create and attach them to the CSplitterWnd control
fine, but I want to be able to set the splitters split sizes based on
the size of the form view attached to it.
The form views are defined in a template resource and so have a
fixed size. How to I get this size and then set the splitters pane
sizes? The information must be stored somewhere as when you shrink the
splitter via the divider bar, at some point the pane containing the form
view gets a set of scroll bars added, hence the pane size must be
smaller than the original form views size.
Help much appreciated.
Cheers
David
Ian Semmel
2008-04-03 19:04:22 UTC
Permalink
I think that if you use something like

RECT screen;

BOOL rv = SystemParametersInfo ( SPI_GETWORKAREA, 0, & screen, 0 );

you get a more accurate size of what you are using for your splitter
window.

I have found that including the size in CreateView gives a better result
than using SetRowInfo etc.

(I do find split windows a bit confusing sometimes. They seem to have a
mind of their own)
Post by David Bilsby
All
Thanks for all the suggestions, sadly most I have tried and do not
work. However by a set of coincidences I have found a partial solution
to this problem which sort of ties up with the behaviour I was seeing.
As I said originally if you resize the window or adjust the splitter
bar, at some point the CFormView added a set of scrollbars when the pane
became smaller than the views resource template defined it to be.
Therefore the CFormView must have this information somewhere inside it.
This is indeed the case and it is stored away in a CSize called
m_totalDev. Unfortunately this is protected, however the total view size
can be retrieved by a call to GetTotalSize() (or GetDeviceScrollSizes()
but this returns a hole load of other stuff as well).
With this I can get the size, which I think are in pixels (MSDN says
they are logical units), of the two CFormViews making up my splitter. I
can then use the SetColumnInfo() member to set the widths of the panes
appropriately.
The problem I still have is that despite all of this, if I try and set
the parent window size with MoveWindow() to the pane width or heights,
there must be a few pixels I am missing in the calculation somewhere as
the panes still get scrollbars added.
I first get the CFormView size with GetTotalSize(). Then I get the main
frames client size with GetClientRect(). I then get the windows actual
screen size with GetWindowRect(). From the main frames client rect and
the windows rect I can calculate the extra width and height of the
window borders. This I can add onto the height of my largest CFormView
and also the combined width of my two CFormViews (as they are setup 2
columns 1 row in the splitter).
The problem seems to be however that the CStatusBar in my SDI is not
taken into account by the GetWindowRect() calculation. Also the width
calculation I do does not include the width of the splitter bar, in fact
I have no idea how to find the width of this. NOTE: If you do a
GetClientRect() on the two CFormViews you get the same cumulative value
as the the GetClientRect() lookup on the main frame, therefore the
client rectangle as retrieved does not seem to take into account the
splitter bar either.
In summary. The partial solution to the problem is to use
GetTotalSize(), however this only works on a CFormView derived class.
David.
Post by David Bilsby
All
I am creating an SDI with a splitter and several views based on
the
Post by David Bilsby
CFormView. I can create and attach them to the CSplitterWnd control
fine, but I want to be able to set the splitters split sizes based on
the size of the form view attached to it.
The form views are defined in a template resource and so have a
fixed size. How to I get this size and then set the splitters pane
sizes? The information must be stored somewhere as when you shrink the
splitter via the divider bar, at some point the pane containing the
form
Post by David Bilsby
view gets a set of scroll bars added, hence the pane size must be
smaller than the original form views size.
Help much appreciated.
Cheers
David
David Bilsby
2008-04-04 13:54:32 UTC
Permalink
Ian
I think you may have misunderstood the problem, or I have misunderstood
your reply.

I had a look at SystemParametersInfo() but it seems to be retrieving
the desktop screen area. I want to try and find the client area of an
SDI application which has a tool bar and status bar. I am not trying to
make the SDI window the size of the usable screen area.

Cheers

David.
Post by Ian Semmel
I think that if you use something like
RECT screen;
BOOL rv = SystemParametersInfo ( SPI_GETWORKAREA, 0, & screen, 0 );
you get a more accurate size of what you are using for your splitter
window.
I have found that including the size in CreateView gives a better result
than using SetRowInfo etc.
(I do find split windows a bit confusing sometimes. They seem to have a
mind of their own)
Post by David Bilsby
All
Thanks for all the suggestions, sadly most I have tried and do not
work. However by a set of coincidences I have found a partial solution
to this problem which sort of ties up with the behaviour I was seeing.
As I said originally if you resize the window or adjust the splitter
bar, at some point the CFormView added a set of scrollbars when the pane
became smaller than the views resource template defined it to be.
Therefore the CFormView must have this information somewhere inside it.
This is indeed the case and it is stored away in a CSize called
m_totalDev. Unfortunately this is protected, however the total view size
can be retrieved by a call to GetTotalSize() (or GetDeviceScrollSizes()
but this returns a hole load of other stuff as well).
With this I can get the size, which I think are in pixels (MSDN says
they are logical units), of the two CFormViews making up my splitter. I
can then use the SetColumnInfo() member to set the widths of the panes
appropriately.
The problem I still have is that despite all of this, if I try and set
the parent window size with MoveWindow() to the pane width or heights,
there must be a few pixels I am missing in the calculation somewhere as
the panes still get scrollbars added.
I first get the CFormView size with GetTotalSize(). Then I get the main
frames client size with GetClientRect(). I then get the windows actual
screen size with GetWindowRect(). From the main frames client rect and
the windows rect I can calculate the extra width and height of the
window borders. This I can add onto the height of my largest CFormView
and also the combined width of my two CFormViews (as they are setup 2
columns 1 row in the splitter).
The problem seems to be however that the CStatusBar in my SDI is not
taken into account by the GetWindowRect() calculation. Also the width
calculation I do does not include the width of the splitter bar, in fact
I have no idea how to find the width of this. NOTE: If you do a
GetClientRect() on the two CFormViews you get the same cumulative value
as the the GetClientRect() lookup on the main frame, therefore the
client rectangle as retrieved does not seem to take into account the
splitter bar either.
In summary. The partial solution to the problem is to use
GetTotalSize(), however this only works on a CFormView derived class.
David.
Post by David Bilsby
All
I am creating an SDI with a splitter and several views based on
the
Post by David Bilsby
CFormView. I can create and attach them to the CSplitterWnd control
fine, but I want to be able to set the splitters split sizes based on
the size of the form view attached to it.
The form views are defined in a template resource and so have a
fixed size. How to I get this size and then set the splitters pane
sizes? The information must be stored somewhere as when you shrink the
splitter via the divider bar, at some point the pane containing the
form
Post by David Bilsby
view gets a set of scroll bars added, hence the pane size must be
smaller than the original form views size.
Help much appreciated.
Cheers
David
Ian Semmel
2008-04-04 19:06:00 UTC
Permalink
My mistake, sorry. I was looking at code where I actually use the whole
screen and divide it up.
Post by David Bilsby
Ian
I think you may have misunderstood the problem, or I have misunderstood
your reply.
I had a look at SystemParametersInfo() but it seems to be retrieving
the desktop screen area. I want to try and find the client area of an
SDI application which has a tool bar and status bar. I am not trying to
make the SDI window the size of the usable screen area.
Cheers
David.
Post by Ian Semmel
I think that if you use something like
RECT screen;
BOOL rv = SystemParametersInfo ( SPI_GETWORKAREA, 0, & screen,
0 );
Post by Ian Semmel
you get a more accurate size of what you are using for your splitter
window.
I have found that including the size in CreateView gives a better
result
Post by Ian Semmel
than using SetRowInfo etc.
(I do find split windows a bit confusing sometimes. They seem to have
a
Post by Ian Semmel
mind of their own)
Post by David Bilsby
All
Thanks for all the suggestions, sadly most I have tried and do not
work. However by a set of coincidences I have found a partial
solution
Post by Ian Semmel
Post by David Bilsby
to this problem which sort of ties up with the behaviour I was
seeing.
Post by Ian Semmel
Post by David Bilsby
As I said originally if you resize the window or adjust the splitter
bar, at some point the CFormView added a set of scrollbars when the
pane
Post by Ian Semmel
Post by David Bilsby
became smaller than the views resource template defined it to be.
Therefore the CFormView must have this information somewhere inside
it.
Post by Ian Semmel
Post by David Bilsby
This is indeed the case and it is stored away in a CSize called
m_totalDev. Unfortunately this is protected, however the total view
size
Post by Ian Semmel
Post by David Bilsby
can be retrieved by a call to GetTotalSize() (or
GetDeviceScrollSizes()
Post by Ian Semmel
Post by David Bilsby
but this returns a hole load of other stuff as well).
With this I can get the size, which I think are in pixels (MSDN says
they are logical units), of the two CFormViews making up my splitter.
I
Post by Ian Semmel
Post by David Bilsby
can then use the SetColumnInfo() member to set the widths of the
panes
Post by Ian Semmel
Post by David Bilsby
appropriately.
The problem I still have is that despite all of this, if I try and
set
Post by Ian Semmel
Post by David Bilsby
the parent window size with MoveWindow() to the pane width or
heights,
Post by Ian Semmel
Post by David Bilsby
there must be a few pixels I am missing in the calculation somewhere
as
Post by Ian Semmel
Post by David Bilsby
the panes still get scrollbars added.
I first get the CFormView size with GetTotalSize(). Then I get the
main
Post by Ian Semmel
Post by David Bilsby
frames client size with GetClientRect(). I then get the windows
actual
Post by Ian Semmel
Post by David Bilsby
screen size with GetWindowRect(). From the main frames client rect
and
Post by Ian Semmel
Post by David Bilsby
the windows rect I can calculate the extra width and height of the
window borders. This I can add onto the height of my largest
CFormView
Post by Ian Semmel
Post by David Bilsby
and also the combined width of my two CFormViews (as they are setup 2
columns 1 row in the splitter).
The problem seems to be however that the CStatusBar in my SDI is not
taken into account by the GetWindowRect() calculation. Also the width
calculation I do does not include the width of the splitter bar, in
fact
Post by Ian Semmel
Post by David Bilsby
I have no idea how to find the width of this. NOTE: If you do a
GetClientRect() on the two CFormViews you get the same cumulative
value
Post by Ian Semmel
Post by David Bilsby
as the the GetClientRect() lookup on the main frame, therefore the
client rectangle as retrieved does not seem to take into account the
splitter bar either.
In summary. The partial solution to the problem is to use
GetTotalSize(), however this only works on a CFormView derived class.
David.
Post by David Bilsby
All
I am creating an SDI with a splitter and several views based on
the
Post by David Bilsby
CFormView. I can create and attach them to the CSplitterWnd control
fine, but I want to be able to set the splitters split sizes based
on
Post by Ian Semmel
Post by David Bilsby
Post by David Bilsby
the size of the form view attached to it.
The form views are defined in a template resource and so have a
fixed size. How to I get this size and then set the splitters pane
sizes? The information must be stored somewhere as when you shrink
the
Post by Ian Semmel
Post by David Bilsby
Post by David Bilsby
splitter via the divider bar, at some point the pane containing the
form
Post by David Bilsby
view gets a set of scroll bars added, hence the pane size must be
smaller than the original form views size.
Help much appreciated.
Cheers
David
Loading...