DX Resize Problems

Title: DX Resize Problems
Written: April 8, 2004

This document will help you understand why you may be getting a DriverInternalErrorException exception when rendering in windowed mode. I should also say that the details pertaining to what I think is going on behind the scenes with directx may be inaccurate so don't quote me on them.

First if you are rendering to a control that is either docked or anchored on your form that may be your first problem. As I understand it, DirectX automatically resizes the back buffer to the same size of the target control when the target control is resized. So the problem occurs when you resize or minimize your form the size of that control is set to 0,0. And there in lies the problem. You can't have a back buffer with a width or height of 0! So to solve the problem You will need to position and size the control on your form manually.

In the fallowing code snip I have placed a panel control (pnlWorkArea) on my form and have set it's dock property to Fill. Then I have placed a picture box control (pbWorkArea) inside of pnlWorkArea and have set it's location property to 0,0. Now under the resize event for pnlWorkArea I have added the fallowing code ...

Private Sub pnlWorkArea_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlWorkArea.Resize

    If pnlWorkArea.ClientSize.Width < 4 Then Exit Sub

    If pnlWorkArea.ClientSize.Height < 4 Then Exit Sub

    pbWorkArea.Size = pnlWorkArea.ClientSize

End Sub

... Now any time I resize or minimize my form I will no longer have that nasty DriverInternalErrorException exception being raised.


Authors Note: April 21, 2004

This is the response I got back from Microsoft regarding this issue ...

The following was received from the Managed DirectX development team:

No, it's not really valid, and no I don't believe we should create a bug for the issue.

Before the device automatically resets the backbuffer it raises an event (DeviceResizing), that allows you to cancel this behavior. It is up to the application to determine whether they want to allow the resize or not, not MDX..

... So there you have it folks Microsoft's answer to the DriverInternalErrorException exception dilemma. I guess it really doesn't matter what method you use to deal with a possible DriverInternalErrorException exception so long as you deal with it gracefully.

Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume