Solved

Hide annoying MDI scrollbars in C#

Posted on 2004-09-13
15
1,622 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
ID: 12052231
0
 
LVL 10

Expert Comment

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

Expert Comment

by:eternal_21
ID: 12058292
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
ID: 12060363
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
ID: 12092838
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
ID: 12098037
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:armoghan
ID: 12098961
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
ID: 12098965
0
 

Author Comment

by:paylett
ID: 12365954
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
ID: 12687721
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
ID: 12691979
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
ID: 12698156
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
ID: 12713806
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

15 Experts available now in Live!

Get 1:1 Help Now