Lucas S.
Lucas S.

Reputation: 332

Window api size and move a console

I'm trying to make a function a function who allow me to move & resize the console on windows. Currently I did that :

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);
}

The buffer is ok. I tried to look error and I get one. The error n°87 : Invalid Parameter : The parameter is incorrect.

How to solve this problem, I don't really undertsand what I do false.

Upvotes: 0

Views: 139

Answers (1)

seva titov
seva titov

Reputation: 11880

There seems to be a bug in your code:

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

The meaning of height is not the same as bottom. Similarly for width and right. Try changing to something like:

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

Upvotes: 1

Related Questions