Solved

Dialog Box Scrolling needed (VC++5.0)

Posted on 1998-08-17
3
179 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

630 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