Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How disable scrollbars in a maximized mdi parent form? 4

Status
Not open for further replies.

FemPro

Programmer
Feb 15, 2008
28
GR
Hello everyone.
I have a mdi parent window state maximized form and many mdi child forms. When i load a child form and move it, the scrollbars are appearing in the parent form. How can i disable the scrollbars in mdi parent form? Any help will be much appreciated.

Thank you
in advanced
FemPro.
 
Thank you much andrea96 but i am very new to visual studio 2005 and unfortunatelly this doesn't help me :-(.
 
unfortunatelly andrea my problem still exists.
Well the reason i want to disable the scrollbars in the mdi parent is that i have an image background strech, so when a mdi child form displayed when i move the mdi child out of mdi parent's ranges and the scrollbars appears, the background images seems to be altered. Is there a way at least, to avoid the mdi parent's alteration background image? Thank you again try to help me.


 
It kind of depends on what you mean buy "altered", but for the moment I would say in the Layout Event for the parent form put Me.Refresh() and see if that fixes it.

-I hate Microsoft!
-Forever and always forward.
 
One warning I should have put is layout is called a little more often than I would like so calling refresh so often might slow things up depending on computer, how may child forms are running, etc. I am trying to see if there is a better event, but at the moment I don't know of one. If it makes it too slow could do a global event that keeps track of when a scroll bar is add/removed and only refres when that status has changed.

-I hate Microsoft!
-Forever and always forward.
 
Thank you much Sorwen help me. When i tell that the image background seems to be altered, i mean that it seems like fading image. I tryed in mdi parent layout event the refresh method, when i run the program and move a mdi child out of the bounds of mdi parent so the scrollbars appears, the mdi parent image background doesn't faded but seems the it moves. It displays when the mdi parent background image growing or become smaller. I have 6 mdi child forms.
 
Another idea i have instead of seting a background image is to use a picture box and set the image there. But the problem here is that that mdi child forms appears under the picture box and if i use picturebox1.sendtoback the picture doesn't displayed. A very complecated problem. I don't know what to do.
 
I tryed in mdi parent layout event the refresh method, when i run the program and move a mdi child out of the bounds of mdi parent so the scrollbars appears, the mdi parent image background doesn't faded but seems the it moves. It displays when the mdi parent background image growing or become smaller. I have 6 mdi child forms."

Yes, it does that automatically because the actual size of the background area has changed. The scroll bar becomes sort of a new control on the form. I say sort of because as far as I know you cannot accesses it like you would a new control.

There is no way I know of to get rid of the scroll bars on an MDI parent. That said you are going to end up with some little quirks no matter what you do. You could prevent the child window from being dragged past the bounds of the form, but I'm pretty sure the scroll bar would still appear until they quit trying to drag it.

I'm pretty sure the only way you are going to get 100% what you want is make your own mdi parent/child forms (read really hard). Or fake it using panels or something like that.

-I hate Microsoft!
-Forever and always forward.
 
The link posted by andre96 in her first reply to you appears to do just what you want and more. Can you explain why it didn't help?



[vampire][bat]
 
Because i am very new in vs2005 and i almost know nothing in c#.
 
Ok, so you are not saying that you have investigated the article and it is not suitable.

Although c# is not my language of choice, I'll have a more detailed look at the article tonight and see if I can extract the relevant parts of it into VB.

For future reference, if a similar situation should occur, explain why you can't use the suggestion - it will save others from unnecessarily trying to find alternatives for you.

[vampire][bat]
 
Thank you much earthandfire, i hope this code will help me in vb 2005. The what i want to avoid as i explained before, is the fading of mdi parent background image when i move children forms out of parent bounds. But if this is not possible, i refered another thought instead of seting a background image which is to use a picture box and set the image there. But the problem here is that that mdi child forms hide under the picture box image and if i use picturebox1.sendtoback the picture doesn't displayed.
I hope explained you my problem as better as i could.
I know that you do everything help me and thanks all of you very much. Any help will be much appreciated.

Thanks everyone
again in advanced.
 
earthandfire although i am wandering. Is it sure that disabling the mdi parent's form scrollbars when moving a mdi child form out of parent's bounds that the parent's background image doesn't seem to be faded? I mean is it sure that this manner i thought firstly is properly to solve my problem or must we have to think something else? I am just trying to think the best solution of my problem.
 
