Advertisement
huutho_96

Untitled

Sep 20th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <Windows.h>
  4.  
  5. void gotoxy(short x, short y)
  6. {
  7. HANDLE hConsoleOutput;
  8. COORD Cursor_an_Pos = { x, y };
  9. hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
  10. SetConsoleCursorPosition(hConsoleOutput, Cursor_an_Pos);
  11. }
  12.  
  13. void SetWindowSize(int Width, int Height)
  14. {
  15. _COORD coord;
  16. coord.X = Width;
  17. coord.Y = Height;
  18.  
  19. _SMALL_RECT Rect;
  20. Rect.Top = 0;
  21. Rect.Left = 0;
  22. Rect.Bottom = Height - 1;
  23. Rect.Right = Width - 1;
  24.  
  25. HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE);
  26. if (Handle == NULL)
  27. {
  28. cout << "Failure in getting the handle\n" << GetLastError();
  29. }
  30.  
  31. if (!SetConsoleScreenBufferSize(Handle, coord))
  32. {
  33. cout << "Failure in setting buffer size\n" << GetLastError();
  34. }
  35.  
  36. if (!SetConsoleWindowInfo(Handle, TRUE, &Rect))
  37. {
  38. cout << "Failure in setting window size\n" << GetLastError();
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement