Make Console Full Screen?

How Can I make my console full screen?

Page 1 of 1

9 Replies - 27332 Views - Last Post: 16 March 2008 - 06:28 AM Rate Topic: -----

#1 irsmart  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-September 06

Make Console Full Screen?

Post icon  Posted 14 January 2007 - 05:02 PM

I am a very beginning programmer and I was wondering if I could make the console full screen. I searched on Google, but I couldn't find anything. I know that you can press Alt + Enter and it will do it, but is there anything I can embed into the code? I remember using a system command somewhere:
system("command");
, but I don't remember how to do it. If you know anything that can help... thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Make Console Full Screen?

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Make Console Full Screen?

Posted 14 January 2007 - 07:04 PM

What operating system are you using?
Was This Post Helpful? 0
  • +
  • -

#3 jstephens  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 214
  • Joined: 07-November 05

Re: Make Console Full Screen?

Posted 14 January 2007 - 08:09 PM

He is more than likely using windows as that is a windows key to expand the command prompt to take up the full screen.
Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Make Console Full Screen?

Posted 14 January 2007 - 08:15 PM

I agree, but making assumptions is one of the biggest cause of errors in programming, so I try to ensure that solutions provided are in fact the solutions required.
Was This Post Helpful? 0
  • +
  • -

#5 irsmart  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-September 06

Re: Make Console Full Screen?

Posted 14 January 2007 - 10:22 PM

I'm using Windows XP (to be exact). I don't need to worry about this being able to work on other operating systems because I am the only one who would use it.

Thanks.
Was This Post Helpful? 0
  • +
  • -

#6 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Make Console Full Screen?

Posted 15 January 2007 - 12:31 AM

Use the SetConsoleWindowInfo API along with the GetLargestConsoleWindowSize API Function.

You can also use the SetConsoleDisplayMode() API Function or Simulate KeyStrokes using keybd_event() or SendInput().
Was This Post Helpful? 0
  • +
  • -

#7 jmtboz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 02-March 07

Re: Make Console Full Screen?

Post icon  Posted 02 March 2007 - 04:20 PM

View Postborn2c0de, on 15 Jan, 2007 - 12:31 AM, said:

Use the SetConsoleWindowInfo API along with the GetLargestConsoleWindowSize API Function.

You can also use the SetConsoleDisplayMode() API Function or Simulate KeyStrokes using keybd_event() or SendInput().


born2c0de,

This is my first time asking a question, so go easy on me...

I have a similar problem manipulating the console size; I actually found several references to the msdn website, but I don't understand how to implement setConsoleWidowInfo API

I've included windows.h but C++ still has a problem with the setConsoleWidth line.

-Jeremy
Was This Post Helpful? 0
  • +
  • -

#8 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Make Console Full Screen?

Posted 02 March 2007 - 11:42 PM

Quote

This is my first time asking a question, so go easy on me...

Am I really that rude?

You can use two techniques to set the console in fullscreen mode.
  • SetConsoleDisplayMode
  • Simulating the Alt+Enter KeyStrokes (using SendInput() or keybd_event()

I've provided the code for both these methods.
Which compiler are you using?
I'm not sure if Dev C++ supports this, although Borland,VC++ and others do.

MSDN Recommends usage of SendInput rather than keybd_event.
But I'm not sure how it can be done using SendInput, so i've implemented it using the latter.

Here's the code.
#include <windows.h>
#include <conio.h>
#include <iostream.h>

void AltEnter()
{
	keybd_event(VK_MENU,0x38,0,0);
	keybd_event(VK_RETURN,0x1c,0,0);
	keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
	keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);
}

BOOL NT_SetConsoleDisplayMode(HANDLE hOutputHandle, DWORD dwNewMode)
{
	typedef BOOL (WINAPI *SCDMProc_t) (HANDLE, DWORD, LPDWORD);
	SCDMProc_t SetConsoleDisplayMode;
	HMODULE hKernel32;
	BOOL bFreeLib = FALSE, ret;
	const char KERNEL32_NAME[] = "kernel32.dll";

	hKernel32 = GetModuleHandleA(KERNEL32_NAME);
	if (hKernel32 == NULL)
	{
		hKernel32 = LoadLibraryA(KERNEL32_NAME);
		if (hKernel32 == NULL)
			return FALSE;

		bFreeLib = true;
	}

	SetConsoleDisplayMode =
		(SCDMProc_t)GetProcAddress(hKernel32, "SetConsoleDisplayMode");
	if (SetConsoleDisplayMode == NULL)
	{
		SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
		ret = FALSE;
	}
	else
	{
		DWORD tmp;
		ret = SetConsoleDisplayMode(hOutputHandle, dwNewMode, &tmp);
	}

	if (bFreeLib)
		FreeLibrary(hKernel32);

	return ret;
}

int main( void )
{
  int x;
  cout<<"1) Using SetConsoleDisplayMode  (Press Return)\n";
  NT_SetConsoleDisplayMode( GetStdHandle( STD_OUTPUT_HANDLE ), 1 );
  getch();
  NT_SetConsoleDisplayMode( GetStdHandle( STD_OUTPUT_HANDLE ), 0 );
  cout<<"2) Simulating Alt+Enter KeyStrokes  (Press Return)\n";
  getch();
AltEnter();
  getch();
  return 0;
}


Was This Post Helpful? 1

#9 razvan1024  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-March 08

Re: Make Console Full Screen?

Posted 15 March 2008 - 03:54 PM

I have a problem with a full screen console application. I'm using the SetConsoleDisplayMode to make my console full screen. I write data to my console using a console buffer. I set the buffer to display a character on the console but it only displays on the left side of the console. Can someone help me, pls? My console is 80 chars wide and 40 chars in height.
Was This Post Helpful? 0
  • +
  • -

#10 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Make Console Full Screen?

Posted 16 March 2008 - 06:28 AM

Could you post your code as well?
It's rather difficult to track errors without the code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1