As it appears that you're coding a windowed app, a better approach might be to size the backbuffer to the client area, rather than the other way 'round. Using a window means the user may move or resize the window for his/her own convenience, and you should respect that. So, when the window is resized:
RECT rect; GetClientRect(hwnd, &rect); params.BackBufferWidth = rect.right - rect.left; params.BackBufferHeight = rect.bottom - rect.top; OnDeviceLost(); // prepare objects for device reset device->Reset( ¶ms ); OnDeviceRestored(); // restore objects after the reset ResetProjectionAspectRatio(); // account for change in the aspect ratio
Perhaps even better than setting the width/height yourself, unless you have some specific reason to size the backbuffer to a particular size, set the BackBufferWidth and BackBufferHeight to 0, and let D3DX set the buffer to the client area dimensions itself. You can do that when creating the device or when the window is resized (device reset). Just remember to check the aspect ratio of your projection matrix whenever the client/backbuffer is resized.