i missed to refer that the background image layout is streched and want to be streched.
 
When I converted it nothing happened, but earthandfire is better at this so he may be able to get it working for you. That is the better option so if it does work I would go with it.

I never had the fade effect you spoke of so likely there is no telling what will work till you try it. My picture always split along the scroll areas. Here is something else you can try. I couldn't remember how to do it so it took me a little to find it and make it work again (that is why I didn't mention it as an option before).

Rather than having the mdi create the background you can paint it directly to it. The up shot is that it paints to the whole background rather than visible background so you don't have the resizing when the scroll bar is added/remove. If you wanted to try it let me say it still "splits" on mine so it may still fade on yours. I know why it splits, but can't think of where to put the refresh to make it quit.

Declare Globally
Code:
Dim backWin As MdiClient

Code:
    Private Sub MdiClientOnPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim ti As Image
        ti = Image.FromFile("C:\Sample.jpg")
        e.Graphics.DrawImage(ti, 0, 0, Me.Width, Me.Height)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim found As Object
        For Each found In Me.Controls
            If TypeOf found Is MdiClient Then
                backWin = found
                AddHandler backWin.Paint, AddressOf MdiClientOnPaint
            End If
        Next
    End Sub


-I hate Microsoft!
-Forever and always forward.
 
I started working on a VB version based solely on the article, but it was slow work - so I downloaded the project from CodeProject and read through the complete c# source code. There is a fair bit of "low level" code in there and as you say that you are new to VB 2005, you may, for now at least, struggle to understand it as it uses some advanced techniques.

The good news - you don't need the code in c# or in VB.

Download the project from CodeProject - if you are not a member you will need to register (registration is free).

For simplicty, create a folder in the root of Drive C: called CodeProjectDownloads.

Unzip the downloaded file (I'm assuming therefore that you unzip to C:\CodeProjectDownloads\) .

Open up your project in VS 2005

I'm using VS2008, so the following highlighted menu selections may have slightly different names on your system.

On the ToolBox, right click on a blank area and select Add Tab, when prompted, name the new Tab (anything you like for example CodeProject Controls).

When the new tab has been created, right click on a blank area in the new tab and select Choose Items.... A dialog box will open, make sure that the .NET tab is selected and then click on the Browse button. You will need to locate the following file:
C:\CodeProjectDownloads\mdiclientcontroller_src\MdiClientController\bin\Release\MdiClientController.dll

Then click on Apply, or OK or whatever the appropriate button is in VS 2005.


You should now see the MdiClientController component in your ToolBox.


In your project, remove the image from the MDIParent Form.

Add the MdiClientController to the MdiParent Form. It won't actually go on the form, instead it will be placed in the Component Tray at the bottom of the form.

Select MdiClientController1 and set the following properties:

AutoScroll: False
Image: set this to the required background image


You also have:
BorderStyle, ImageAlign and StretchImage that you can set if you need/wish.


The beauty of this approach is that you do not need to write a single line of code, and when you feel ready, you have access to the source code to study.


I've tested the control and it seems to work perfectly, with no fading of the image (although the image didn't fade when the ScrollBars were operational either - so I don't know what that problem was).


Hope this helps.

[vampire][bat]
 
Thank you very much both of you.

Sorwen its a nice idea but if you move the mdi child form out of mdi parent's bounds and if you press the scrollbar's button so that the scrollbar disappears you can see that the parent's background image still fades. Although i thank you very much for your help.

earthandfire its a very nice idea, helped me better than Sorwen's. I want to ask you something, when run the program and move the child form i can see the its track, like it happens in mouse pointer in windows if you adjust it from settings through control panel. Is it possible to avoid this? Can i do something about this?
Also, i realized that MdiClientController.dll is now to my project's folder, will i have problem when i finish my program and want to deploy and package my application?
Thank you very much again!!!

 
Unfortunately no, not without rewriting the underlying redraw code - the author makes a comment about this in the source code.

To deploy, you will need to deploy your application (and any other files that you need) plus the MdiClientController.dll (which needs to be in the same folder as your .exe)


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top