|
1 | 1 | /*--------------------------------------------------------------
|
2 |
| - | Display Position Editor v1.3.3 | |
| 2 | + | Display Position Editor v1.4.0 | |
3 | 3 | | By Benjamin J. Pryor |
|
4 | 4 | |--------------------------------------------------------------|
|
5 | 5 | | A simple command line utility to accurately set the relative |
|
|
20 | 20 | using namespace std;
|
21 | 21 |
|
22 | 22 | void set_display_pos(int argc, char** argv);
|
23 |
| -void list_displays(void); |
| 23 | +void list_displays(bool showAll); |
24 | 24 | void show_help(void);
|
25 | 25 | bool is_valid_int(string s);
|
26 | 26 |
|
27 | 27 | int main(int argc, char** argv)
|
28 | 28 | {
|
29 | 29 | if (argc > 1) {
|
30 | 30 |
|
31 |
| - if (!strcmp(argv[1], "/H") |
32 |
| - || !strcmp(argv[1], "/h") |
33 |
| - || !strcmp(argv[1], "/?")) |
| 31 | + if (!strcmp(argv[1], "/H") || !strcmp(argv[1], "/h") || !strcmp(argv[1], "/?")) |
34 | 32 | show_help();
|
35 | 33 |
|
36 |
| - else if (!strcmp(argv[1], "/L") |
37 |
| - || !strcmp(argv[1], "/l")) |
38 |
| - list_displays(); |
| 34 | + else if (!strcmp(argv[1], "/L") || !strcmp(argv[1], "/l")) { |
| 35 | + if (argc > 2 && (!strcmp(argv[2], "/A") || !strcmp(argv[2], "/a"))) |
| 36 | + list_displays(true); |
| 37 | + else list_displays(false); |
| 38 | + } |
39 | 39 |
|
40 | 40 | else set_display_pos(argc, argv);
|
41 | 41 |
|
@@ -79,39 +79,42 @@ void set_display_pos(int argc, char** argv) {
|
79 | 79 | }
|
80 | 80 | }
|
81 | 81 |
|
82 |
| -void list_displays(void) { |
| 82 | +void list_displays(bool showAll) { |
83 | 83 | DISPLAY_DEVICE displayDevice{ sizeof displayDevice, };
|
84 | 84 |
|
85 | 85 | for (long i = 0; EnumDisplayDevices(nullptr, i, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME); i++) {
|
86 |
| - wcout << endl; |
87 |
| - wcout << "Display #" << i + 1 << endl; |
88 |
| - wcout << "Device name: " << displayDevice.DeviceName << endl; |
89 |
| - wcout << "Device string: " << displayDevice.DeviceString << endl; |
90 |
| - wcout << "Active: " << (displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE) << endl; |
91 |
| - wcout << "Mirroring: " << (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) << endl; |
92 |
| - wcout << "Modes pruned: " << (displayDevice.StateFlags & DISPLAY_DEVICE_MODESPRUNED) << endl; |
93 |
| - wcout << "Primary: " << (displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) << endl; |
94 |
| - wcout << "Removable: " << (displayDevice.StateFlags & DISPLAY_DEVICE_REMOVABLE) << endl; |
95 |
| - wcout << "VGA compatible: " << (displayDevice.StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE) << endl; |
96 |
| - |
97 |
| - DEVMODE devMode{ {}, {}, {}, sizeof devMode, 0, }; |
98 |
| - if (EnumDisplaySettings(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode)) |
99 |
| - { |
100 |
| - wcout << "Dimensions: {" << devMode.dmPelsWidth << ", " << devMode.dmPelsHeight << "}" << endl; |
101 |
| - wcout << "Position: {" << devMode.dmPosition.x << ", " << devMode.dmPosition.y << "}" << endl; |
| 86 | + if (showAll || (displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE)) { |
| 87 | + wcout << endl; |
| 88 | + wcout << "Display #" << i + 1 << endl; |
| 89 | + wcout << "Device name: " << displayDevice.DeviceName << endl; |
| 90 | + wcout << "Device string: " << displayDevice.DeviceString << endl; |
| 91 | + wcout << "Active: " << (displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE) << endl; |
| 92 | + wcout << "Mirroring: " << (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) << endl; |
| 93 | + wcout << "Modes pruned: " << (displayDevice.StateFlags & DISPLAY_DEVICE_MODESPRUNED) << endl; |
| 94 | + wcout << "Primary: " << (displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) << endl; |
| 95 | + wcout << "Removable: " << (displayDevice.StateFlags & DISPLAY_DEVICE_REMOVABLE) << endl; |
| 96 | + wcout << "VGA compatible: " << (displayDevice.StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE) << endl; |
| 97 | + |
| 98 | + DEVMODE devMode{ {}, {}, {}, sizeof devMode, 0, }; |
| 99 | + if (EnumDisplaySettings(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode)) |
| 100 | + { |
| 101 | + wcout << "Dimensions: {" << devMode.dmPelsWidth << ", " << devMode.dmPelsHeight << "}" << endl; |
| 102 | + wcout << "Position: {" << devMode.dmPosition.x << ", " << devMode.dmPosition.y << "}" << endl; |
| 103 | + } |
102 | 104 | }
|
103 | 105 | }
|
104 | 106 | }
|
105 | 107 |
|
106 | 108 | void show_help(void) {
|
107 |
| - wcout << endl << "DPEdit 1.3.3" << endl; |
| 109 | + wcout << endl << "DPEdit 1.4.0" << endl; |
108 | 110 | wcout << "A command line utility to accurately position displays in a multi-monitor setup." << endl << endl;
|
109 | 111 | wcout << "Usage: dpedit.exe [/H] [/?]" << endl;
|
110 | 112 | wcout << " dpedit.exe /L" << endl;
|
111 | 113 | wcout << " dpedit.exe <displayNum> <xPos> <yPos> [<displayNum2> <xPos2> <yPos2>] ..." << endl << endl;
|
112 | 114 | wcout << " Options:" << endl << endl;
|
113 | 115 | wcout << " /H, /? Shows this help page" << endl;
|
114 |
| - wcout << " /L Lists all displays and their indices" << endl; |
| 116 | + wcout << " /L Lists active displays and their indices" << endl; |
| 117 | + wcout << " /A Forces /L to list all registered displays" << endl; |
115 | 118 | wcout << " <displayNum> The index of the display to position" << endl;
|
116 | 119 | wcout << " <xPos> The X (horizontal) position of the top-left corner of display <displayNum>." << endl;
|
117 | 120 | wcout << " <YPos> The Y (vertical) position of the top-left corner of display <displayNum>." << endl << endl;
|
|
0 commit comments