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 BilsbyAll
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