Solved

Adding a scroll bar to a CWnd embedded in a CSizngControlBar

Posted on 2002-03-14
12
346 Views
Last Modified: 2012-06-27
I have a CWnd embedded in a CSizingControlBar, within the CWnd I have a tree control that takes up the top half and a CPropertySheet control that takes up the bottom half, because it's a pretty large window not everything shows when it's initialized so I would like to add scroll bars to the window & be able to scroll the window to see all the controls appropriately.
I tried adding WS_HSCROLL | WS_VSCROLL when I initially create the window, it did put the scroll bars, & I overwrote the OnVScroll method to  call RedrawWindow() when it scrolls but nothing seems to be happining, If you can please tell me what I need to do with some sample code I would greatly appreciate it.

Thanks
0
Comment
Question by:borghard
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
CSizingControlBar is not listed in MSDN.  What is it?

Use Spy++ to verify that you control bar is being sent WM_VSCROLL messages.  Place a breakpoint in your OnVScroll to see if it is being called.

-- Dan
0
 

Author Comment

by:borghard
Comment Utility
it just extends the functionality of MFC control bars
but really I can just put the scrollbars in the CWnd that I have embedded in the ControlBar
I put a breakpoint in my OnVScroll method & it gets in there every time I click the scroll bar ,so that means the window is getting the message, but it's just not scrolling the treeControl & the propertSheet control
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
When you get the message, you need to calculate where you are and then use the ScrollWindow() and possibly UpdateWindow().

A file named ViewScroll.cpp in your MFC Source directory  shows how MFC handles these messages in its generic CScrollView class.  That is a good place to start.

-- Dan
0
 

Author Comment

by:borghard
Comment Utility
Thanks  for that info, now that I use ScrollWindow & UpdateWindow it seems to scroll the controls in the window but when I continue pressing the down scroll it keeps on scrolling into empty space & then when I try to scroll up I only get blank space I don't see any controls.
I guess I am still not doing things I have to if you can please let me know what & how, Is there a way I can set the scroll in OnVScroll to only scroll till the end of the last control
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
I think if you check that source file, you'll see how the MFC coders do it (avoid scrolling past the end).  

You may also need to do an UpdateWindow() to force it to redraw the background.

-=-==--=
(I should have brought this up earlier)
You should re-think what you are doing.  Scrolling an entire control bar is very unusual.  I can't think of any program that does it.  The common way is to provide scrollbars on the *controls* within (eg, on your tree).  The PropertySheet is problematic.  I think you will just need to make the sheet smaller.  You could enforce a minimum size on the control bar and/or and force the user to resize it when the property sheet needs to be accessed.

That said, it is probably quite possible to do what you want to do, but don't be surprised that there is no one-step way to do it.  MFC provides lots of built-in functionality for common U/I operations and not much for oddball stuff.

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
hi borghard,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:borghard
Comment Utility
I see I can't scroll the control bar I am trying to scroll the window within the control bar that has within it a tree control and a property sheet control.
I also came across another problem when my screen is set to 1600 by 1200 pixels the property sheet gets cut off both in it's width and height, and I have the tree control set to the same size as the property sheet & nothing happens to the tree control, any suggestions on this

Thanks
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
Comment Utility
The final solution may end up being that you just need to make the PropertySheet smaller, leaving ugly gaps when using other screen resulutions.

It has to do with the fact that dialog boxes use 'dialog box units' (rather then pixels) for measurements.  You may need to do a GetWindowRect on one or more controls in the PropertySheet (e.g,. get the actual screen size and location of some editbox that is in the bottom right corner of the largest property page) That will tell you the actual size that must be enforced in the controlbar.

-- Dan
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Have you been helped here, or is more needed?
Moondancer - EE Moderator
0
 
LVL 11

Expert Comment

by:griessh
Comment Utility
Dear borghard

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "DanRollins"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Thank you, I have finalized this question.  Thanks also to Dan for the ongoing responsiveness to follow-on questions posted in this collaboration effort.  In the event Asker still has additional needs to this question, please respond.
Thanks all,
Moondancer - EE Moderator
0
 

Author Comment

by:borghard
Comment Utility
Sorry I ddin't get back I was just wokring on something else.
Thanks alot Dan Rollins for all your input.
I ended up resizing the tree control so the property sheet fits better

Thanks again
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now