Results 1 to 12 of 12

Thread: [RESOLVED] Chilkd form still jumping on resize

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    236

    Resolved [RESOLVED] Chilkd form still jumping on resize

    This is driving me nuts. I posted this question not long ago and thought it was resolved but it is not. I can't figure out why this is happening but more importantly, I can't figure out how to make it stop. Something happened to my VB6 installation a few weeks ago and it will no longer register or use active X files. I wiped the computer, reloaded Windows 7 (twice), ran the updates but none of my programming applications will open without serious errors and missing controls. So I decided to migrate to VS2010 ultimate. I'm in the process of converting all my software to VB2010 ... but some things do not seem to work properly and the behavior I am finding in VB2010 did NOT occur in VB6. Anyway, that's a bit of background ...

    I have a parent MDI form and a child form. The MDI form has a menu and a button bar while the child has only a button. The child is set to open maximized so as to fill the parent container regardless of what size it is set to. Seems to work BUT .. the child form is NOT maximized when it opens ... when you click on a border of the parent to resize the form THEN it will jump and maximize - not before. The button is set in the upper left corner of the child form. It can barely be seen when the program opens .. but do the slightest resize and the button will jump down into full view. This cannot happen in my production piece. I suspect it has something to do with the menu bar/button bar because when those are not there the child form shows a control box regardless of the property settings for it. This I suspect is due to the child form being maximized but I gather from research on the net that there is nothing that can be done about this behavior. However there must be a way to get the child to start up in the position it jumps to when the parent is resized ...

    I've included a very basic program to illustrate this.

    Can anyone help me with this? This is so annoying that I've been starting to study C# and am about ready to abandon basic after working with the language in various iterations since 1970.

    Thanks in advance.
    Ken
    Attached Files Attached Files
    Last edited by SparrowHawk7; Jul 8th, 2013 at 06:34 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Chilkd form still jumping on resize

    Given that C# uses the same IDE and same .NET Framework as VB, there's no reason to believe that shifting to C# would make any difference at all. In fact, almost all of the IDE and .NET Framework that you're using in VB was written in C# anyway.

    Also, I'll take a look at your issue when I get the chance but, from the size of your attachment, I'm guessing that you have failed to delete the bin and obj folders before zipping it. If so then it contains binaries, which is against forum rules. If that's the case then please remove it and upload a new attachment that does comply.

  3. #3
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: Chilkd form still jumping on resize

    Hi,

    There seem to be numerous references on the net which describe different variations of this issue. There may be better solutions but the best one that I found which seems to sort the problem is this one:-

    Code:
    Dim newMdiChild As New Form1()
    With newMdiChild
      .MdiParent = Me
      .Show()
      .WindowState = FormWindowState.Minimized
      .WindowState = FormWindowState.Maximized
    End With
    In your case, remove the call to FormWindowState.Maximized in the child form's Load event and use the above. This only seems to occur with the FIRST child form and all subsequent calls to open child forms seem to open correctly.

    Hope that helps.

    Cheers,

    Ian

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Chilkd form still jumping on resize

    Here's a demo that, from what I can tell, does what you want without the behaviour you describe. Form1 has a MenuStrip and ToolStrip and opens as an MDI parent containing one maximised instance of Form2. The tool bar button will then open a maximised instance of Form3 with each click. Each child form has a Button on it that will close that form.
    Attached Files Attached Files

  5. #5
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: Chilkd form still jumping on resize

    @jmcilhinney & SparrowHawk7,

    That demo from jmcilhinney demonstrates quite an interesting bit of behaviour based on which properties are set. To explain:-

    jmcilhinney's child forms have their FormBorder style set to Sizeable and when displayed within the Parent form the children are displayed correctly. However, SparrowHawk7's child forms have the FormBorder style set to None which does then produce the unusual behaviour of hiding the button. Same happens if you change this in jmcilhinney's demo.

    Sounds like a small bug to me, but you can either use the solution I provided with FormBorder style set the None or you can use the solution provided by jmcilhinney with the FormBorder style set to Sizeable.

    Either way, that should sort things for you.

    Cheers,

    Ian

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    236

    Re: Chilkd form still jumping on resize

    Thanks all for trying .. none of the suggestions will work for what I want to do. Leaving the child form sizable is definitely something I do not want although I guess I have no choice. If I make the children with no borders and try the minimize/maximize trick, the button is still under the buttonbar on first load. Changing the child form to a different one leaves the button hidden if I do not resize the parent. The moment I go to resize the parent, the button on the child form jumps down to being visible and subsequent changes in forms seem to be correct. The "secret" is that first resize to shift the location of the child form. One would think that could be accomplished with code so I'll have to spend more time playing with that.

    I redid the zip file, incidentally ... sorry. I wasn't aware of the folder restrictions.

    Interestingly if I recreate this program in .NET 3.5 the problem is somewhat different (I tried all earlier versions of .NET with the same results). The child form is sized correctly when opened, but even with no border, it still displays the control box once maximized. Unfortunately maximizing the child is something I need to do but I do not want the user to have access to the controls. Is there an API that could be used to suppress the control box - even to disable it although I'd rather it wasn't visible at all.

    Thanks guys. This has been frustrating.
    Ken

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    236

    Re: Chilkd form still jumping on resize

    OK ... for the record I think I figured it out. Im not going to mark this thread resolved just yet however ...

    for the properties of the child form:
    FormBorderStyle = None
    Window State = Normal
    Control Box = False
    Minimize Box = False
    Maximize Box = False

    In the child form's Load event:

    ControlBox = False
    WindowState = FormWindowState.Maximized

    That seems to hide the control box and avoids the jumping controls .. I have to try it out on a few more examples first though ... fingers crossed ...

    Ken

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Chilkd form still jumping on resize

    The simple fact is that you shouldn't be using MDI and that's why it's not working. You should simply be using a regular form with multiple Panels or perhaps UserControls on it. If you use a tool for something other than what it was intended then it shouldn't be a surprise if it doesn't work as you expect or want.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    236

    Re: Chilkd form still jumping on resize

    The application uses roughly 10 different forms. There is a button bar so the user can select which form to work from. In addition there are several modal forms. Are you saying I should be using 10-15 different forms for the program and make each one an identical size? I tried using containers and switching them on and off but it got way too unwieldy very quickly. How would you approach such a problem?

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Chilkd form still jumping on resize

    I meant exactly what I said. I said that you should be using Panels or UserControls and, not surprisingly, that's what I meant. There's no reason that a tool bar can't select a specific Panel or UserControl just as easily, or even more easily, as selecting an MDI child form. You're trying very hard to remove all the form-like behaviour so why not just not use forms at all and then you've already got what you want? In the simplest case, just add a bunch of Panels to the form and set the Dock property of each one to Fill. You can then either Hide and Show them as needed or you can leave them all visible all the time and call BringToFront on the one you want the user to see. To access the stacked controls in the designer you can either use the Bring To Front and Send To Back options on the right-click menu, the drop-down at the top of the Properties window or the Document Outline window or some combination of all three.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    236

    Re: Chilkd form still jumping on resize

    It's clear you have no respect for me. That's too bad .. but your choice. Thank you for trying anyway.
    Last edited by SparrowHawk7; Jul 8th, 2013 at 07:19 PM.

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: [RESOLVED] Chilkd form still jumping on resize

    It's clear that you haven't considered that someone with over 80,000 posts probably answers a lot of threads and doesn't really want to have to answer the same question twice in two posts. I've provided information that you can use to get a good outcome. If you'd rather feel aggrieved than use that information then too bad... but your choice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width