簡體   English   中英

窗口API大小和移動控制台

[英]Window api size and move a console

我正在嘗試使一個函數成為允許我在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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM