Console: how resize the windows?

how can i resize windows Console?
i have these code:
1
2
3
4
5
6
7
8
 void SetWindowSize(COORD newsize)
    {
        PCONSOLE_SCREEN_BUFFER_INFOEX consolesize;
        GetConsoleScreenBufferInfoEx(hConsole,consolesize);
        consolesize->srWindow.Right=(int)newsize.X + consolesize->srWindow.Left;
        consolesize->srWindow.Bottom=(int)newsize.Y + consolesize->srWindow.Top;
        SetConsoleScreenBufferInfoEx(hConsole,consolesize);
    }

but i get a memory leak.
i need a correction: when i resize the window Console i must resize, too, the max window size?
Last edited on
Are you using the new Windows 10 console or the old Windows 8 console?

Why do you even want to resize the console at all?
http://www.cplusplus.com/articles/G13hAqkS/
i'm using windows 7.
1st - i don't agree with that link... why? because i can, easly draw images on Console ;)
(my console class can return the HDC and HWND ... and i have my own class image)

i resolve the memory leak:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void SetWindowSize(COORD newsize)
    {
        CONSOLE_SCREEN_BUFFER_INFOEX consolesize;
        consolesize.cbSize=sizeof(consolesize);
        GetConsoleScreenBufferInfoEx(hConsole,&consolesize);
        COORD c;
        consolesize.srWindow.Right  = newsize.X-1;
        consolesize.srWindow.Bottom = newsize.Y-1;
        CONSOLE_FONT_INFO consolefont={0} ;
        GetCurrentConsoleFont(hConsole, FALSE,&consolefont);
        GetConsoleFontSize(hConsole,consolefont.nFont);
        c.X =(consolesize.srWindow.Right)/consolefont.dwFontSize.X;
        c.Y =(consolesize.srWindow.Bottom)/consolefont.dwFontSize.Y;
        SetConsoleScreenBufferSize( hConsole, c );
        SetConsoleWindowInfo(hConsole, FALSE, &consolesize.srWindow);
    }

my problem is with c.X and c.Y calculations :(
can you advice me?
Topic archived. No new replies allowed.