MDX OnResize Exception

MickD

Member
Joined
Jul 30, 2006
Messages
6
Location
Gerringong, NSW Australia
Hi All, Im new to DirectX and have been studying the tuts in the sdk but have come across a small problem when resizing the form.
I noticed they handle Minimised in the OnResize override but when I size the window to nothing vertically it throws an exception. There is also code in place to handle pausing and reseting the device, these things I can understand but dont help.
Ive searched high and low for a good explanation but so far Ive come up short. Ive seen code that handles the sizing of panels to prevent them from being (0,0) say but how do you handle a forms client rect?
I probably will move it to a panel anyway but Id just like to work this one out first.
If you need to see some error reports or code, let me know but I dont think this is an isolated problem and hopefully Im just missing something simple.
Thanks in advance for any help,
Cheers,
Mick.

Whoops, my appologies for posting in the wrong forum, could a mod make the changes if needed, thanks.
 
Why not set a minimum size for the form that would prevent the client rectangle from becoming zero-width or zero-height.
 
I tried setting the forms minimum size in the constructor but no go -
this.MinimumSize = new Size(1,1);

This is the error from the call stack -

MatricesTutorial.exe!MatricesTutorial.Matrices.OnResetDevice(System.Object sender = {Microsoft.DirectX.Direct3D.Device}, System.EventArgs e = null) Line 88

and heres the code where its crashing when the app breaks -
Code:
public void OnResetDevice(object sender, EventArgs e)
		{
			Device dev = (Device)sender;
			// Turn off culling, so we see the front and back of the triangle
			dev.RenderState.CullMode = Cull.None;
			// Turn off D3D lighting, since we are providing our own vertex colors
			dev.RenderState.Lighting = false;// <---breaks here****
		}

Thanks for your speedy reply marble_eater :)
 
Ive even tried something simple like this but it breaks before it happens I think??

Code:
protected override void OnResize(System.EventArgs e)
        {
            pause = ((this.WindowState == FormWindowState.Minimized) || !this.Visible || this.Size.Height < 2);//check height!
        }
 
The MinimumSize property sets the minimum values for the forms Size property, not the ClientSize property. You can either use a minimum size that is (almost) guarunteed to result in a client size at least one pixel, or you can calculate the minimum allowable size by getting the window border sizes from the SystemInformation class, and adding one to each pair of borders (left border size + right border size + 1 and top border size + bottom border size + 1).
 
Ok, Ill do a bit of study and let you know how I go, thanks again.

Ive tested this on all tuts Ive found so far and all have the same problem (all have different results for the errors though). I know its probably not a common thing to do but I did it and it wouldnt be good for the end user to find it either , and I just might learn something on the way
:)
 
A quick work around for now but doesnt solve the real issue, I set the minimum size to something like (30, 50) and it stopped it sizing too small, even though it was letting the height go much smaller than 50 when dragging the border!
There must be a way to tell the device or something that theres no client area to paint on and pause or something, I think Im not catching the events quick enough, more study...
Cheers,
Mick.
 
Heres how I solved this problem in my app.

In the constructor of my Direct3D control, I hook up the
 
Back
Top