Jump to content
  • Advertisement
Sign in to follow this  
SelethD

XNA and dialog boxes ?

This topic is 3668 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

I was making an xna game in windows, and i needed to allow the user to save a file. I was wondering if XNA can use the save dialog built into C# or not? If so, how would I do this?

Share this post


Link to post
Share on other sites
Advertisement
Sure, you can use the SaveFileDialog class when you're on the PC. However if you want proper Modal functionality (AKA, have the main window disabled while the SaveFile dialog is open), you'll need to give SaveFileDialog.ShowDialog the handle to your window. If you're using the Game class, the GameWindow class gives you the window handle as an IntPtr. Unfortunately you can't directly use that, since ShowDialog wants an IWin32Window. Fortunately it's easy to get around this...you just need to make your own very simple implementation of IWin32Window. Something like this should work:

public class WindowHandle: System.Windows.Forms.IWin32Window
{
public WindowHandle(IntPtr handle)
{
_hwnd = handle;
}

public IntPtr Handle
{
get { return _hwnd; }
}

private IntPtr _hwnd;
}



Also...I'm not totally sure if SaveFileDialog will work correctly when you're in full screen mode.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!