Skip to content

Commit d08ec68

Browse files
Replace default /L functionality and wrap it in /A
1 parent 132bc4f commit d08ec68

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

DPEdit/DPEdit/DPEdit.cpp

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*--------------------------------------------------------------
2-
| Display Position Editor v1.3.3 |
2+
| Display Position Editor v1.4.0 |
33
| By Benjamin J. Pryor |
44
|--------------------------------------------------------------|
55
| A simple command line utility to accurately set the relative |
@@ -20,22 +20,22 @@
2020
using namespace std;
2121

2222
void set_display_pos(int argc, char** argv);
23-
void list_displays(void);
23+
void list_displays(bool showAll);
2424
void show_help(void);
2525
bool is_valid_int(string s);
2626

2727
int main(int argc, char** argv)
2828
{
2929
if (argc > 1) {
3030

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], "/?"))
3432
show_help();
3533

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+
}
3939

4040
else set_display_pos(argc, argv);
4141

@@ -79,39 +79,42 @@ void set_display_pos(int argc, char** argv) {
7979
}
8080
}
8181

82-
void list_displays(void) {
82+
void list_displays(bool showAll) {
8383
DISPLAY_DEVICE displayDevice{ sizeof displayDevice, };
8484

8585
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+
}
102104
}
103105
}
104106
}
105107

106108
void show_help(void) {
107-
wcout << endl << "DPEdit 1.3.3" << endl;
109+
wcout << endl << "DPEdit 1.4.0" << endl;
108110
wcout << "A command line utility to accurately position displays in a multi-monitor setup." << endl << endl;
109111
wcout << "Usage: dpedit.exe [/H] [/?]" << endl;
110112
wcout << " dpedit.exe /L" << endl;
111113
wcout << " dpedit.exe <displayNum> <xPos> <yPos> [<displayNum2> <xPos2> <yPos2>] ..." << endl << endl;
112114
wcout << " Options:" << endl << endl;
113115
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;
115118
wcout << " <displayNum> The index of the display to position" << endl;
116119
wcout << " <xPos> The X (horizontal) position of the top-left corner of display <displayNum>." << endl;
117120
wcout << " <YPos> The Y (vertical) position of the top-left corner of display <displayNum>." << endl << endl;

0 commit comments

Comments
 (0)