Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Keeping MDI children alive

Keeping MDI children alive

Scheduled Pinned Locked Moved Windows Forms
winformshelptutorialquestion
3 Posts 2 Posters 24 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CPP_Student
    wrote on last edited by
    #1

    Howdy! I came across this new forum and realized that I still have a problem with a Windows Forms project I am toying with. I am creating a quicken like program. The main window creates a MDI child for each account (checking, credit card, and broker). I cannot figure out how to handle the close button. I want the form to just hide itself and remain in the main menu item that I dedicated to keeping the names of the children, so that the user can reselect and open the form again. However, this doesn't work: private void CheckingAccountForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { this.Visible = false; } e.Cancel = true; } The window is removed from the menu, and I currently have no way to bring it back. Ideally I would like to remove the close button from the header of the form but leave the other two. I can't see any way to get rid of that button without losing the others. I may just get rid of the header and add two custom buttons for the other two functions (minimize and full/screen toggle). Any ideas? Another pesky problem is that if I click the close button on the main form, it closes the children but stays open, and I gotta click the close buttong again. Thx.

    N 1 Reply Last reply
    0
    • C CPP_Student

      Howdy! I came across this new forum and realized that I still have a problem with a Windows Forms project I am toying with. I am creating a quicken like program. The main window creates a MDI child for each account (checking, credit card, and broker). I cannot figure out how to handle the close button. I want the form to just hide itself and remain in the main menu item that I dedicated to keeping the names of the children, so that the user can reselect and open the form again. However, this doesn't work: private void CheckingAccountForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { this.Visible = false; } e.Cancel = true; } The window is removed from the menu, and I currently have no way to bring it back. Ideally I would like to remove the close button from the header of the form but leave the other two. I can't see any way to get rid of that button without losing the others. I may just get rid of the header and add two custom buttons for the other two functions (minimize and full/screen toggle). Any ideas? Another pesky problem is that if I click the close button on the main form, it closes the children but stays open, and I gotta click the close buttong again. Thx.

      N Offline
      N Offline
      Newbie00
      wrote on last edited by
      #2

      I don't know why You are defining The FormClosing method.. If You are using VC++ 2005 and you've placed a button on the form, that you want to close, all you have to do is setting up the Behavior property named DialogResult (you can choose the proper result's value from the checkbox placed on the right of the DialogResult property).. If user clicks the button, the form closes. The user can open it from main/parent form's menu again. In order to handle button's click you have to define private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {} method, which you can choose with the button double clicking (in the design form) or with choosing it from the button's events. In abovementioned method's body you can also write code, like this : this->Close(); which will cause closing the form too (the form wich is the owner of the button).

      C 1 Reply Last reply
      0
      • N Newbie00

        I don't know why You are defining The FormClosing method.. If You are using VC++ 2005 and you've placed a button on the form, that you want to close, all you have to do is setting up the Behavior property named DialogResult (you can choose the proper result's value from the checkbox placed on the right of the DialogResult property).. If user clicks the button, the form closes. The user can open it from main/parent form's menu again. In order to handle button's click you have to define private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {} method, which you can choose with the button double clicking (in the design form) or with choosing it from the button's events. In abovementioned method's body you can also write code, like this : this->Close(); which will cause closing the form too (the form wich is the owner of the button).

        C Offline
        C Offline
        CPP_Student
        wrote on last edited by
        #3

        Thanks anyway, but that isn't it. I am talking about the red X button that you get in the right corner of any form you create where you do not set the ControlBox property to false.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups