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. Detect Opened Forms

Detect Opened Forms

Scheduled Pinned Locked Moved C#
questionhelp
6 Posts 3 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.
  • R Offline
    R Offline
    RizwanSharp
    wrote on last edited by
    #1

    I'm creating and opening new forms from a main form, set its name randomly and call Form.Show() method to show it. Now the problem is how can i detect if user has closed that form or it's still opened? or its closed and disposed. Thanks in advance!!! Best Regards, Rizwan

    S 1 Reply Last reply
    0
    • R RizwanSharp

      I'm creating and opening new forms from a main form, set its name randomly and call Form.Show() method to show it. Now the problem is how can i detect if user has closed that form or it's still opened? or its closed and disposed. Thanks in advance!!! Best Regards, Rizwan

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      How about keeping a reference and checking IsDisposed and Visible property.?.


      www.troschuetz.de

      R 1 Reply Last reply
      0
      • S Stefan Troschuetz

        How about keeping a reference and checking IsDisposed and Visible property.?.


        www.troschuetz.de

        R Offline
        R Offline
        RizwanSharp
        wrote on last edited by
        #3

        Thanks for your interest in helping me. But I think it's not effecient way that I maintain my own global list to count the opened forms. I hope that C# will be having some built in solution for that. Best Regards, Rizwan Ahmed

        S M 2 Replies Last reply
        0
        • R RizwanSharp

          Thanks for your interest in helping me. But I think it's not effecient way that I maintain my own global list to count the opened forms. I hope that C# will be having some built in solution for that. Best Regards, Rizwan Ahmed

          S Offline
          S Offline
          Stefan Troschuetz
          wrote on last edited by
          #4

          In my opinion keeping a list of references wouldn't be that inefficient. Anyway, as far as I know there is no .NET way to interact with a form you have no refernce for. Maybe there is one since 2.0 but i haven't used it until now. If not, keep a look at the findwindow function which you can pinvoke.


          www.troschuetz.de

          R 1 Reply Last reply
          0
          • R RizwanSharp

            Thanks for your interest in helping me. But I think it's not effecient way that I maintain my own global list to count the opened forms. I hope that C# will be having some built in solution for that. Best Regards, Rizwan Ahmed

            M Offline
            M Offline
            mav northwind
            wrote on last edited by
            #5

            Why should C# care how many forms you create and what you do with them? Each Form is an instance of a class like thousands of other instances. You want your forms to do something meaningful so you'll have to see to it yourself. Regards, mav -- Black holes are the places where god divided by 0...

            1 Reply Last reply
            0
            • S Stefan Troschuetz

              In my opinion keeping a list of references wouldn't be that inefficient. Anyway, as far as I know there is no .NET way to interact with a form you have no refernce for. Maybe there is one since 2.0 but i haven't used it until now. If not, keep a look at the findwindow function which you can pinvoke.


              www.troschuetz.de

              R Offline
              R Offline
              RizwanSharp
              wrote on last edited by
              #6

              Thanks, I'm using 2.0 and also know about findwindow and used it in the same application but some other purpose. Lets see if i can get some better solution otherwise i know different ways to do it. Thanks alot!!! Best Regards, Rizwan

              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