Serg,
There are VScroll and HScroll proeperties that get give you information
where the scorll bars are visible or not, but there is no notification when
these properties changes. There is no also notification when the MDI
children inside the MDI parent move.
I have two workarounds for you:
1. Hook on Application.Idle event and check VScroll and HScroll propoerties
and fire events when they change (or do whatever you want to do).
Cons: Using this solution you will get the event fired eventually, but not
right away.;
Pros: This solution doesn't use any window messages, refelection, PInvoke or
undocumneted stuff; Works for all .NET versions
2. When scollabars show/hide in a ScrollableControl (the one that support
autoscrolling) the SizeChanged event fires. This could be used to check for
changing scrollbars visiblity.
The bad news is that when a form is configure to be a MDI container it
creates one internal control that host all MDI children and shows all the
scrollbars, thus handling SizeChanged event on the level of the form won't
do.
Good news is that this control is added to the form's Controls collection as
any other control. You can enumerate the child control and hook to its
SizeChanged event. For example your form's contructor can look something
like this:
public Form1(int a)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
foreach(Control ctrl in this.Controls)
{
if(ctrl is MdiClient)
{
ctrl.SizeChanged += new EventHandler(MDIClinet_SizeChanged);
}
}
}
private void MDIClinet_SizeChanged(object sender, EventArgs e)
{
//Check VScroll and HScroll and fire event if they change
}
Pros: You get the event right away; This solution doesn't use any window
messages, refelection, Works for all current versions of .NET
Cons: The solution uses undocumented mdi client control. It may not work for
future versions if MS desides to change the implementation of this, but it
is unlikely to happen.
--
HTH
Stoitcho Goutsev (100)
Then in the MDIClinet_SizeChanged you can check VScroll and HScroll
properties and fire an event if they change or do whatever you want to do