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. .NET (Core and Framework)
  4. How do you make a form close by itself?

How do you make a form close by itself?

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestionlounge
3 Posts 2 Posters 11 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.
  • H Offline
    H Offline
    HJB417
    wrote on last edited by
    #1

    I'm trying to make a popup window, that closes after it executes several functions but it doesn't work because the form stays open. I tried 2 ways, __gc class test1: public Form { public: test1() { Close(); } };//stays open __gc class test: public Form { public: __delegate void delegate(); void close(){Close();} test() { delegate* pDelegate = new delegate(this, &test::close); pDelegate->Invoke(); } };//stays open -------------------------- One problem with the programmer's mentality is insecurity. This goes deep. An insulting college litany says that failed mathematicians become computer programmers. They are also ridiculed for being nerdy losers, for being too fat or too skinny, and for having few social skills. Most programmers can be spotted easily in a crowd. Nobody really wants to hang out with them. Put thousands of these people in one company and if you can get them to work, you become a billiona

    J 1 Reply Last reply
    0
    • H HJB417

      I'm trying to make a popup window, that closes after it executes several functions but it doesn't work because the form stays open. I tried 2 ways, __gc class test1: public Form { public: test1() { Close(); } };//stays open __gc class test: public Form { public: __delegate void delegate(); void close(){Close();} test() { delegate* pDelegate = new delegate(this, &test::close); pDelegate->Invoke(); } };//stays open -------------------------- One problem with the programmer's mentality is insecurity. This goes deep. An insulting college litany says that failed mathematicians become computer programmers. They are also ridiculed for being nerdy losers, for being too fat or too skinny, and for having few social skills. Most programmers can be spotted easily in a crowd. Nobody really wants to hang out with them. Put thousands of these people in one company and if you can get them to work, you become a billiona

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      I'm just recovering from a fresh install so I don't have the framework installed yet; but what happens if you call Close on the test object outside of the constructor? HTH, James Sonork ID: 100.11138 - Hasaki "My words but a whisper -- your deafness a SHOUT. I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972

      H 1 Reply Last reply
      0
      • J James T Johnson

        I'm just recovering from a fresh install so I don't have the framework installed yet; but what happens if you call Close on the test object outside of the constructor? HTH, James Sonork ID: 100.11138 - Hasaki "My words but a whisper -- your deafness a SHOUT. I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972

        H Offline
        H Offline
        HJB417
        wrote on last edited by
        #3

        when I try calling it from outside the constructor, it won't close. What I'm going to try doing is A), create the window in a new background thread and have the foreground thread close it in 3 seconds or B)have the constructor of the new form take a variable.... incomplete thought as of now, will try A) 1st =) ------ The background worker thread method worked __gc class heh: public Form { public: heh() { Size = System::Drawing::Size(300,300); Text = "I Should be gone soon"; } }; __gc class test: public Form { heh* mm; void popup(){ mm->ShowDialog(); } public: test() { Text = "Base Form"; mm = new heh(); Thread* worker = new Thread(new ThreadStart(this, &test::popup)); worker->IsBackground = true; worker->Start(); Thread::Sleep(100); mm->Close(); worker->Abort(); } }; -------------------------- One problem with the programmer's mentality is insecurity. This goes deep. An insulting college litany says that failed mathematicians become computer programmers. They are also ridiculed for being nerdy losers, for being too fat or too skinny, and for having few social skills. Most programmers can be spotted easily in a crowd. Nobody really wants to hang out with them. Put thousands of these people in one company and if you can get them to work, you become a billiona

        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