CScrollView: Get rid of the scrollbars!
Hi all,
I have a CFormView derived class.
I wanted to implement dynamic control resizing in it when the user resizes the CFrameWnd so I overrided the view's OnSize() and called MoveWindow() for each control. All went fine except some (not so annoying) flickering of the controls.
But when the user sizes the formview to a size less than the starting size the scrollbars appear. I guess that is because of CScrollView functionality of CFormView. But since I resize the controls myself I do not want the scrollbars. I tried in OnSize()
SetScaleToFitSize(CSize(cx, cy));
which solves the problem, but the flickering becomes very annoying...
Any ideas on how to get rid of the scrollbars (without the flickering)?
[750 byte] By [
panayotisk] at [2007-11-18 19:16:32]

# 1 Re: CScrollView: Get rid of the scrollbars!
Play a bit with the clipchildren and clipsiblings settings.
Marc G at 2007-11-11 1:17:58 >

# 2 Re: CScrollView: Get rid of the scrollbars!
Could you provide some more info? I have no idea what these settings are...
# 3 Re: CScrollView: Get rid of the scrollbars!
I don't know if it will solve your problem, but you could try it.
What I mean are the WS_CLIPCHILDREN and WS_CLIPSIBLINGS windowstyles. You can try to set for example WS_CLIPCHILDREN on your CFormView dialog template (in the dialog resource editor, it's called "clip children").
Marc G at 2007-11-11 1:19:59 >

# 4 Re: CScrollView: Get rid of the scrollbars!
Setting WS_CLIPCHILDREN solved the problem. Now there is no flickering at all.
Thanx a lot
Panayotis
# 5 Re: CScrollView: Get rid of the scrollbars!
You're welcome ;)
Marc G at 2007-11-11 1:22:03 >

# 6 Re: CScrollView: Get rid of the scrollbars!
I got stuck using SetScaleToFitSize to avoid scrollbars.
I am having a working model where there is view to display bitmaps but problem is that i want the image to fit in the window always.
So instead of setscrollsize, i m using SetScaleToFitSize but then i am getting the assertion error.
I even use the recalclayout() function before calling the SetScale.. Function.
I am quite new to MFC, so here are really basic queries.
--how can get the size of view window.
--what does the arguments to ONSize reperesents
Can any one help me on the topic???
Thanks in advance
Mohit
# 7 Re: CScrollView: Get rid of the scrollbars!
Please post your OnSize()
What is the assertion?
# 8 Re: CScrollView: Get rid of the scrollbars!
void CmyView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
if (m_hWnd)
CreateClientDIB();
}
CmyView is derived from CScrollView.
I am trying to use setscale.. function in this class.
But i got the following error
[QUOTE]
Debug Assertion Failed.
[QUOTE]
When i try to debug it takes me to this line
[QUOTE]ASSERT(m_nMapMode > 0);[QUOTE]
Plz help
# 9 Re: CScrollView: Get rid of the scrollbars!
cx and cy are the new view coordinates.
Probably the problem is that CreateClientDIB() uses controls in the view that are not yet created... A WM_SIZE message is sent early in the view initilization process.
But it should not be SetScaleToFitSize() that causes the problem.
# 10 Re: CScrollView: Get rid of the scrollbars!
If i use setscrollsize instead of setscalefit..
then everything works fine, but i don't want the scrollbars.
What i need is that image always fit to the view window.
Mohit
# 11 Re: CScrollView: Get rid of the scrollbars!
Originally posted by panayotisk
But when the user sizes the formview to a size less than the starting size the scrollbars appear. I guess that is because of CScrollView functionality of CFormView. But since I resize the controls myself I do not want the scrollbars.It's quite simple: CFormView uses the initial size of the associated dialog resource template to determine when to show the scroll bars. So just define a very small dialog area in the resource editor, and you won't get the scrollbars.
# 12 Re: CScrollView: Get rid of the scrollbars!
but the problem is if the image is bigger then the screen resolution then i need the image to shrink to fit in the viewable area.
So i am using SetScaleToFitSize function and it is giving me assertion failure.
# 13 Re: CScrollView: Get rid of the scrollbars!
Originally posted by gstercken
So just define a very small dialog area in the resource editor, and you won't get the scrollbars.
Right. I do not remember why I did not do that. But this looks like the simplest solution.
Originally posted by mohit_sws
...but the problem is if the image is bigger then the screen resolution then i need the image to shrink to fit in the viewable area
SetScaleToFitSize() shrinks or enlarges the view according to the shrinking or enlarging of the Frame window. You should size the image yourself.
Provide full stack trace information of the assertion (e.g. which function calls ASSERT(m_nMapMode > 0); and which function calls this function e.t.c.)
Also provide the code of CreateClientDIB().
We can't help with the info you provided, only make guesses.