Solved

Hide annoying MDI scrollbars in C#

Posted on 2004-09-13
15
1,660 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 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