Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6112699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:46:29+00:00 2026-05-23T14:46:29+00:00

Possible Duplicate: Changing the width of a Windows console window? Im writing a simple

  • 0

Possible Duplicate:
Changing the width of a Windows console window?

Im writing a simple brick breaker program. How do I maximize the console window, when the program starts.

#include <iostream>
#include <windows.h>
#include <algorithm>
#include <conio.h>
#define _WIN32_WINNT 0x500
using namespace std;
int lives = 2;
void gotoxy(int x , int y);
void hideCursor();
class Grid
{
      public:
      char grid[20][79];
      void fill()
      {
           for(int i = 0; i < 20; i++)
           {
                   for(int j = 0; j < 79; j++)
                   {
                           grid [i][j] = (char)176;
                   }
            }
      }
      void print()
      {
           gotoxy(0,0);
           for(int i = 0; i < 20; i++)
           {
                   for(int j = 0; j < 79; j++)
                   {
                           cout << grid [i][j];
                   }
                   cout << endl;
           }
      }    
};

class Paddle
{
      public:
      int x_pos;
      char paddle[7];    
      void fill()
      {
           x_pos = 35;
           for (int i = 0; i < 7; i++)
               paddle [i] = (char)219;
      }

      void print()
      {
           gotoxy (x_pos,23);
           for (int j = 0; j < 7; j++)
               cout << paddle [j];
      }
      void redraw()
      {
           for(int i = 0; i < 80; i++)
           {
                   gotoxy (0+i,23);
                   cout << " ";

           } 
           print();  
      }
};
class Ball
{
      public:
      int x_pos, y_pos;
      bool crashed;
      char ball;
      void create()
      {
           ball = 'O';
           crashed = false;
           x_pos = 38;
           y_pos = 22;     
      }
      void show()
      {
           gotoxy (x_pos,y_pos);
           cout << ball;
      }
};

int main()
{ 
    char move;
    Grid grid;
    Paddle paddle;
    Ball ball;
    grid.fill();
    paddle.fill();
    grid.print();
    paddle.print();
    ball.create();
    ball.show();
    hideCursor();
    while(!ball.crashed)
    {
          move = getch();
          move = getch();
          if(move ==  75)
               paddle.x_pos--;
          else if(move == 77)
               paddle.x_pos++;
          paddle.redraw(); 
    }
    cin.get();
    return 0;
}
void hideCursor()
{
    HANDLE cmd;
    CONSOLE_CURSOR_INFO cur;
    char *str = (char*)malloc(32);
    cur.dwSize = 1;
    cur.bVisible = FALSE;  
    cmd = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorInfo(cmd, &cur);
}
void gotoxy(int x , int y)
{
     COORD coord;
     coord.X = x;
     coord.Y = y;
     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:46:30+00:00Added an answer on May 23, 2026 at 2:46 pm

    Call the SetConsoleDisplayMode() function with the CONSOLE_FULLSCREEN_MODE flag.

    [If you want to make the window maximise but not go into full screen mode then it is a lot more complicated because you have to calculate how many columns and rows will exactly fit the screen at the current screen resolution, taking into account the size of the window furniture (caption, scrollbars, borders). That isn’t a trivial task. See GetSystemMetrics(), EnumDisplayMonitors(), GetMonitorInfo(), SetConsoleScreenBufferSize(), etc.]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Filetype association with application (C#) I'm writing a C# Windows app to
Possible Duplicate: Random variable not changing in “for” loop in windows batch file I
Possible Duplicate: Django data migration when changing a field to ManyToMany how I can
Possible Duplicate: Changing a nested (multidimentional) array into key => value pairs in PHP
Possible Duplicate: How can I stop Filezilla changing my linebreaks? For some reason Filezilla
Possible Duplicate: Changing scaling of MATLAB Figure I have an m-size vector f. By
Possible Duplicate: Errors for changing variables content depending on session status Hello! I am
Possible Duplicate JavaScript: Changing src-attribute of a embed-tag but this is not working for
Possible Duplicate: Changing only y pos of background image via Jquery I want to
Possible Duplicate: CodeSign Error after changing Product Name I have been stuck in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.