000
30.04.2007, 17:29 Uhr
~Siegfried75
Gast
|
Hallo. Ich habe einen Code mit dem kann ich aber nur Bunt schreiben. Ich möchte HTML Daten für die Dos Console normal lesbar machen und ich Möchte die html Datei mit in die exe einbinden.
Hier ist mein farb code:
C++: |
#include <windows.h>
class Console { public: enum fore_color { f_black = 0 , f_white = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, f_red = FOREGROUND_INTENSITY | FOREGROUND_RED , f_green = FOREGROUND_INTENSITY | FOREGROUND_GREEN , f_yellow = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN , f_blue = FOREGROUND_INTENSITY | FOREGROUND_BLUE, f_magenta= FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE, f_cyan = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE, };
enum back_color { b_black = 0 , b_white = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE, b_red = BACKGROUND_INTENSITY | BACKGROUND_RED , b_green = BACKGROUND_INTENSITY | BACKGROUND_GREEN , b_yellow = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN , b_blue = BACKGROUND_INTENSITY | BACKGROUND_BLUE, b_magenta= BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_BLUE, b_cyan = BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE, };
void Move (int x, int y); void Color(fore_color fg, back_color bg); void Cls(back_color bg=b_black); };
void Console::Cls(back_color bg) { COORD coordScreen = { 0, 0 }; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, bg); GetConsoleScreenBufferInfo(hConsole, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); GetConsoleScreenBufferInfo(hConsole, &csbi); FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); SetConsoleCursorPosition(hConsole, coordScreen); }
void Console::Move(int x, int y) { COORD point; point.X = x; point.Y = y; SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE),point); }
void Console::Color(fore_color fg, back_color bg) { SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), fg | bg); }
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) { Console c; c.Cls(Console::b_green); c.Color(Console::f_red , Console::b_blue); c.Move(4,2); cout << " Test "; c.Color(Console::f_blue, Console::b_yellow); c.Move(4,4); cout << " Test "; c.Move(4,6); system("PAUSE"); return 0; }
|
Mit
C++: |
system("TYPE Test.html");
|
kann ich das nicht machen, da er ja sonst noch den Rest drum drum zeigen würde, wie die Funktion die die Schrift an der stelle Rot macht.
Beispiel: Si sieht der Text aus der HTML normal aus.
C++: |
//Das Folgende Beispiel zeigt einen goto sprung. #include <iostream> #include <cstdlib> using namespace std;
int main() { cout << "Hallo" << endl; Ziel: // Hier springt das goto hin. cout << "Den Text wirst du immer sehen." << endl; system("PAUSE"); goto Ziel; //Von hier spring er zu Ziel: }
|
So sieht er aus wenn man ihn mit TYPE einließt [html] <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>a.htm</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="generator" content="SynEdit HTML exporter" /> <style type="text/css"> <!-- body { color: #000000; background-color: #FFFFFF; } .cpp1-assembler { color: #0000FF; } .cpp1-character { color: #000000; } .cpp1-comment { color: #B2B4BF; font-style: italic; } .cpp1-float { color: #800080; } .cpp1-hexadecimal { color: #800080; } .cpp1-identifier { color: #000000; } .cpp1-illegalchar { color: #000000; } .cpp1-number { color: #800080; } .cpp1-octal { color: #800080; } .cpp1-preprocessor { color: #008000; } .cpp1-reservedword { color: #000000; font-weight: bold; } .cpp1-space { background-color: #FFFFFF; color: #000000; } .cpp1-string { color: #FF0000; } .cpp1-symbol { color: #000000; } --> </style> </head> <body> <pre> <code><span style="font: 10pt Courier New;"><span class="cpp1-comment">//Das Folgende Beispiel zeigt einen goto sprung. </span><span class="cpp1-space"> </span><span class="cpp1-preprocessor">#include <iostream> #include <cstdlib> </span><span class="cpp1-reservedword">using</span><span class="cpp1-space"> </span><span class="cpp1-reservedword">namespace</span><span class="cpp1-space"> std;
</span><span class="cpp1-reservedword">int</span><span class="cpp1-space"> main() { cout << </span><span class="cpp1-string">"Hallo"</span><span class="cpp1-space"> << endl; Ziel: </span><span class="cpp1-comment">// Hier springt das goto hin. </span><span class="cpp1-space"> cout << </span><span class="cpp1-string">"Den Text wirst du immer sehen."</span><span class="cpp1-space"> << endl; system(</span><span class="cpp1-string">"PAUSE"</span><span class="cpp1-symbol"> </span><span class="cpp1-reservedword">goto</span><span class="cpp1-space"> Ziel; </span><span class="cpp1-comment">//Von hier spring er zu Ziel: </span><span class="cpp1-symbol">}
</span></span> </code></pre> </body> </html> [/html]
Danke Im vOraus. Gruß, Siegfried75.
PS: Ich wäre froh wenn ihr mir ein Beispiel geben könntet für Dev-C++ . |