Re: MFC Scrollbar Problems
Have you considering using a CFormView inside of a CFrameWnd instead of a CDialog?
<spineybabbler@gmail.com> wrote in message
news:668bd84f-8fd9-4ccf-92be-acec2177b178@n7g2000prc.googlegroups.com...
Hi,
My dialog has lot of controls in it and the dialog is resizable.
Whenever size is smaller than certain threshold i create scroll
bar.Whenever size increases beyond a threshold i remove scrollbar. The
thing that I have to do is to make sure that whenever dialog is
resized the dialog should be scrolled properly. The code I have
written works properly when I resize window slowly (dragging mouse
slowly while resizing) but when I drag the mouse fast the dialog is
not properly scrolled. Here is what I am doing in my OnSize().
void CDlg::OnSize(UINT nType, int cx, int cy)
{
ScrollWindow(h_scrollPos-GetScrollPos(SB_HORZ),0,NULL,NULL);
h_scrollPos=GetScrollPos(SB_HORZ);
ScrollWindow(v_scrollPos-GetScrollPos(SB_VERT),0,NULL,NULL);
v_scrollPos=GetScrollPos(SB_VERT);
//set scroll bar
SetScrollBar();
}
void CDlg::SetScrollBar()
{
if(logicalHeight>pageHeight)
{
SCROLLINFO si;
si.cbSize=sizeof(SCROLLINFO);
si.fMask=SIF_ALL;
si.nMax=logicalHeight;
si.nMin=0;
si.nPos=v_scrollPos;
si.nPage=pageHeight;
si.nTrackPos=2;
SetScrollInfo(SB_VERT,&si,true);
}
if(logicalWidth>pageWidth)
{
SCROLLINFO hsi;
hsi.cbSize=sizeof(SCROLLINFO);
hsi.fMask=SIF_ALL;
hsi.nMax=logicalWidth;
hsi.nMin=0;
hsi.nPos=h_scrollPos;
hsi.nPage=pageWidth;
hsi.nTrackPos=2;
SetScrollInfo(SB_HORZ,&hsi,true);
}
ShowScrollBar(SB_VERT,logicalHeight>=pageHeight);
ShowScrollBar(SB_HORZ,logicalWidth>=pageWidth);
}
logicalWidth and logicalHeight are actual width and height that is
sufficient to show all the contents. pageWidth and pageHeight are
current width and height.
Any help would be highly appreciated. Anyone?