Solved

Hide annoying MDI scrollbars in C#

Posted on 2004-09-13
15
1,599 Views
Last Modified: 2008-01-09
Hi,
If I create an MDI form in C#, then whenever I move the child window outside of the MDI area, the MDI window itself gets scrollbars. Does anyone know how to hide these?

I've seen other programs that hide them, and I've found code for other languages (eg Delphi) to do it - but I can't get it to work in C#. And I can't find any C# examples anywhere.

(This should be easy.. and it's making me feel dumb!)

Thanks in advance. :)
0
Comment
Question by:paylett
  • 4
  • 4
  • 3
  • +1
15 Comments
 
LVL 10

Expert Comment

by:123654789987
Comment Utility
0
 
LVL 10

Expert Comment

by:123654789987
Comment Utility
If u have the child windows state = "Mamimized" then u won't face this problem
0
 
LVL 10

Expert Comment

by:eternal_21
Comment Utility
I could not come up with a solutions, and I found this related thread: http://www.gotdotnet.com/community/messageboard/Thread.aspx?id=20185
0
 

Author Comment

by:paylett
Comment Utility
Thanks guys for looking at this. Unfortunately none of these address the problem:

123654789987, the sample link you provided doesn't address the problem.
(and it kinda defeats the purpose of an MDI if I only allow the user to run windows maximised)
eternal_21, yes, this is the problem I'm trying to solve. I've found lots of frustrating forums like that where people put forward the question, but no-one has the answer.

Is there anyone out there who has got this to work??
0
 
LVL 10

Expert Comment

by:eternal_21
Comment Utility
Okay, I have taken a detailed look at it, and what you are looking for is not going to be possible.  When you change the IsMdiContainer property of a Windows Form, a control is added (a System.Windows.Forms.MdiClient) to your form.  The MdiClient is responsible for the scroll bars on the form; They are not controllable by Windows, they are part of the client area of the MdiClient control.  Ideally, you could implement your own MdiClient and change this functionality, but the MdiClient is a sealed class which makes this impossible.

Sorry for the bad news!
0
 

Author Comment

by:paylett
Comment Utility
Can you point me to an example of how to do it in C++? (Maybe I can find another way to do it in C#) Thanks.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 18

Expert Comment

by:armoghan
Comment Utility
This is a way in VB to see if the scrollbars are visiable or not of a MDI window. So it may help
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10063171.html
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
0
 

Author Comment

by:paylett
Comment Utility
I was really hoping for an answer to this question.
I've awarded the points to eternal_21 as he's the only person who's addressed the question asked, and I haven't found any other way to do it yet. Though I'm not 100% convinced that it's not possible.

I've decided that the Internet is very good at telling you how to do things that are possible - but sucks at telling you that what you're trying to do isn't possible. :(
0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 500 total points
Comment Utility
paylett, I haven't forgotten about your problem... here is a small step in the right direction (I hope)

Do not set the IsMdiContainer property to true for your main form, leave it as a regular form (you can change the BackColor, if you like).  Then put this code in your main form's class:

  System.Runtime.InteropServices.DllImport("user32.dll")]
  extern static int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

Then you can call this (or however is appropriate, this is just an example) code:

  System.Windows.Forms.Form childForm = new System.Windows.Forms.Form();
  SetParent(childForm.Handle, Handle);
  childForm.Show();

You will notice that the child form is displayed, and scroll bars are not (since scroll bars, as I said before, are handled in .NET by the MdiClient class which will not be a control on the main form if the IsMdiContainer property is false.

Hope this helps!
0
 

Author Comment

by:paylett
Comment Utility
Cool, that works well!
Thanks for coming back to this one.

Is it possible to change the accepted answer on this forum?
0
 
LVL 10

Expert Comment

by:eternal_21
Comment Utility
Thanks for you're response as well!  I am glad that I was able to help.

If you would like to change the Accepted Answer, someone in Community Support could probably do that for you.
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
I found another way of doing it.
See this article.
It is using the Standard MDI way and hiding the scrollbars
http://www.codeproject.com/cs/miscctrl/mdiclientcontroller.asp
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now