Link to home
Start Free TrialLog in
Avatar of borghard
borghard

asked on

Adding a scroll bar to a CWnd embedded in a CSizngControlBar

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
Avatar of DanRollins
DanRollins
Flag of United States of America image

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
Avatar of borghard
borghard

ASKER

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
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
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
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
hi borghard,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
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
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Have you been helped here, or is more needed?
Moondancer - EE Moderator
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: https://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
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
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