【问题标题】:Window api size and move a console窗口 api 大小和移动控制台
【发布时间】:2015-01-14 16:02:50
【问题描述】:

我正在尝试使一个函数成为允许我在 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 : Invalid Parameter : 参数不正确。

如何解决这个问题,我真的不明白我做错了什么。

【问题讨论】:

    标签: c++ api console window


    【解决方案1】:

    您的代码中似乎存在错误:

    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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 2014-11-12
      • 1970-01-01
      • 1970-01-01
      • 2014-03-29
      • 2019-09-23
      相关资源
      最近更新 更多