Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, my name is Dave and i'm new on this forum.

I get an error when running this code, it's vb.net and directx9.

display = New Microsoft.DirectX.DirectDraw.Device(CreateFlags.Default)

 

display.SetCooperativeLevel(Me.PictureBox1, CooperativeLevelFlags.Exclusive)

 

this is the error that i get:

An unhandled exception of type 'System.ArgumentException' occurred in microsoft.directx.directdraw.dll

 

Additional information: Value does not fall within the expected range

 

if some one could help me i would be grateful.

 

best regards /DrDave

  • *Experts*
Posted

Run the following file:

c:\DXSDK\Bin\DXUtils\dbmon.exe

 

Then start your project in Debug mode in Visual Studio. The command window opened by dbmon will display a ton of information, including more detailed error messages.

 

My guess is that you're trying to make a picturebox an exclusive device and it can't be done. You can only use a form when going exclusive (fullscreen).

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

wow, that was a fast replay! thank you :)

hmm, is there no way to beable to do a flip to transfer the backbuffer to the front, as it's faster.. ? anyways thank you ones again for your fast replay.

Posted

The error is here:

display.SetCooperativeLevel(Me.PictureBox1, CooperativeLevelFlags.Exclusive)

It should be:

display.SetCooperativeLevel(Me, CooperativeLevelFlags.Exclusive Or CooperativeFlags.FullScreen)

Controls on forms cannot be used for fullscreen displays. If you want a Windowed app you'll need to use the Normal flag.

 

The point of using Exclusive is to have a fullscreen app but Microsoft decided to make the flags seperate to increase confusion. In DX9.Net, however, there is a FullscreenExclusive flag I think.

 

In Normal you cannot use Flip, only Blt. It's probably got something to do with being unable to rearrange Video Memory pointers whilst GDI controls the Video Card.

.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...