How can I change the size of my FormView dynamically
I created a splitter window creating two sides/columns (the left side and the right side).
Both sides are FormViews (CFormLeft and CFormRight).

In my CFormLeft, I have a for-loop that displays another FormView N times.
But since the creation of these new FormViews are dynamic, then the scrollbar for the left side (CFormLeft) would not be activated and the rest of the dynamically created displays cannot be shown.

I would like to dynamically adjust my CFormLeft size.
Is this possible

I only want to activate the scrollbar and let it scroll up/down so that all the dynamically created views will be shown.

Re: Visual C++ General how to dynamically resize FormView


Hi kaye.

SetWindowPos or MoveWindow function can do re-sizing an window.

Reference this page.


Good Luck.

Re: Visual C++ General how to dynamically resize FormView



I tried using the SetWindowPos and MoveWindow but to no avail.
Still the size of the FormView did not change and the scroll bar did not show.
(Vertical Scroll Bar already enabled, set to True)

Re: Visual C++ General how to dynamically resize FormView


I'm so sorry.

I just tested.

I think there are more good methods.

Try this code. It'll work

Code Snippet
MoveWindow(10,10, 100,100, TRUE);
CFrameWnd* pFrame = GetParentFrame();
pFrame->SendMessage(WM_SIZE, SIZE_RESTORED, MAKELPARAM(100,100));

And read this article on codeproject.

It'll help.


Re: Visual C++ General how to dynamically resize FormView

Simple Samples

I have done that kind of thing a few times. That is, I resize the controls in a window when the window is resized.

I suggest using a CView or CScrollView instead of a CFormView because the logic to resize controls can be used to initially place them too. It does not make a big difference; just a minor suggestion.

What I do is to process WM_SIZE (OnSize) in the frame window and do the move and/or resize there of the controls. I first check to ensure that the WM_SIZE is for a restore or a maximize. I also ignore OnSize if the width or height is zero. After that, the logic needed to do the resize and all that depends on your requirements.