I have an MDIParent window.
And I can`t catch the moment when scroll bars become visibe.
this.VScroll and this.HScroll

are always return false.

Thanks in adv

Serg.

Re: How can I determine when scroll bars become visible for a form? by Jared

Jared
Tue Feb 28 15:57:08 CST 2006

Sounds bad, but could try holding the difference of form size and clientsize
in a varible and if that is smaller than 'last' value onresize window would
have scroll bars

Never tried it.


"Serg" <serg_nospam_@alef.ru> wrote in message
news:uHvxenHPGHA.1288@TK2MSFTNGP09.phx.gbl...
>I have an MDIParent window.
> And I can`t catch the moment when scroll bars become visibe.
> this.VScroll and this.HScroll
>
> are always return false.
>
> Thanks in adv
>
> Serg.
>
>
>
>



Re: How can I determine when scroll bars become visible for a form? by Stoitcho

Stoitcho
Tue Feb 28 16:05:52 CST 2006

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
"Serg" <serg_nospam_@alef.ru> wrote in message
news:uHvxenHPGHA.1288@TK2MSFTNGP09.phx.gbl...
>I have an MDIParent window.
> And I can`t catch the moment when scroll bars become visibe.
> this.VScroll and this.HScroll
>
> are always return false.
>
> Thanks in adv
>
> Serg.
>
>
>
>



Re: How can I determine when scroll bars become visible for a form? by Serg

Serg
Wed Mar 01 03:13:24 CST 2006

Hi, Stoitcho

First way is not working because of VScroll and HScroll for MDI parent form
always return false. I think this is error in .NetFramework_1.1.
Second way is working well.

Thank you.
Serg.



"Stoitcho Goutsev (100)" <100@100.com> wrote in message
news:extIpKLPGHA.1696@TK2MSFTNGP14.phx.gbl...
> 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
> "Serg" <serg_nospam_@alef.ru> wrote in message
> news:uHvxenHPGHA.1288@TK2MSFTNGP09.phx.gbl...
>>I have an MDIParent window.
>> And I can`t catch the moment when scroll bars become visibe.
>> this.VScroll and this.HScroll
>>
>> are always return false.
>>
>> Thanks in adv
>>
>> Serg.
>>
>>
>>
>>
>
>



Re: How can I determine when scroll bars become visible for a form? by Stoitcho

Stoitcho
Wed Mar 01 08:21:15 CST 2006

Serg,

I never tried the first way. It may not work because the scroll bars are
carried by the internal MDIClinet control. I thought that they are taking
this into considereation.



--

Stoitcho Goutsev (100)

"Serg" <serg_nospam_@alef.ru> wrote in message
news:uFYnmBRPGHA.1312@TK2MSFTNGP09.phx.gbl...
> Hi, Stoitcho
>
> First way is not working because of VScroll and HScroll for MDI parent
> form always return false. I think this is error in .NetFramework_1.1.
> Second way is working well.
>
> Thank you.
> Serg.
>
>
>
> "Stoitcho Goutsev (100)" <100@100.com> wrote in message
> news:extIpKLPGHA.1696@TK2MSFTNGP14.phx.gbl...
>> 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
>> "Serg" <serg_nospam_@alef.ru> wrote in message
>> news:uHvxenHPGHA.1288@TK2MSFTNGP09.phx.gbl...
>>>I have an MDIParent window.
>>> And I can`t catch the moment when scroll bars become visibe.
>>> this.VScroll and this.HScroll
>>>
>>> are always return false.
>>>
>>> Thanks in adv
>>>
>>> Serg.
>>>
>>>
>>>
>>>
>>
>>
>
>