StuFfii Temat założony przez niniejszego użytkownika |
Czcionka w DOS » 2013-03-15 23:27:46 Witam. Mam pytanie: czy jest możliwość zmiany wielkości czcionki, zmany wyglądu czcionki i dodania polskich znaków w DOS? Chodzi mi głównie o walory estetyczne. Ale najbardziej to by się przydały polskie znaki. Jak tak to prosił bym o podanie kodu umożliwiający dodanie takich"bajerów". |
|
Admixior |
» 2013-03-16 00:07:41 Chodzi o konsolę windows, czy serio o system DOS? //---- Jeśli o konsolę windows to wielkość okna, czcionki, ekranu/bufora, itp. możesz zmieniać w ustawieniach konsoli (możesz zmienić np. na stałe), a także do wszystkich rzeczy odpowiedniki w winapi są, ot to i kawałek biblioteki korzystającej z nich (zmiany rodzaju i wielkości czcionki nie ma): Header: #pragma once #include <windows.h> namespace tlo { enum tlo { BLACK, D_WHITE = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE, D_RED = BACKGROUND_RED, D_GREEN = BACKGROUND_GREEN, D_BLUE = BACKGROUND_BLUE, D_CYAN = BACKGROUND_GREEN | BACKGROUND_BLUE, D_YELLOW = BACKGROUND_GREEN | BACKGROUND_RED, D_PURPLE = BACKGROUND_BLUE | BACKGROUND_RED, WHITE = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY, RED = BACKGROUND_RED | BACKGROUND_INTENSITY, GREEN = BACKGROUND_GREEN | BACKGROUND_INTENSITY, BLUE = BACKGROUND_BLUE | BACKGROUND_INTENSITY, CYAN = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY, YELLOW = BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY, PURPLE = BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY, }; } namespace col { enum czcionka { BLACK, D_WHITE = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, D_RED = FOREGROUND_RED, D_GREEN = FOREGROUND_GREEN, D_BLUE = FOREGROUND_BLUE, D_CYAN = FOREGROUND_GREEN | FOREGROUND_BLUE, D_YELLOW = FOREGROUND_GREEN | FOREGROUND_RED, D_PURPLE = FOREGROUND_BLUE | FOREGROUND_RED, WHITE = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY, RED = FOREGROUND_RED | FOREGROUND_INTENSITY, GREEN = FOREGROUND_GREEN | FOREGROUND_INTENSITY, BLUE = FOREGROUND_BLUE | FOREGROUND_INTENSITY, CYAN = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY, YELLOW = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY, PURPLE = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY, }; } class CConLib { public: CConLib( char * tytul ); ~CConLib(); void SetTitle( char * pTitle ); BOOL SetCursorPosition( int x, int y ); BOOL SetCursorPosition( COORD position ); void ClearConsole(); void ClearConsole( COORD From, COORD To ); void ChangeConsoleSize( int x, int y ); COORD ReturnCursorPosition(); void HideCursor(); void SetTextColor( int color ); void SetBackgroundColor( int color ); private: HANDLE m_hScreen; HANDLE m_hKeyboard; HANDLE m_hConsole; int currentTextColor; int currentBackgroundColor; COORD m_cCursor; CONSOLE_CURSOR_INFO cci; };
Function: #pragma once #include <my\headers\console.h> #include <windows.h> #include <string> #include <conio.h>
CConLib::CConLib( char * pTitle ) { m_hScreen = GetStdHandle( STD_OUTPUT_HANDLE ); m_hKeyboard = GetStdHandle( STD_INPUT_HANDLE ); SetCursorPosition( 0, 0 ); ChangeConsoleSize( 80, 300 ); SetTitle( pTitle ); currentTextColor = col::WHITE; currentBackgroundColor = tlo::BLACK; }
CConLib::~CConLib() { }
void CConLib::SetTitle( char * pTitle ) { SetConsoleTitleA( pTitle ); }
BOOL CConLib::SetCursorPosition( int x, int y ) { COORD Position; Position.X = x; Position.Y = y; return SetConsoleCursorPosition( m_hScreen, Position ); }
BOOL CConLib::SetCursorPosition( COORD position ) { return SetConsoleCursorPosition( m_hScreen, position ); }
void CConLib::ClearConsole() { COORD Start; DWORD dwWritten; Start.X = 0; Start.Y = 0; FillConsoleOutputCharacterA( m_hScreen, ' ', 80 * 300, Start, & dwWritten ); SetConsoleCursorPosition( m_hScreen, Start ); }
void CConLib::ClearConsole( COORD From, COORD To ) { SHORT sWidth = To.X - From.X; SHORT sHeigth = To.Y - From.Y; if(( sWidth > 0 ) &&( sHeigth > 0 ) ) { DWORD dwWritten; FillConsoleOutputCharacterA( GetStdHandle( STD_OUTPUT_HANDLE ), '*', sWidth * sHeigth, From, & dwWritten ); SetConsoleCursorPosition( m_hScreen, From ); } }
COORD CConLib::ReturnCursorPosition() { COORD Position; CONSOLE_SCREEN_BUFFER_INFO info; GetConsoleScreenBufferInfo( m_hScreen, & info ); Position.X = info.dwCursorPosition.X; Position.Y = info.dwCursorPosition.Y; return Position; }
void CConLib::ChangeConsoleSize( int x, int y ) { COORD buffor; buffor.X = x; buffor.Y = y; SetConsoleScreenBufferSize( m_hScreen, buffor ); }
void CConLib::HideCursor() { cci.dwSize = 100; cci.bVisible = FALSE; SetConsoleCursorInfo( m_hScreen, & cci ); }
void CConLib::SetTextColor( int color ) { if( currentTextColor == color ) return; currentTextColor = color; SetConsoleTextAttribute( m_hScreen, color ); }
void CConLib::SetBackgroundColor( int color ) { if( currentBackgroundColor == color ) return; currentBackgroundColor = color; SetConsoleTextAttribute( m_hScreen, color ); }
bool ignore() { while( true ) { if( _kbhit() ) _getch(); else return true; } }
char get_key() { while( true ) { if( _kbhit() ) return _getch(); Sleep( 10 ); } }
std::string & ToPolishChar( std::string & x ) { if( !x.size() ) return x; unsigned int size = x.size(), act = 0; while( act < size ) { if( x[ act ] == 'Ę' ) x[ act ] = '\xA8'; else if( x[ act ] == 'ę' ) x[ act ] = '\xA9'; else if( x[ act ] == 'Ó' ) x[ act ] = '\xE0'; else if( x[ act ] == 'ó' ) x[ act ] = '\xA2'; else if( x[ act ] == 'Ą' ) x[ act ] = '\xA4'; else if( x[ act ] == 'ą' ) x[ act ] = '\xA5'; else if( x[ act ] == 'Ś' ) x[ act ] = '\x97'; else if( x[ act ] == 'ś' ) x[ act ] = '\x98'; else if( x[ act ] == 'Ł' ) x[ act ] = '\x9D'; else if( x[ act ] == 'ł' ) x[ act ] = '\x88'; else if( x[ act ] == 'Ż' ) x[ act ] = '\xBD'; else if( x[ act ] == 'ż' ) x[ act ] = '\xBE'; else if( x[ act ] == 'Ź' ) x[ act ] = '\x8D'; else if( x[ act ] == 'ź' ) x[ act ] = '\xAB'; else if( x[ act ] == 'Ć' ) x[ act ] = '\x8F'; else if( x[ act ] == 'ć' ) x[ act ] = '\x86'; else if( x[ act ] == 'Ń' ) x[ act ] = '\xE3'; else if( x[ act ] == 'ń' ) x[ act ] = '\xE4'; act++; } return x; }
std::string ToPolishChar( char * x ) { std::string str = x; return change_char_for_std( str ); }
|
|
MrPoxipol |
» 2013-03-16 10:34:20 Co do koloru tła konsoli możesz użyć komendy cmd. Wpisz sobie w cmd w Windows komendę color i zobaczysz możliwe wariacje ustawień kolorów :) A nazwę okna też można tak ustawić: SYSTEM( "title Moj Tytul" );
Jeśli chodzi o polskie znaki spróbuj zrobić tak: @downNo nie sprawdziłem, KIS blokuje. Można też użyć funkcji z WinAPI, bodajże SetConsoleTitle() czy jakoś tak ;) |
|
RazzorFlame |
» 2013-03-16 11:36:07 @UP takie rozwiązanie jest idiotyczne. Pierwszy lepszy antywirus to wykryje i dalej sobie nie popłyniesz ;) system("color <id>") ustawia kolor całej konsoli. |
|
« 1 » |