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. C#
  4. preventing a form from closing

preventing a form from closing

Scheduled Pinned Locked Moved C#
helptutorialquestion
5 Posts 4 Posters 0 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.
  • N Offline
    N Offline
    navvara the infantryman
    wrote on last edited by
    #1

    1. When a button is clicked on Form1 it handles the event by creating a new form, like this: newForm *a=new newForm; a.Show(); the problem here is that when Form1 is closed newForm disspaears is closed too. how can a new a form be closed without closing all the forms it created? 2. in the above example newForm also has a button that creates an instance of Form1 when pressed. Form1.h has newForm.h included. the problem here is that when i try to include Form1.h in newForm.h i get an error saying that newForm is not defined in Form1 and Form1 is not defined in newForm.h. m$: It is normal for your screen to go blank and for your computer to restart itself several times

    S D 2 Replies Last reply
    0
    • N navvara the infantryman

      1. When a button is clicked on Form1 it handles the event by creating a new form, like this: newForm *a=new newForm; a.Show(); the problem here is that when Form1 is closed newForm disspaears is closed too. how can a new a form be closed without closing all the forms it created? 2. in the above example newForm also has a button that creates an instance of Form1 when pressed. Form1.h has newForm.h included. the problem here is that when i try to include Form1.h in newForm.h i get an error saying that newForm is not defined in Form1 and Form1 is not defined in newForm.h. m$: It is normal for your screen to go blank and for your computer to restart itself several times

      S Offline
      S Offline
      Sasuko
      wrote on last edited by
      #2

      in the OnClosing event do: e.Cancel = false;

      N 1 Reply Last reply
      0
      • S Sasuko

        in the OnClosing event do: e.Cancel = false;

        N Offline
        N Offline
        navvara the infantryman
        wrote on last edited by
        #3

        to close form1 i call form1.dispose(); that in turn calls components.dispose(); i dunno where to find the OnClosing event anyway setting form1.cancel to false will still close the form whiel allowing it's chold forms to exist? i mean really lose it not just hide it. what about calling Activator.CreateInstance(newForm); i've seen soem refereances to the functione but i have no clue as to what it does. m$: It is normal for your screen to go blank and for your computer to restart itself several times -- modified at 9:33 Friday 30th December, 2005

        1 Reply Last reply
        0
        • N navvara the infantryman

          1. When a button is clicked on Form1 it handles the event by creating a new form, like this: newForm *a=new newForm; a.Show(); the problem here is that when Form1 is closed newForm disspaears is closed too. how can a new a form be closed without closing all the forms it created? 2. in the above example newForm also has a button that creates an instance of Form1 when pressed. Form1.h has newForm.h included. the problem here is that when i try to include Form1.h in newForm.h i get an error saying that newForm is not defined in Form1 and Form1 is not defined in newForm.h. m$: It is normal for your screen to go blank and for your computer to restart itself several times

          D Offline
          D Offline
          Darryl Borden
          wrote on last edited by
          #4

          I do not think there is a way to close a parent form and keep its child forms open. Darryl Borden Principal IT Analyst dborden@eprod.com

          D 1 Reply Last reply
          0
          • D Darryl Borden

            I do not think there is a way to close a parent form and keep its child forms open. Darryl Borden Principal IT Analyst dborden@eprod.com

            D Offline
            D Offline
            Dan Neely
            wrote on last edited by
            #5

            I think the best you can do is to make the parent invisible.

            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