Screen refresh problem when exiting managed directdraw windows

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi all

I am trying some simple managed directdraw code in C# (VS2005,
DirectX9sdk) but encouter some troubles when closing my windows (form).

It is a testing application with some kind of "Menu form" where a
button open a new Form in which I initialise a directdraw device and
jus fill a secondary surface with one color & flip it to a primary
surface for displaying each time a key is pressed.

here is what I am doing :
ssurface.ColorFill(Color.Blue ); //fill the backbuffer ( secondary
Surface ) with a color
psurface.Flip(ssurface, FlipFlags.DoNotWait); //flip the backbuffer to
the front

When I do this operation only one time and then I exit the windows
everything is OK I'm back on my remaining Menu form.

But if this operation is done twice or more, when I close the
"directdraw form" the screen is not refreshed and I can only see the
frame of the menu form (or of all the other opened windows) and I have
to move my mouse over it to make the differents controls be refreshed
(and become visible). Then when I click on my "Quit buttton",
everything (all the other windows)is refreshed and ok.

What's happening ? Is there any way to force the refresh of all opened
windows.

thanks in advance for any help!

Sylvain Clément
------------
Here is some piece of my code :


// initialize DirectDraw :
dddevice = new Microsoft.DirectX.DirectDraw.Device(); // Creating
Device Object
dddevice.SetCooperativeLevel(this,
CooperativeLevelFlags.FullscreenExclusive );


// prepare front & back buffer

sdesc.SurfaceCaps.Complex = true;
sdesc.BackBufferCount = 1;
psurface = new Surface(sdesc, dddevice);
psurface.Clipper = clip;
sdesc.Clear();
sdesc.SurfaceCaps.BackBuffer = true;
ssurface = psurface.GetAttachedSurface(sdesc.SurfaceCaps);

// fiil when the B key is pressed (same code for another key but with
a different color).
if (e.KeyCode == Keys.B)
{
ssurface.ColorFill(Color.Blue ); //fill the backbuffer
( secondary Surface ) with a color
psurface.Flip(ssurface, FlipFlags.DoNotWait); //flip
the backbuffer to the front

}


// closing the windows
dddevice.RestoreDisplayMode();
dddevice.SetCooperativeLevel(null, CooperativeLevelFlags.Normal);
psurface.Dispose();
ssurface.Dispose();
this.close();

.



Relevant Pages

  • RE: Help: how to draw on a monitor that is not part of Desktop?
    ... With Win9x, we can use DirectDraw on an unattached display. ... But on Windows ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Webcams and python
    ... I tested VideoCapture using PyGame to draw the graphics. ... SDL which uses DirectDraw on Windows. ...
    (comp.lang.python)
  • Re: DirectDraw?
    ... Note that the reason DirectDraw was deprecated in the first place is because ... is widely available on every version of Windows in the market, ... support is ubiquitous, and actually DirectDraw is just going to mess around ...
    (microsoft.public.win32.programmer.directx.graphics)
  • RE: how to obtain monitors properties?
    ... DirectDraw - PixelFormat, ColorKeyCaps, ColorControl, Caps. ... Direct3D - Device, Manager.GetDeviceCapsreturns a Caps structure, look at ... You can get the size of the display, as a rectangle, from the screen classes ... I'm not sure how to get the more precise info you're looking for, Windows ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Drop shadow problem - nobody could solve it so far
    ... I'm not sure but the problem your Windows may have could be because Refresh ... I too get sometimes the same effects with Drop Shadows but when Resolution - ... Refresh Rate are set accordingly it works perfect. ...
    (microsoft.public.windowsxp.general)