|
-
July 27th, 2012, 03:54 AM
#1
Scroll Range not being set correctly during MDITile/MDICascade/SetWindowPos
Hello,
My current setup involves an MDI infrastructure with a fixed number of child windows (CFormView), each window with different controls, ranging from a single control to five or six. I am using http://www.codeproject.com/Articles/...indow-Resizing for resizing purposes. This resizing class works great when resized manually, ie. using the mouse to drag the child border edges. However, when the size is set programatically and the resulting sizes require scroll bars the actual child window will resize fine, but its controls will be compressed (see image file).
I have traced the error to the OnSize function in the resizing class; the resizer calls the following:
Code:
void CWndResizer::GetTrueClientRect(CWnd * pWnd, CRect * prc)
{
int nMin = 0;
int nMax = 0;
int nCur = 0;
pWnd->GetClientRect(prc);
if ( (pWnd->GetStyle() & WS_HSCROLL) > 0)
{
pWnd->GetScrollRange(SB_HORZ, &nMin, &nMax);
nCur = pWnd->GetScrollPos(SB_HORZ);
prc->right = prc->left + nMax;
prc->OffsetRect( -nCur , 0);
}
if ( (pWnd->GetStyle() & WS_VSCROLL) > 0)
{
SCROLLINFO ScrollInfo;
ScrollInfo.cbSize = sizeof(SCROLLINFO);
ScrollInfo.fMask = SIF_RANGE | SIF_POS;
pWnd->GetScrollInfo(SB_VERT, &ScrollInfo);
nMin = ScrollInfo.nMin;
nMax = ScrollInfo.nMax;
nCur = ScrollInfo.nPos;
//pWnd->GetScrollRange(SB_VERT, &nMin, &nMax);
//nCur = pWnd->GetScrollPos(SB_VERT);
prc->bottom = prc->top + nMax;
prc->OffsetRect(0, -nCur);
}
}
When the resizing is done manually ScrollInfo.nMin and ScrollInfo.nMax will correspond to the correct scroll range which is equivalent to the total size (vertical or horizontal) of the controls inside the child window. However when this function is called as a result of SetWindowPos, MDITile or MDICascade ScrollInfo.nMin is always set to 0 and ScrollInfo.nMax is always set to 100, causing the compression of the controls. Clicking on the scroll bar readjusts the controls correctly.
At first I thought it was some sort of issue in the way MDITile and MDICascade worked, so I built my own variation of MDITile using ::SetWindowPos and sure enough ran into the same problem, so if I had to guess I would say ::SetWindowPos sends the respective windows messages to resize/move the window and _afterwards_ sets up the scroll bars accordingly. So, is there any way to fix, alter or bypass this behaviour?
zbtilehorizerror.png
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|