Jump to content
  • Advertisement
Sign in to follow this  
generic_name

[.net] Handle to App

This topic is 4067 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
If you're using WinForms or the WPF, there should be a static property along the lines of
Application.Current

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!