Solved

Dialog Box Scrolling needed (VC++5.0)

Posted on 1998-08-17
3
178 Views
Last Modified: 2010-04-10
Hi,

Looking for a step by step approach to implement scrolling in a dialog box. I have seen an answer to a previously asked question which says that once you add the scrollbars, scrolling will be implemented automatically if the text/control is out of the dialog box. I have tried and it does not work! The dialog box in the first place would not let me build controls that do not fit it. Would really appreciate if someone could help me on this !

Thanks,
Arnaud.
0
Comment
Question by:decornez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1170502
The scrollbars won't automatically move the controls around (CFormView will if you use it's scroll bars, but the implementation code is built into MFC not windows).

The easiest way to do this is to add scroll bars to your dialog, and respond to the scroll bar messages (WM_HSCROLL, WM_VSCROLL).  When you get the scroll messages, you then move all the other controls on the dialog.  For example to move a control one unit left, do something like this

CWnd * pCtrl = GetDlgItem(ID_CONTROL) ;
CRect rect ;
pCtrl->GetWindowRect( &rect ) ; // get old position, will be in screen coords
ScreenToClient( &rect ) ; // convert coords to position on dialog
rect += CPoint( -1, 0 ) ; // move 1 pixel left, 0 in vertical pos
pCtrl->MoveWindow( rect ) ; // move to new position

In your code you'll have to do this for all controls on the dialog.  You can write generic code using EnumChildren
0
 

Author Comment

by:decornez
ID: 1170503
The answer given to me looks good. I'll just have to try it out and see whether I can get it to work. Thanks.
0
 

Author Comment

by:decornez
ID: 1170504
I did try it in the end and it works perfectly. Great help from Answers2000 !
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question