Windows 11, Visual Studio 2022.
The code below works with two monitors, left (#1) and right = #2, main).
The console window defaults to the main monitor (#2). Using the code below I can successfully place the console window in the left monitor (#1).
Using three monitors (#1, #2, #3), the console window always locates in the main window, no matter what coordinates I give. (they are completely ignored with 3 monitors).
bool SetConsolePosition(const int x, const int y, const int width, const int height)
{
HWND console = GetConsoleWindow();
if (console == NULL)
return false;
ShowWindow(console, SW_SHOW);
return SetWindowPos(console, nullptr, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
}
int main()
{
bool result;
result = SetConsolePosition(-2000, 100, 800, 600); // Returns true
return 0;
}