Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I am trying to make a fullscreen DirectX application with C#. In my mainloop I call Application.DoEvents() that Windows can process the KeyEvents... If I do so, I get a "InvalidCallException". I don't have the problem when I run the application in non-fullscreen-mode.

Could anyone please help me? Many thanks in advance.
Posted

Can you take out the Application.DoEvents() call and have it work in full screen?

It you can't, then you need to change your present parameters.

Ex.

C#
presentParams.Windowed = false;

See the following link[^].

It might help if you provide more information on the exception as well.
 
Share this answer
 
If I ommit the Application.DoEvents() call, the app is working in fullscreen mode, but the OnKeyPress(KeyPressEventArgs e) is not working anymore since windows seems not to have any resources left vor event-handling.

If I turn on the Application.DoEvents() call, I get this error-message:

Error in the application.
-2005530516 (D3DERR_INVALIDCALL)
   at Microsoft.DirectX.Direct3D.Device.Reset(PresentParameters[] presentationParameters)
   at Microsoft.DirectX.Direct3D.Device.OnParentResized(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnResize(EventArgs e)
   at System.Windows.Forms.Form.OnResize(EventArgs e)
   at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
   at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
   at System.Windows.Forms.Control.UpdateBounds()
   at System.Windows.Forms.Control.WmWindowPosChanged(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmWindowPosChanged(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 
Share this answer
 
Comments
Andrew Rissing 8-Jun-10 14:09pm    
This error sounds familiar. I believe it is because you're not resizing your device upon the window its being displayed in being resized. I don't know if it'll help, but you can check out my AViD project. It might help you to play with some working DirectX .NET code to figure out how to get your code working.

http://www.codeproject.com/KB/directx/AViD.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900