Reputation: 12904
Here goes my code
DEVMODE dm;
int index = 0;
while(0 != EnumDisplaySettings(NULL, index++, &dm)){
qDebug() << index-1 << dm.dmPelsWidth << dm.dmPelsHeight;
Resolution* resolution = new Resolution(dm.dmPelsWidth, dm.dmPelsHeight);
}
Outputs
0 320 200
1 320 200
2 320 200
3 320 240
4 320 240
5 320 240
6 400 300
7 400 300
8 400 300
9 512 384
10 512 384
11 512 384
12 640 400
13 640 400
14 640 400
15 640 480
.....
25 640 480
26 640 480
27 800 600
.....
41 800 600
42 1024 768
50 1024 768
51 1152 864
....
62 1152 864
63 1280 600
I get only one thing in return that is 320x200
not even the 1600x900
which is my current Resolution.
Upvotes: 0
Views: 1458
Reputation: 45252
EnumDisplaySettings
gives you every possible combination of screen parameters.
The trick is knowing which fields of the DEVMODE
structure to pay attention to.
These significant fields are:
For example, here are the first 14 legitimate settings for my monitor:
dmPelsWidth dmPelsHeight dmBitsPerPixel dmDisplayFrequence dmDisplayFixedOutput 640 480 8 59 Default 640 480 8 59 Stretch 640 480 8 59 Center 640 480 8 60 Default 640 480 8 60 Stretch 640 480 8 60 Center 640 480 8 75 Default 640 480 16 59 Default 640 480 16 59 Stretch 640 480 16 59 Center 640 480 16 60 Default 640 480 16 60 Stretch 640 480 16 60 Center 640 480 16 75 Default (... etc ...)
Upvotes: 2
Reputation: 182689
You need to call it in a loop. My feeling is that replacing the if
with a while
will instantly solve this.
Upvotes: 0