Originally posted by: Babul
In this demo , Dialog is acting like a ScrollView , I mean whole Dialog contents are Scrolling..
I want to make some part (assume that width of 100 pixel From left Side ) Constant and remaining part of the Dialog to be Scroll.
How can it be possible..?
Thanks
Originally posted by: Yuki
Pls help, I am very new for programming.
I am writing a dialog-based program for Pocket PC (Win CE 3.0) using MFC. I am able to get the scrollbar for one of the child dialog embedded in the overlapped dialog. However, the scrollbar is not scrolling at all (the window is not moving when I scroll!!!). What did I do wrong? Here is my code for the WM_VSCROLL:
void CScrollDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int nDelta;
m_nScrollPos=GetScrollPos(SB_VERT);
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = nMaxPos;
si.nPage = si.nMax/10;
si.nPos = 0;
SetScrollInfo(SB_VERT, &si, TRUE);
switch (nSBCode)
{
case SB_TOP:
nDelta = -m_nScrollPos;
break;
case SB_BOTTOM:
nDelta = si.nMax-m_nScrollPos;
break;
case SB_LINEDOWN:
nDelta = 1;
break;
case SB_LINEUP:
nDelta = -1;
break;
case SB_PAGEDOWN:
nDelta = 100;
break;
case SB_THUMBPOSITION:
nDelta = nPos - m_nScrollPos;
break;
case SB_PAGEUP:
nDelta = -100;
break;
default:
nDelta = 0;
return;
}
m_nScrollPos += nDelta;
SetScrollPos(SB_VERT,m_nScrollPos,TRUE);
ScrollWindow(0,-nDelta, NULL, NULL);
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
Thanks, in advance.
Originally posted by: redCPU4GHZ
Hi folks:
First I wanted to say what a great article you have
Felix!!
For those that have dialogs bigger than their screen and
are having trouble getting to be able to see the part off
the screen, the secret is to insure to size of the dialog
that initially appears fits on the screen.
Here are the steps to accomplish this:
1. Add a message handler for WM_SHOWWINDOW
2. In that handler add the following code - note that I
am modifying the height parameters only. It should be
obvious the same thing can be done for the width.
CRect rectEntireScreen;
HWND hWndEntireScreen = NULL;
int nHeightOfEntireScreen = 0,nHeightOfMyDlg = 0;
int nAdjHeight = 0;
int nMaxDesiredHeight = 0;
CRect rectMyDlg;
hWndEntireScreen = ::GetDesktopWindow();
BOOL bSuccess = ::GetWindowRect(hWndEntireScreen,&rectEntireScreen);
if (bSuccess != FALSE)
{
nHeightOfEntireScreen = rectEntireScreen.Height();
GetWindowRect(&rectMyDlg);
nHeightOfMyDlg = rectMyDlg.Height();
nAdjHeight = min(nHeightOfEntireScreen,nHeightOfMyDlg);
//In my case, I want the height to be no more than 90% of the entire screen
nMaxDesiredHeight = (int)(0.9 * (double)nHeightOfEntireScreen);
if (nAdjHeight >= nMaxDesiredHeight)
{
nAdjHeight = nMaxDesiredHeight;
}
MoveWindow(rectMyDlg.left,rectMyDlg.top,
rectMyDlg.Width(),nAdjHeight);
}
3. When your dialog comes up it will fit on top the
screen and now you can scroll down to the bottom of
the dialog.
Answer to person who wants to add 200 controls on 8 pages:
It is definitely possible and you will not meet any
CDialog limitations. Use my code above and you'll be fine.
Originally posted by: Garimella
i am using 60 contols in one dialog box ...so i using ScrollDialog class...here i modified dialog templates(co ordinates) using resource editor..but it looks bad ..it's fit to screen also ..so i want to minimize the dialog box when i am calling this dialog box ...
if i mentioned less coordinates in resource file i did't use scrollbar functionality ...
i tried lot of ways ..but not success...
Originally posted by: Ed A
BOOL CScrollDialog::OnInitDialog()
I fixed this by adding a method to modify the 'target' dialog size after the OnInitDialog call.
SetClientRect(int width, int height) { m_ClientRect.bottom = height; m_ClientRect.right = width; }
I call this in onShowWindow if the dialog is bigger than the display, but I've used hardcoded values. I'm not sure how to get the size of the dialog BEFORE windows has made it fit on the display.
Thanks for posting this, it saved me a buncha time.
I found an issue when the display is smaller than the dialog. The initial call to getclientrect returns the screen size instead of the initial size of the dialog.
{....
// Get the initial dimensions of the dialog
GetClientRect(&m_ClientRect);
....}
Originally posted by: Roy Motley
Great Job - Thanks
ReplyOriginally posted by: Jitu Deshpande
Yhanks a lot for giving such a nice and handy code for scrolling dialog boxes. Thanks to Patrix Dughi also for suggesting a very important change as i also faced the same problem...
Thanks
ReplyOriginally posted by: toni
I implemented dialog derived from CScrollDialog, on tab control.
So, mouse event is not captured on edit box of dialog .
Other controls(combo box or button) are run well.
Pls. comment it.
Originally posted by: Praveen
Is it possible to have the scrolling capability like a true view window. What I mean is that, If I dynamically add controls into the dialog (100s of them), can I scroll and view all the controls, currently it limits the max size to the screen (when maximised)
Originally posted by: Aajay
I have opened a new project with CFormView as a base class & i have inserted Dialog box. I want the HScroll & VScroll functionality on this dialog box. If i choose CScroll as the derived class, DoModal will not work in order to open another Dialog box.
I want this fuctionality in order to show a large number of outputs in the same window.
And I want the second way of implementing the DoModal(), to open another dailog box.
Ajay.
Hi: