#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Sheffield, UK
    Posts
    94
    Rep Power
    12

    checking to see if a particular form is loaded


    Hi guys

    my solution has multiple forms/data forms. I reference between them,and can get them to popup/close down as needed.

    If my form has a button, and the user clicks on it, the new form will show. However, if the user then clicks again on the button, a new instance of the same form appears.

    Is there any way to check to see if the form is open/loaded/showing/anything but not loaded, and if it is just to gain focus to it again, rather than having a new instance?

    Sounds really complicated, but im sure someone has come across this problem before.

    Ideally, i'd want it where no matter how many times the button is pressed, only one new form appears.

    Can you help?

    Thanks!

    Chris
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Sheffield, UK
    Posts
    94
    Rep Power
    12
    Followup to previous post.

    I believe im after something called the "singleton class".

    Anyone got any info?
  4. #3
  5. WebDeveloper++;
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    New York City
    Posts
    85
    Rep Power
    12
    You could do what I do. You could place a bool variable called for example, isOpened in the top level form class, then check to see if its true or false before opening the form.
    PHP Code:
    public bool isOpened;

    // ...

    if(isOpened == false)
    {
        
    WinForm1 aboutWindow = new WinForm1();
        
    aboutWindow.Show();
        
    isOpened true;

    then to set isOpened back to false set an event for when the form is closed.
    Last edited by CCDemonX; October 15th, 2003 at 02:15 PM.

IMN logo majestic logo threadwatch logo seochat tools logo