View Full Version : Clear Screen
Submerge
08-09-2003, 10:33 PM
How do you guys go about clearing the screen on a C++ application since there is no official way to do it. I'd just like to know the best way since im starting out.
:cheers:
my teacher is talking about a header file:
#include <msoftcon.cpp>
but she says it doesn't always work and it's not accepted officially in c++ books cuz it has errors. anyone got an error free way?
dbsynergy
08-09-2003, 10:55 PM
are we talking about a console app? of so,
system("cls");
I think that is right, you may not need the quotes.
rootbin
08-09-2003, 11:14 PM
VOID g_Application::ClearScreen()
{
DDBLTFX clsBltFX;
ZeroMemory(&clsBltFX, sizeof(clsBltFX));
clsBltFX.dwSize = sizeof(clsBltFX);
lpddsBack->Blt(0, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &clsBltFX);
}
:D
edit: btw that code is a copyrighted part of my upcoming game, avanti ;)
khaki
09-09-2003, 03:56 AM
for ( int i = 0; i < 100; i++ )
{
cout << endl;
}
:P (joking)
Submerge
09-09-2003, 10:18 PM
^wat does that do...im just starting out so im not that much knowing of everything u stated.
Submerge
09-09-2003, 10:28 PM
Originally posted by rootbin
VOID g_Application::ClearScreen()
{
DDBLTFX clsBltFX;
ZeroMemory(&clsBltFX, sizeof(clsBltFX));
clsBltFX.dwSize = sizeof(clsBltFX);
lpddsBack->Blt(0, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &clsBltFX);
}
:D
edit: btw that code is a copyrighted part of my upcoming game, avanti ;)
thus i can't use it right.
khaki
10-09-2003, 03:44 AM
Originally posted by Submerge
^wat does that do...im just starting out so im not that much knowing of everything u stated.
It sends a 100 blank lines to the console screen. Though thats not a very efficient way of clearing the screen, it works.
Here is a more efficient answer. http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385
rootbin
11-09-2003, 01:16 AM
Originally posted by Submerge
thus i can't use it right.
it was sarcasm. that's all directx code.
Yeah the DirectX bit won't help you much lol...
There's some bass-ackwards way that M$ lets you do it with their weird console API stuff, or, yeah, you can use
system("cls");
...which will run the "cls" command, which clears the screen. I remember seeing a clrscr() function or something a long time ago, but MSVC didn't support it. Maybe it was just a Borland thing...
-Syko
CyberSh33p
17-09-2003, 01:35 AM
clrscr, I remember using that when I was learning c. which was only last year. So, clrscr should work, at least if you are using gcc.
Impute
20-09-2003, 05:07 AM
Originally posted by khaki
for ( int i = 0; i < 100; i++ )
{
cout << endl;
}
:P (joking)
lol
Evgeny
22-09-2003, 03:33 AM
what about just #include <conio.h> clrscr(); or are we talking about win32 programs here?
Vextor
22-09-2003, 02:11 PM
clsscr worked under the djgpp compiler, and that used a mainstream standard didn't it? That SHOULD work.
Tee Kyoo Em
22-09-2003, 04:58 PM
In a console application, under a non-Microsoft C++ compiler use a clrscr function, or alternatively, send an escape sequence (ESC[2J) to the output stream.
Otherwise read this article.
http://support.microsoft.com/support/kb/articles/Q99/2/61.asp
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.