Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetLargestConsoleWindowSize returns incorrect size in Terminal #10337

Closed
alabuzhev opened this issue Jun 4, 2021 · 5 comments
Closed

GetLargestConsoleWindowSize returns incorrect size in Terminal #10337

alabuzhev opened this issue Jun 4, 2021 · 5 comments
Assignees
Labels
Product-Conhost For issues in the Console codebase Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@alabuzhev
Copy link
Contributor

Windows Terminal version (or Windows build number)

1.9.1445.0

Other Software

No response

Steps to reproduce

Compile and run the following code:

#include <iostream>
#include <windows.h>

int main()
{
	COORD c = GetLargestConsoleWindowSize(GetStdHandle(STD_OUTPUT_HANDLE));
	std::cout << "\nWidth:  " << c.X << "\nHeight: " << c.Y << std::endl;
}

Expected Behavior

Some sane output, e.g.

Width:  213
Height: 50

Actual Behavior

Reported width is insanely large:

Width:  1904 
Height: 62

Actual maximum size (maximize the window and type mode con):

> mode con

Status for device CON:
----------------------
    Lines:          47
    Columns:        209
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 4, 2021
@vefatica
Copy link

vefatica commented Jun 4, 2021

If you're familiar with the console API, it's a bit disappointing, but many things don't work when a console app runs in Windows Terminal. For one thing, there is no console window; i.e., no CONSOLE_WINDOW_CLASS window.

This will shed some light: https://docs.microsoft.com/en-us/windows/console/getlargestconsolewindowsize

A year or more ago @DHowett gave me a fairly detailed account of what you can/cannot expect to work. I can't find the issue. If @DHowett chimes in here, perhaps he can dredge it up.

@DHowett
Copy link
Member

DHowett commented Jun 4, 2021

(This is an ongoing discussion, but I need to get my notes in order in order to reply ;P)

@alabuzhev
Copy link
Contributor Author

it's a bit disappointing, but many things don't work when a console app runs in Windows Terminal

I just ranted about that fact elsewhere, but anyways - it's okay if something doesn't work, especially when there are technical limitations. But please, please, make it obvious that it doesn't work by returning FALSE, or, in this particular case, returning {0, 0} and setting the last error to something sensible to give an app a chance to recover.
Currently it's impossible to tell whether the function failed and the result can't be trusted of the user just has one of these and it's okay.

@zadjii-msft zadjii-msft added the Product-Conhost For issues in the Console codebase label Jul 6, 2021
@DHowett DHowett self-assigned this Jul 8, 2021
@zadjii-msft
Copy link
Member

You know, we've had this discussion before as it turns out!

/dup #2712

@ghost
Copy link

ghost commented Dec 9, 2021

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost ghost closed this as completed Dec 9, 2021
@ghost ghost added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Dec 9, 2021
alabuzhev added a commit to FarGroup/FarManager that referenced this issue Jul 15, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product-Conhost For issues in the Console codebase Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

4 participants