Započni novu temu Ova tema je zaključana, ne možete da menjate postove ili da odgovarate  [ 4 Posta ] 
Autoru Poruka
PostPoslato: 01.03.2004. 16:38:45 

Pridružio se: 14.02.2003. 17:20:47
Postovi: 15
Zna li neko kako se brise ekran konzolne aplikacije (pandam ClrScr u pascalu)?


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 01.03.2004. 19:25:20 
Korisnikov avatar

Pridružio se: 09.01.2002. 21:49:51
Postovi: 526
Godina: Padobranac
Pandan clrscr f-je u Pascalu ne postoji u C#. Potrazi malo po net-u i naci ces dosta dobre namespace-ove u kojima se nalaze metode koje ce to obaviti.

_________________
http://www.speedtest.net/result/236970595.png
Slika


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 01.03.2004. 19:47:01 
Korisnikov avatar

Pridružio se: 23.06.2002. 10:23:32
Postovi: 3592
Lokacija: Beograd
Godina: Dipl.
Smer: IS
http://support.microsoft.com/default.aspx?scid=kb;EN-US;319257


Start Microsoft Visual Studio .NET.
Create a new Visual C# Console Application project.
Paste the following using statement at the top of the default class:
using nsClearConsole;

Paste the following code in the Main procedure of the Console application:
static void Main(string[] args)
{
ClearConsole ClearMyConsole = new ClearConsole();
Console.WriteLine("THIS IS FIRST LINE"); // Some text
Console.WriteLine("THIS IS SECOND LINE"); // Some text
Console.WriteLine("THIS IS THIRD LINE"); // Some text
Console.WriteLine("THIS IS FOURTH LINE"); // Some text
Console.WriteLine("THIS IS FIFTH LINE"); // Some text
Console.WriteLine("Hit Enter to Clear"); // Some text
Console.ReadLine(); // Wait for user input
ClearMyConsole.Clear(); // Clear the screen
Console.WriteLine("THE CONSOLE WAS CLEARED"); // Some text to clear console
Console.WriteLine("Hit Enter to Terminate"); //Some text
Console.ReadLine(); // Wait for user input
}

On the Project menu, click Add Class.
In the Add New Item dialog box, select Class, and then click Open.
Replace all of the existing code in the new class with the following code:
using System;
using System.Runtime.InteropServices;

namespace nsClearConsole
{
/// <summary>
/// Summary description for ClearConsole.
/// </summary><BR/>
public class ClearConsole
{
private const int STD_OUTPUT_HANDLE = -11;
private const byte EMPTY = 32;

[StructLayout(LayoutKind.Sequential)]
struct COORD
{
public short x;
public short y;
}

[StructLayout(LayoutKind.Sequential)]
struct SMALL_RECT
{
public short Left;
public short Top;
public short Right;
public short Bottom;
}

[StructLayout(LayoutKind.Sequential)]
struct CONSOLE_SCREEN_BUFFER_INFO
{
public COORD dwSize;
public COORD dwCursorPosition;
public int wAttributes;
public SMALL_RECT srWindow;
public COORD dwMaximumWindowSize;
}

[DllImport("kernel32.dll", EntryPoint="GetStdHandle", SetLastError=true, CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int GetStdHandle(int nStdHandle);

[DllImport("kernel32.dll", EntryPoint="FillConsoleOutputCharacter", SetLastError=true, CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int FillConsoleOutputCharacter(int hConsoleOutput, byte cCharacter, int nLength, COORD dwWriteCoord, ref int lpNumberOfCharsWritten);

[DllImport("kernel32.dll", EntryPoint="GetConsoleScreenBufferInfo", SetLastError=true, CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int GetConsoleScreenBufferInfo(int hConsoleOutput, ref CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);

[DllImport("kernel32.dll", EntryPoint="SetConsoleCursorPosition", SetLastError=true, CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int SetConsoleCursorPosition(int hConsoleOutput, COORD dwCursorPosition);

private int hConsoleHandle;

public ClearConsole()
{
//
// TODO: Add constructor logic here.
//
hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
}

public void Clear()
{
int hWrittenChars = 0;
CONSOLE_SCREEN_BUFFER_INFO strConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
COORD Home;
Home.x = Home.y = 0;
GetConsoleScreenBufferInfo(hConsoleHandle, ref strConsoleInfo);
FillConsoleOutputCharacter(hConsoleHandle, EMPTY, strConsoleInfo.dwSize.x * strConsoleInfo.dwSize.y, Home, ref hWrittenChars);
SetConsoleCursorPosition(hConsoleHandle, Home);
}
}
}

Press F5 to run the application. Note that the text in the Console window is cleared.

_________________
.ılı.ılı.


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
 Tema posta:
PostPoslato: 01.03.2004. 20:02:16 

Pridružio se: 14.02.2003. 17:20:47
Postovi: 15
Hvala vam prijatelji !


Share on FacebookShare on TwitterShare on Google+
Vrh
 Profil  
Odgovori sa citatom  
Prikaži postove u poslednjih:  Poređaj po  
Započni novu temu Ova tema je zaključana, ne možete da menjate postove ili da odgovarate  [ 4 Posta ] 


Ko je OnLine

Korisnici koji su trenutno na forumu: Nema registrovanih korisnika i 6 gostiju


Ne možete postavljati nove teme u ovom forumu
Ne možete odgovarati na teme u ovom forumu
Ne možete monjati vaše postove u ovom forumu
Ne možete brisati vaše postove u ovom forumu
Ne možete slati prikačene fajlove u ovom forumu

Pronađi:
Idi na:  
cron
Copyleft FONForum 2001-2014 | Powered by phpBB © phpBB Group