Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dialog Box Scrolling needed (VC++5.0)

Posted on 1998-08-17
3
Medium Priority
?
181 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 150 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 clear a vector as well as how to detect empty vectors in C++.

719 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