![]() |
ResizeFormView in child frame with splitters |
Post Reply ![]() |
Author | |
dmcminn_mwd ![]() Newbie ![]() Joined: 03 October 2007 Location: United Kingdom Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() Posted: 19 October 2007 at 5:39am |
Hello,
I'm trying to get a resize form view working in my current application (MFC MDI with splitter in child frame showing two views). I have previously got resizable dialogs to work and have done the resizable forms in a similar way and I can get my form view resized.
However, the controls are all initally resized so that they are not as wide as I would expect - before I added the resizing code they would fill the left pane of the splitter exactly as designed.
It looks as if they are not as wide by the width of a scrollbar. It could be possible since my form view design is quite tall, although when maximised (set on create) it will fit vertically without requiring a scrollbar. I'm probably doing something stupid when I create the splitter and views in my child frame but I can't figure out what.
Does anyone have any experience they could offer?
An example solution (MSVC2005) which shows the problem is here: http://www.david-mcminn.co.uk/files/resizeform.zip
Thanks.
Edit: It is exactly the size of a scrollbar that the control is smaller by. If you download the above solution, trying commenting out line 84 of CJ_XTResizeFormView.cpp to compare what it is like.
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
When it comes first it shows scrollbars and CXTResize get wrong width.
Just increase size a little:
if (m_LRSplitter.CreateStatic(this, 1, 2, WS_CHILD | WS_VISIBLE | WS_BORDER)){ m_LRSplitter.SetFullDrag(FALSE); m_LRSplitter.SetSplitterStyle(XT_SPLIT_DOTTRACKER|XT_SPLIT_NOFULLDRAG); if(m_LRSplitter.CreateView(0, 0, RUNTIME_CLASS(CCJ_XTResizeFormView), CSize(230, 0), pContext)){ create_ok = m_LRSplitter.CreateView(0, 1, RUNTIME_CLASS(CDummyView), CSize(0, 0), pContext);} } // L/R control/display splitter created OK if(create_ok){ CCJ_XTResizeFormView *control_view = static_cast<CCJ_XTResizeFormView *>(m_LRSplitter.GetPane(0, 0)); //m_LRSplitter.SetColumnInfo(0, control_view->GetDesignedRect().Width(), control_view->GetDesignedRect().Width()); m_LRSplitter.SetColumnInfo(1, 0, 0);} |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
dmcminn_mwd ![]() Newbie ![]() Joined: 03 October 2007 Location: United Kingdom Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
Hi Oleg,
Thanks for the response. After you mentioned that I had made the pane too small I traced the execution, checking the form view's width at each stage. The width was 222 pixels, but the pane had to be set to 223 for it to show the correct size. I tried a variety of initial sizes and here was what I found:
<=220 - ok, shows scrollbar at bottom
221 - not ok, scrollbar at bottom, no scrollbar at right but space for it
222 - not ok, no scrollbars but space on right for scrollbar
>=223 - ok
I've seen a lot of Windows applications have trouble to decide when to show scrollbars when on the minimum limits. I guess this is a problem with the underlying CScrollView or the window's native classes.
But thank you for pointing me on the correct track.
|
|
![]() |
|
dmcminn_mwd ![]() Newbie ![]() Joined: 03 October 2007 Location: United Kingdom Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
Hi,
I traced the execution of my code and what the toolkit library does. The flow of function calls through my code is this:
On lines 3-4 this first OnSize shows the designed size of the form which is correct, and the controls will be created at their correct positions. I set up my resize items after line 11. Line 12 is the size message sent by the splitter using the sizes I specify at the start of this sequence (before line 1). Line 14 is the CScrollView base class trying to set various sizes.
If I set the size of the splitter pane to CSize(0,0) then the XTResize::Size() returns before doing anything. Similarly if I set the pane size to be the exact size required for the form view then XTResize::Size() returns before doing anything because it thinks the window size has not changed.
If I set the size to something different from the exact size (e.g. 1 pixel wider) then XTResize::Size() performs it's processing but then it sets the resize item's sizes to something incorrect (the degree of incorrect is determined by how different the sizes I specify are from the designed sizes) and sets their m_bInitialSize flag. The controls are then all resized from an incorrect base size.
Is there some way to force a call to Size() using the current window sizes as the initial size?
Edit: a bit of a hack, but I've just went through the m_arrItems setting their m_bInitialSize to true after I've set their resizes (since that finds their correct sizes without having to get a WM_SIZE message).
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |