On Saturday, 5 October 2013 at 11:24:49 UTC, Andrej Mitrovic wrote:
On 10/5/13, webwraith <webwra...@fastmail.fm> wrote:
Could someone give this code the quick once over and tell me
where I'm going wrong, or simply how to get this to work?

In the docs:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686044%28v=vs.85%29.aspx

It says:

dwSize [in]

    A COORD structure that specifies the new size of the console
screen buffer, in character rows and columns. The specified width and height cannot be less than the width and height of the console screen
buffer's window.
**The specified dimensions also cannot be less than the minimum size allowed by the system. This minimum depends on the current font size for the console (selected by the user) and the SM_CXMIN and SM_CYMIN
values returned by the GetSystemMetrics function.**

So you need to make these calls:

-----
short width = cast(short)(csbi.srWindow.Right - csbi.srWindow.Left); short height = cast(short)(csbi.srWindow.Bottom - csbi.srWindow.Top);

auto minX = GetSystemMetrics(SM_CXMIN);
auto minY = GetSystemMetrics(SM_CYMIN);

c.X = cast(short)max(minX, width);
c.Y = cast(short)max(minY, height);
-----

Also make sure to import std.algorithm to use the max() function.

Thank you for pointing that out. It's a pity it's both annoying and confusing. According to my system, GetSystemMetrics(SM_CXMIN) returns 132, and GetSystemMetrics(SM_CYMIN) returns 38, despite the fact that I can go into the preferences on the console window in question, and create a screen buffer that is 80x20, and even my intended 60x30. Truly frustrating...

Reply via email to