To reproduce, run the code, move part of child window outside parent.
Observed:
scrollbars appear.
Expected:
Scrollbars should not appear since AutoScroll if false.
How to fix ?
Andrus.
using System;
using System.Windows.Forms;
public class Test {
static void Main() {
Application.Run(new MainForm());
}
}
class MainForm : Form {
public MainForm() {
IsMdiContainer = true;
Form frm = new Form();
frm.MdiParent = this;
frm.Show();
}
}
> To reproduce, run the code, move part of child window outside parent.
>
[quoted text clipped - 5 lines]
>
> Scrollbars should not appear since AutoScroll if false.
What actually happens is that the MdiClient control (which is implicitly
created) is occupying the form. Since this always fits the visible area, the
AutoScroll property has no effect.
> How to fix ?
That's not easy. You're really not supposed to "fix" this, since it would be
bad news if the user could lose an MDI child window.
That said, in Windows, there's almost always a way. In this case, you can do
it by P/Invoking. There's not really a managed interface for this. See
http://www.codeproject.com/KB/dialog/mdiclientcontroller.aspx
> using System;
> using System.Windows.Forms;
[quoted text clipped - 13 lines]
> }
> }

Signature
J.
Andrus - 17 Feb 2008 00:30 GMT
Jeroen,
> You're really not supposed to "fix" this, since it would be bad news if
> the user could lose an MDI child window.
I check in MDI child constructor that it is visible in screen and adjust
location if not.
So user could see always part of child form.
> That said, in Windows, there's almost always a way. In this case, you can
> do it by P/Invoking. There's not really a managed interface for this. See
> http://www.codeproject.com/KB/dialog/mdiclientcontroller.aspx
My code nees to run in MONO also so I cannot use P/Invoke.
I realy want to get rid of those scrollbars since they appear always when
only few part of
MDI child form is moved out of MDI parent form.
Those scrollbars are very confusing and decrease form working area.
Any idea how to remove them using managed code only ?
Andrus.
Jeroen Mostert - 17 Feb 2008 00:47 GMT
>> That said, in Windows, there's almost always a way. In this case, you can
>> do it by P/Invoking. There's not really a managed interface for this. See
>> http://www.codeproject.com/KB/dialog/mdiclientcontroller.aspx
>
> My code nees to run in MONO also so I cannot use P/Invoke.
Ouch.
> I realy want to get rid of those scrollbars since they appear always when
> only few part of
> MDI child form is moved out of MDI parent form.
> Those scrollbars are very confusing and decrease form working area.
>
> Any idea how to remove them using managed code only ?
As far as I know, it's just not possible. The necessary properties are not
exposed. If only MdiClient was a ScrollableControl... But it's not. If
Google is any indication, many people have been bothered by this.
If your code needs to be portable, you have your work cut out for you. You
could detect your platform and P/Invoke only if you're running on Windows
(which solves half of your problem) and ask the Mono developers for help on
how to get it done in Mono. This will in all likelihood involve another
non-portable construct, but it should be possible.
Your other option is to petition Microsoft, wait for an update and convince
the Mono guys to implement it as well... but if you're on a deadline, I
wouldn't go for that.

Signature
J.
Andrus - 17 Feb 2008 11:31 GMT
> As far as I know, it's just not possible. The necessary properties are not
> exposed. If only MdiClient was a ScrollableControl... But it's not. If
> Google is any indication, many people have been bothered by this.
Is is possible to replace mdiclient control with some othe control in mdi
form ?
Or maybe there is custom MDI parent window code somewhere ?
Andrus.
Jeroen Mostert - 17 Feb 2008 12:37 GMT
>> As far as I know, it's just not possible. The necessary properties are not
>> exposed. If only MdiClient was a ScrollableControl... But it's not. If
>> Google is any indication, many people have been bothered by this.
>
> Is is possible to replace mdiclient control with some othe control in mdi
> form ?
No, because child forms couldn't associate with that. They expect an
MdiClient, so you'd end up reimplementing everything anyway.
> Or maybe there is custom MDI parent window code somewhere ?
If your code has to run on Mono as well, this is a no-go. You can't
re-implement MDI without the windowing framework to back you up.

Signature
J.