Solved

Hide annoying MDI scrollbars in C#

Posted on 2004-09-13
15
1,690 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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