Jump to content
  • Advertisement
Sign in to follow this  
GuyWithBeard

[.net] C# Fullscreen video problem

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

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
Advertisement
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
because the Focus event restores a minimized window... so you're really minimizing and restoring it back very quickly.

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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!