Sign in to follow this  
generic_name

[.net] Handle to App

Recommended Posts

generic_name    101
Is there anyway to get the handle to an app outside of the main class? I want to put my DirectInput stuff in a class by itself but SetCooperativeLevel needs the handle to the app. I know I could just do this.Handle in my main class and pass it through but I was hoping there was a cleaner solution then passing a variable through several classes.

Share this post


Link to post
Share on other sites
Headkaze    607
It probably goes against the rules of encapsulation but I always have a class called Global that has a bunch of stuff I share between classes.

public class Global
{
public static MainForm Form = null;
}


Then when I create the form I just make Global.Form point to it..

using (Global.Form = new MainForm())
{
...
}


[Edited by - Headkaze on May 5, 2007 8:19:29 PM]

Share this post


Link to post
Share on other sites
generic_name    101
Don't know why I didn't think about using a "Global", I already have a couple of others for things I need to share.

After I've created my OpenGL window I assign it to my global class and it works. This probably isn't the best way to do it, but I really don't want my MainWindow class creating the keyboard and joystick to have it used in my game loop class.

Headkaze, you forgot to give a variable name for Form.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this