Results 1 to 18 of 18

Thread: setting windowstate

  1. #1

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    setting windowstate

    Hey,

    I have a form that opens up another form. In the newly opened form I have the following code running to maximize it:

    Me.WindowState = FormWindowState.Maximized

    When I close the newly opened form, the previous form that opened the one being closed is maximized as well. Why is that happening?
    Don't anthropomorphize computers -- they hate it

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: setting windowstate

    Do you have some kind of maximize code anywhere inside of the one that originally called it?

  3. #3

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    Re: setting windowstate

    no, only the form that is opening up has that code.
    It's a form showing a report so I want it maximized by default.
    That is the only place in the app that has maximizing code in it.
    Don't anthropomorphize computers -- they hate it

  4. #4
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: setting windowstate

    What event is that code inside? It's definately not inside the first form, even during the showing of the second? Me. anything refers to the current object.

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  5. #5

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    Re: setting windowstate

    The code is inside the form that is opening up. Yes, it does uses the me object to maximize itself.
    Don't anthropomorphize computers -- they hate it

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: setting windowstate

    I'd suggest that you create an empty Resize event handler for the first form and put a breakpoint on the declaration. That way you can look at the call stack when the resizing happens and see where it came from.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    Re: setting windowstate

    In the report form (the one that was maximized), the following line causes the calling form to maximize as well

    MyBase.Dispose(disposing)

    it happens in teh Dispose sub.

    This is weird.
    Don't anthropomorphize computers -- they hate it

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

    Re: setting windowstate

    Have you derived this "report form" from another form of your own creation, or does it inherit Form directly?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    Re: setting windowstate

    Inherits System.Windows.Forms.Form
    Don't anthropomorphize computers -- they hate it

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

    Re: setting windowstate

    When your breakpoint gets hit can you double-click on the entries in the call stack to look at that code, or is it not accessible?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: setting windowstate

    You haven't at any point set the second form as the Owner of the first have you?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    Re: setting windowstate

    no, the mdi parent form is the parent of the new form, as it is the parent for all the other forms.
    Don't anthropomorphize computers -- they hate it

  13. #13
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: setting windowstate

    i think this is the standard behaviour for mdi Forms.

    all mdi childs tends to have the same window state, i dont like it either but that is the way it is

    rgds

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: setting windowstate

    OK, nowhere previously did you mention that any of this involved MDI forms. I assumed that it was just one top-level form opening another top-level form. Now that we know that it's MDI, do you mean that the parent is maximised when the child is or that another child is maximised? If it's the latter then, as maged says, that is normal behaviour. It is not possible to chnage that without using extremely hacky means, and even then I'm not sure that there aren't issues.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  15. #15

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    Re: setting windowstate

    no, the parent is maximized at all times. The form that is calling the report form gets maximized after I exit the report form. The report form maximizes itself upon the Form_Load event.
    Don't anthropomorphize computers -- they hate it

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: setting windowstate

    If one MDI child is maximised then they all are. That's standard behaviour. Try switching to the first child window before closing the second and you'll see that it is already maximised at that point. perhaps it doesn't technically happen until the first time you view it but as soon as you maximise one child then they will all be maximised the next time you look them. The way to workaround this may be to set the WindowState of the second window back to Normal before closing it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  17. #17

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    Re: setting windowstate

    Yeah, I though about doing that. My app is becoming quite large and I don't want to be going through all the forms that might possibly be calling the report form and trapping their resize event. Damn...
    Don't anthropomorphize computers -- they hate it

  18. #18
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: setting windowstate

    How about just calling this in the form.closing event of your report form:

    VB Code:
    1. Me.WindowState = FormWindowState.Normal

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

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