[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Confused about SubMain Form & Class flow

Posted on 2006-04-29
4
Medium Priority
?
184 Views
Last Modified: 2010-04-23
I am confused about Sub Main, Form & Class flow ..

I'm making a game and I'm gonna have to implement a game loop into the sub main.  But I need a form.  My question is how does the classes access controls on the form? What is the best way to handle this "flow". Do you see what I mean?

Module SubMain

  Private _frmGame as frmGame
  Private _clsObjects as clsObjects
  Private _clsData as clsData

  Public Sub Main
 
    _frmServer = new frmServer
    _clsUsers = new clsUsers
    _clsData = new clsData

     Application.Run(_frmServer)
   
  End Sub

End Module
0
Comment
Question by:Hepen
4 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 16568218
I am trying to guess whether you have previous experience in OpenGL - maybe game loop concept is taken from here.
Windows application built using .NET platform contains internal message loop. Developer must implement event handlers in Windows forms.

There is no need to customize SubMain and it must look by the following way:

Module SubMain

  Public Sub Main
 
     Application.Run(new frmServer)
   
  End Sub

End Module

You must handle various events in frmServer. You need to create and show two additional forms in frmServer_OnLoad or othe place according to your needs. Draw screen in frmServer_OnPaint. Handle user commands in mouse and keyboard event handlers.

Maybe I didn't understand what you mean, please give more details.
Animations are done by timer: add timer to the form and redraw image with some change in timer event handler.
0
 
LVL 3

Expert Comment

by:HouseMusic
ID: 16569155
Alex gave you good info.

But maybe this will help.


Make your form your start up object.

In the form create an instance of the class using withevents.

In your class define the events you want the form to react to.

In the class sub new create a timer and use it to do whatever you want and raise events back to your form at appropriate points.
(use a System.Threading.Timer not  a System Timer .. Trust me on this one!!! The threading /snyc issues wil drive you crazy if you dont)

In the form you just write code for the objects events (make sure the object was declared withevents)





0
 

Author Comment

by:Hepen
ID: 16570204
CAn you give an example of events between a form and a class?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 16582543
Public Class formMain

   Private WithEvents Testing As New Tester

   Private Sub OnTestInitiated(ByVal sender As Object, ByVal e As EventArgs) Handles Testing.TestInitiated
   End Sub

End Class


Public Class Tester

   Public Event TestInitiated As EventHandler

   Public Sub Start()
       RaiseEvent TestInitiated(Me, EventArgs.Empty)
   End Sub

End Class

Bob
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses
Course of the Month19 days, 16 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question