I am trying to create a method in a class that will create a console window to the desired size. However I am having some serious issues with this seemingly simple task. This code below is a hash together of code from Adrianxw's site and some stuff I found here.
This code here works exactly as expected. But the second I put this into a class and try it, it does not work (I cut and paste the code into a constructor). Also compiled this in another compiler (Visual C++) and it doesn't work. It is really frustrating me because this is a very simple peice of code. Of course the error messages returned from the functions are useless as it appears to be incorrect.
Code:#include <windows.h> #include <iostream.h> int main() { HANDLE hOut; CONSOLE_SCREEN_BUFFER_INFO SBInfo; COORD NewSBSize; int Status; hOut = GetStdHandle(STD_OUTPUT_HANDLE); NewSBSize.X = (short)90; NewSBSize.Y = (short)31; Status = SetConsoleScreenBufferSize(hOut, NewSBSize); if (Status == 0) { Status = GetLastError(); cout << "Buffer: Failed! Error: " << Status << endl; } SMALL_RECT DisplayArea; DisplayArea.Bottom = 30; DisplayArea.Right = 89; Status = SetConsoleWindowInfo(hOut, TRUE, &DisplayArea); if (Status == 0) { Status = GetLastError(); cout << "Screen: Failed! Error: " << Status << endl; } cin.get(); return 0; }



LinkBack URL
About LinkBacks


