Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Restrict Child form to MDIContainer area

Posted on 2004-08-11
16
Medium Priority
?
517 Views
Last Modified: 2012-05-05
VB.Net / WinForms Application...

I have two forms: one is Parent, the other a Child Form.  At present, when the Child form is maximised, it fills the entire screen.  How do I restrict it to occupying only a certain area within the parent form?  I need the user to be able to see the menus etc on the parent form whilst in the Child form.

Thanks in advance...
0
Comment
Question by:Sigh_Man
[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
  • 7
  • 3
  • 3
  • +1
16 Comments
 
LVL 25

Assisted Solution

by:RonaldBiemans
RonaldBiemans earned 80 total points
ID: 11772500
As far as I know a mdichild won't cover the menu on the parent. Could you post the code where you open the child form
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11772512
Unless you mean that the menu of the child overwrites the menu of the parent ?
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 11772586
(You'll notice that this code includes a check to stop the form being opened more than once at any given time...)

Here's my code for opening the Child Form...

Dim frmCaseDetailOpen As Boolean
        If frmCaseDetailOpen = False Then
            frmCaseDetailOpen = True
            'Create a new instance of frmCaseDetail...
            Dim NewMDIChild As New frmCaseDetail
            'Set the parent of the MDI child form...
            NewMDIChild.MdiParent = Me
            'Display the new form...
            NewMDIChild.Show()
        End If

        mnuSetupCaseDetail.Enabled = True
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 4

Accepted Solution

by:
srcalc earned 160 total points
ID: 11773165
This will keep the form at max 200 by 200 pixels and docked to the top-left of the parent form:

    Private Sub NewMDIChild_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
        If Me.Height > 200 Then
            Me.Height = 200
        End If
        If Me.Width > 200 Then
            Me.Width = 200
        End If
        Me.Left = Me.Parent.Left
        Me.Top = Me.Parent.Top
    End Sub
0
 
LVL 8

Assisted Solution

by:wguerram
wguerram earned 160 total points
ID: 11773178
Private Sub f_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles f.SizeChanged
        With f
            If .WindowState = FormWindowState.Maximized Then
                .WindowState = FormWindowState.Normal
                .Left = 0
                .Top = 0
                .Width = Me.Width - 12
                .Height = Me.Height - 60
            End If
        End With
    End Sub

This code will limit the form to the inner bounds of the parent form when maximized.

just declare the variable this way in the parent form

Dim WithEvents f As New Form2

Hope this help
0
 
LVL 4

Expert Comment

by:srcalc
ID: 11776403
Good point, wguerram. If you combine our too code samples it should work out great.
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 11790195
Good work.  Thanks.

Just to cap this question:  Is it generally better practise to use forms to keep certain parts of the program separate from others (ie contained within forms that have to be opened from menus, say) or is OK to use just one area "common" to all parts of the application?  (by that I mean hide certain objects and show other objects at RunTime).


Thanks
0
 
LVL 4

Expert Comment

by:srcalc
ID: 11790228
Using different forms makes it easier to stay organized if you have a lot of stuff to do in your app.
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 11791681
Thanks again!!   :D
0
 
LVL 8

Expert Comment

by:wguerram
ID: 11792723
Just one question?

why did you accepted srcalc answer?

if you copy his code, it does not work when maximizing the window.

I just think it is not fair.

But are your points.
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 11801947
I went into the Split Points screen and allocated points based on the contributions of each.  Interestingly, the EE system seems to have arbitrarily selected the answer from srcalc to be labelled as the "Accepted Answer" despite the same allocation of points as yourself.

On the issue of the code not working:  I work long hours in a non-IT job.  Generally speaking, the only opportunity I get to program is at weekends, but much of my working week is spent contemplating certain solutions.  With EE, I find that the 'approaches' suggested by the Experts, to me, are as valuable as the code itself.  Given that I have now attained some degree of familiarity with VB.Net syntax, I will accept an answer if it provides me with sufficient information to solve my problem.  I hope that this explains the position.

On reflection, yes you offered slightly more and I probably should have awarded 30 points to you -- I hope you aren't too upset by this!
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 11801956
Sorry wguerram -- that should have read 60 points to you!!!!!   :D
0
 
LVL 8

Expert Comment

by:wguerram
ID: 11809862
No, Problem i am just starting on this forum and i just want to help people with the knowledge i have gotten and i found pretty intersting, the idea on getting points for each answer you post.

It's fine.
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 13598418
RonaldBiemans,
I couldn't tempt you to have a crack at
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21358145.html
...could I?
It's a single form only - and I have posted all code there for it to run in a new project.  I cannot get the 12% interest to calculate correctly and this is now extremely urgent.
I shall post a further question with extra points if you fancy a pop at this question.
Thanks.
Sorry for the rude ask - but things are desperate!!    :-/
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 13599153
I'll have a look :-)
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 13599156
Excellent - thanks!!   :D
0

Featured Post

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!

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

597 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