10 Replies - 1389 Views - Last Post: 03 March 2012 - 04:55 PM Rate Topic: -----

#1 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 366
  • Joined: 26-May 09

Best way to make forms

Posted 02 March 2012 - 04:00 PM

Hey

I have a main program that declares a class object. Inside this class object there is a list of another object. The idea was that I could have many objects within the main class so as needed they can be added or subtracted.

Public Class objAlerts
    Private alertList As New List(Of alertWindow)

    Public Sub add(ByVal message As objEmailMessages.Email)
        Dim newAlert As New alertWindow(message)
        alertList.Add(newAlert)
    End Sub
End Class

Class alertWindow
    Private alert As frmAlert
    Private alertMessage As objEmailMessages.Email

    Public Sub New(ByVal message As objEmailMessages.Email)
        alert = New frmAlert(message)
        alertMessage = message
        alert.Show()
    End Sub
End Class


As you can see, the alertWindow class has an instance of a form and displays that form. I was wondering if there is a better way to hold and keep track of multiple instances of a form. The current issue is that each form will open, but they are frozen on screen.

Anyone have a good idea as to what would be the best way to handle this?

Is This A Good Question/Topic? 0
  • +

Replies To: Best way to make forms

#2 DimitriV  Icon User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: Best way to make forms

Posted 02 March 2012 - 04:10 PM

So you just want a way to keep track of all the applications open forms?
You can loop through the Application.OpenForms collection.
Was This Post Helpful? -1
  • +
  • -

#3 DimitriV  Icon User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: Best way to make forms

Posted 02 March 2012 - 06:52 PM

Ok. So I was wrong :(
You say that you open multiple of this form and they all remain open onscreen - if it's an alert window you may wish to put a "Dismiss" or "ok" button for the user to click to hide/close the forms - or you could use a timer and auto-hide the forms after a certain period of time.
Was This Post Helpful? 0
  • +
  • -

#4 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 366
  • Joined: 26-May 09

Re: Best way to make forms

Posted 02 March 2012 - 07:49 PM

Hi

The problem is that the forms are all frozen. The mouse pointer shows the cycling circle that rotates forever because of this. I think it is because it is being lost or needs to be threaded or something.

I want to be able to create multiple forms within a class that work independently so I wondering if my current idea is correct or if there is a better way.
Was This Post Helpful? 0
  • +
  • -

#5 DimitriV  Icon User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: Best way to make forms

Posted 02 March 2012 - 08:33 PM

Then you'll need to post the code for FrmAlerts.
Was This Post Helpful? 0
  • +
  • -

#6 DimitriV  Icon User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: Best way to make forms

Posted 02 March 2012 - 08:41 PM

View Postvbnet9, on 03 March 2012 - 12:49 PM, said:

Hi

The problem is that the forms are all frozen. The mouse pointer shows the cycling circle that rotates forever because of this. I think it is because it is being lost or needs to be threaded or something.

I want to be able to create multiple forms within a class that work independently so I wondering if my current idea is correct or if there is a better way.

If you want threading you could look at the MSDN docs for System.Thread:
http://msdn.microsof...hreadstart.aspx
Was This Post Helpful? 0
  • +
  • -

#7 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 366
  • Joined: 26-May 09

Re: Best way to make forms

Posted 02 March 2012 - 10:18 PM

There is nothing really there.

Public Class frmAlert

    Public Sub New(ByVal message As objEmailMessages.Email)

        ' MessageBox.Show("DFDF")

    End Sub
    

  
    Private Sub frmAlert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class


I am not looking for code, I am looking for the best method to control a bunch of forms without them freezing. I want to learn a way that is best.
Was This Post Helpful? 0
  • +
  • -

#8 DimitriV  Icon User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: Best way to make forms

Posted 02 March 2012 - 10:34 PM

What's objEmailMessages?
Was This Post Helpful? 0
  • +
  • -

#9 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 366
  • Joined: 26-May 09

Re: Best way to make forms

Posted 02 March 2012 - 10:36 PM

Its the object that stores messages.
Was This Post Helpful? 0
  • +
  • -

#10 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 366
  • Joined: 26-May 09

Re: Best way to make forms

Posted 03 March 2012 - 04:11 PM

Does anyone have an idea why each form that is opened is completely frozen?

I did a simple
dim alert1 = new frmAlert
alert1.show
dim alert3 = new frmAlert
alert3.show
dim alert2 = new frmAlert
alert2.show

and those windows opened fine in the main program file.

Maybe it has something to do with how I reference the class:
Private userAlerts As New objAlerts


This is defined at the top of the main program file. It holds all the alerts. The idea being, an alert can be added and the alert class will handle everything that has to be done with the alerts. The program just passes information for different class to the right places.

This post has been edited by vbnet9: 03 March 2012 - 04:41 PM

Was This Post Helpful? 0
  • +
  • -

#11 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 366
  • Joined: 26-May 09

Re: Best way to make forms

Posted 03 March 2012 - 04:55 PM

I made a test app with the same class and a form with a button on it so that on each click a new form is added to the class. It worked fine with no freezing.


The only thing then I can wonder is if it is the difference between a form app and what I am using.

The main program is not a form. Does that make a difference? Does there need to be a control form or something?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1