gpt4 book ai didi

c++ - 窗口 api 大小和移动控制台

转载 作者:行者123 更新时间:2023-11-28 06:29:08 25 4
gpt4 key购买 nike

我正在尝试使一个函数成为一个允许我在 Windows 上移动和调整控制台大小的函数。目前我这样做了:

int CMD::setSizeAndMove(int top, int left, int width, int height)
//Here we change the size of the window, if the buffer is ok, and change the position
{
SMALL_RECT rect;
rect.Top = top;
rect.Left = left;
rect.Bottom = height;
rect.Right = width;
return SetConsoleWindowInfo(m_consoleHandle, true, &rect);
}

缓冲区没问题。我试图寻找错误,但我得到了一个。错误 n°87:参数无效:参数不正确。

如何解决这个问题,我不太明白我做的是假的。

最佳答案

您的代码中似乎有错误:

SMALL_RECT rect;
rect.Top = top;
rect.Left = left;
rect.Bottom = height;
rect.Right = width;

height 的含义与bottom 的含义不同。 widthright 也类似。尝试更改为类似的内容:

 SMALL_RECT rect;
rect.Top = top;
rect.Left = left;
rect.Bottom = height + top;
rect.Right = width + left;

关于c++ - 窗口 api 大小和移动控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27947264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com