Scrolling Game Development Kit Forum
SGDK Version 2 => Help, Errors, FAQ => Topic started by: v6v on 2012-02-16, 06:28:36 PM
-
private void OpenNewSeq(object sender, System.EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
openFileDialog1.ShowDialog();
//openFileDialog1.Dispose(); Commented out, it doesn't affect the results anyways.
}
Within GameForm.cs
I'm calling this method with an Event Handler, when my game is run, I go to File > Open, and when Open is clicked, it runs this function.
The only problem is that the window freezes. Is there somewthing I'm doing wrong?
-
This one had me stumped for a few minutes. I had to run the project in the C# IDE. And for some reason when I did that I got an error instead of a freeze that explained what needed to be done: you need to add [STAThread()] above the Main function in Project.cs.
So:
1. Open Project.cs
2. Find public static void Main()
3. Make it look like this:
[STAThread()]
public static void Main()
{
try
{
GameDisplayMode mode = (GameDisplayMode)System.Enum.Parse(typeof(GameDisplayMode), m_res.GetString("_DisplayMode"));
...
-
Merci, works like a charm. I can use this for the Open and SaveFile Dialogs.