Is it possible to detect desktop resolution

Started by
3 comments, last by DividedByZero 15 years, 6 months ago
Is is possible to detect what resolution a user's desktop is before creating a render window? For example, on one PC my normal resolution is 1440 x 900 and the other is 1024 x 768. I want my app to automatically initialise the render window to the appropriate desktop resolution without the user having to prompt to do it. If so, is the process the same for DX9 & 10 Thanks in advance.
Advertisement
Yes this is possible, the easiest way in C/C++ is using GetSystemMetrics(SM_CXSCREEN) and GetSystemMetrics(SM_CYSCREEN), for the width and height respectively.
If you want to enable the user to choose a different screen you have to use different methods. You can use the GetMonitorInfo function to get information about a monitor. Look up the MSDN page for additional information.

EDIT: Depending on how you create your device this can be handled automatically for you, with different screens taken into account by the API. Check some of the examples that comes with the SDK, the framework they use fix these things and comes with source.
For example by simply creating your device with D3D10CreateDeviceAndSwapChain in windowed mode, it will automatically use the correct resolution when switching to fullscreen. I often use this since it's easy.
Cool, thanks for the quick reply.
I'll check tose suggestions out and let you know how it goes.
Or use IDirect3D9::GetAdapterDisplayMode for an adapter's current display mode (resolution, color depth/format and refresh rate).

Edit: Although this would probably only work best for full-screen apps.
Million-to-one chances occur nine times out of ten!
That will probably be the method I am after.

I am planning on having my app full-screen when it is complete. So, while in a debugging window mode, i'll probably just use half or three quarter screen resolution.

This topic is closed to new replies.

Advertisement