Solved

Hide annoying MDI scrollbars in C#

Posted on 2004-09-13
15
1,641 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error in JQuery 5 54
C# Single Form 8 42
C# parent child form 5 30
Get distinct values from excel or comm seperated file 4 27
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…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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