Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - ResizeFormView in child frame with splitters
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ResizeFormView in child frame with splitters

 Post Reply Post Reply
Author
Message
dmcminn_mwd View Drop Down
Newbie
Newbie


Joined: 03 October 2007
Location: United Kingdom
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote dmcminn_mwd Quote  Post ReplyReply Direct Link To This Post Topic: ResizeFormView in child frame with splitters
    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.
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2007 at 7:33am
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
Back to Top
dmcminn_mwd View Drop Down
Newbie
Newbie


Joined: 03 October 2007
Location: United Kingdom
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote dmcminn_mwd Quote  Post ReplyReply Direct Link To This Post Posted: 19 October 2007 at 9:52am
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.
 
Back to Top
dmcminn_mwd View Drop Down
Newbie
Newbie


Joined: 03 October 2007
Location: United Kingdom
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote dmcminn_mwd Quote  Post ReplyReply Direct Link To This Post Posted: 22 October 2007 at 4:48am
Hi,
 
I traced the execution of my code and what the toolkit library does. The flow of function calls through my code is this:
CChildFrame::OnCreateClient: Creating control view
1 CCJ_XTResizeFormView::OnCreate: Enter
2 CCJ_XTResizeFormView::OnCreate: Designed width=222 height=650
3 CCJ_XTResizeFormView::OnSize: new width=222 height=650
4 CCJ_XTResizeFormView::OnInitDialog: Enter, window rect width=222 height=650
5 CCJ_XTResizeFormView::OnInitDialog: Enter, client rect width=222 height=650
6 CCJ_XTResizeFormView::OnInitDialog: Enter, init width=0 height=0
7 CCJ_XTResizeFormView::OnInitDialog: Enter, init width=0 height=0
8 CCJ_XTResizeFormView::OnInitDialog: After window rect width=222 height=650
9 CCJ_XTResizeFormView::OnInitDialog: After, client rect width=222 height=650
10 CCJ_XTResizeFormView::OnInitDialog: After, init width=222 height=650
11 CCJ_XTResizeFormView::OnInitDialog: After, min width=222 height=650
12 CCJ_XTResizeFormView::OnSize: new width=223 height=650
13 CChildFrame::OnCreateClient: Creating dummy view
14 CCJ_XTResizeFormView::OnSize: new width=223 height=430
 
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).
 
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.048 seconds.