Click to See Complete Forum and Search --> : Horizontal scrollbar in MDI
David Bajgar
August 3rd, 2008, 03:05 PM
Hi all,
I have MDI application and a child form which height can be more than a MDI main form. In this case the horizontal scrollbar will be displayed. In the code I need to find out if the scrollbar is displayed or not. I tried HScroll and HorizontalScroll properties, but they always contain false.
Do they work in MDI, how to find out that please? I am in VS2005, .net 2.0.
Thanks,
David
JonnyPoet
August 4th, 2008, 02:55 AM
IMHO there is no such property in VS 2005. I would use the resize event of the MDI child. There I would check the MDI parents Form size and comparing it with the actual size of my child form , throwing an event when this exceeds size of parent because this is the time when the scroll switches on. Something like that. It may depend a bit on how your application is designed
David Bajgar
August 4th, 2008, 03:19 AM
thanks for answer Jonny.
yes, there are. Form has properties HScroll and VScroll properties derived from Control class I think.
I got the idea with calculation of form height as well, but at the moment I am trying to avoid it (I think I need to calculate with captions, border width etc. to get exact calculation) and looking for a more "cool" solution :). If there is no any, then I am going to implement the solution as you suggest.
thank you,
David
JonnyPoet
August 4th, 2008, 03:48 AM
yes, there are. Form has properties HScroll and VScroll properties derived from Control class I think....I know that, but you cannot use them for your purpose, as they dont show the actual state. This properties are only a general I would say 'autorisation' for the form to use Hor or ver scroll ability, not the actual state of them. (IMHO there should be additional events to get informed when the scrollbar really appears on screen, but they arn't. There is a Scroll event but this only appears when you are already using the scrollbar. (BTW: I never tried if StyleChanged Property fires when scrollbars appears. Maybe test this, if they are a solution, please post it here, )
David Bajgar
August 4th, 2008, 03:34 PM
StyleChanged nor Scroll events are not fired when scrollbar appears. I overrided also WndProc to find all messages, but no sensible event.
API function GetScrollInfo could be a way, but does not work for main form (still returns FALSE), it works OK for child controls like RichTextBox. When I change the property AutoScroll to true then it works fine! but IsMdiContainer property is changed to false automatically. Both properties cannot be true together. Maybe is that some MDI app limitation, strange :confused:
thanks anyway
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.