Sign in to follow this  
GuyWithBeard

[.net] C# Fullscreen video problem

Recommended Posts

Hi! I have a problem with my managed game engine in that pressing Esc when in fullscreen mode the render window gets minimized for no apparent reason. When in windowed mode this does not happen, and I certainly have not hooked the Esc-keystroke to any event or function that would cause the window to minimize. Other keys do not minimize the window, just Esc and only in fullscreen mode. I use C# and Managed DirectX 1.1. The window is shown with ShowDialog(). Any ideas? //chinc

Share this post


Link to post
Share on other sites
Try using just "Show" instead of "ShowDialog", and see if that makes a difference.

ShowDialog may be performing some default action (ie, closing the window), when you hit escape, since the window is treated as a dialog box. There's no reason to use ShowDialog for full screen rendering anyways.

[Edited by - gharen2 on March 8, 2007 1:08:37 AM]

Share this post


Link to post
Share on other sites
When using Show() instead of ShowDialog() the render window just flashes and closes. I know I should be using Application.Run() with the window as a parameter but then I cannot close the window and show it again during the same program run. Anyone know why?

However, I solved the problem in a very easy but wierd way. It seems that I just have to call this.Focus() in the keydown event handler of the window and everything works fine. Don't know why, but it works :)

Share this post


Link to post
Share on other sites
The reason your window immediately closes with "show" is that the function returns after showing the window, and your program ends. This is different from ShowDialog, which doesn't return until an action is performed (hitting escape in your case). You need to setup a loop so it stays open.

I don't recommend using Application.Run in a game. You can have full control over the rendering loop this way:


public static void Main
{
Form form = new Form();
form.Show();
// initialise directx
while(form.Created)
{
if(form.Active)
{
// render
}
Application.DoEvents();
}
}


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