Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Disabling scrollbars in main form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrus - 16 Feb 2008 20:03 GMT
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();
 }
}
Jeroen Mostert - 16 Feb 2008 21:14 GMT
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.