Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Sheddex
unregistriert
C-/C++-Quelltext |
|
1 |
WriteAt(4, 4, L"Das ist ein Test"); |
Quellcode |
|
1 2 |
Ausgabe: Das ist ein Test |
C-/C++-Quelltext |
|
1 |
WriteAt(4, 4, L" "); |
Quellcode |
|
1 2 |
Ausgabe: Da t e t |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
bool WriteAt(unsigned short x, unsigned short y, wchar_t* String) { unsigned long Safety = 0; void* Handle = NULL; wchar_t TextBuffer[4096]; COORD Position; ZeroMemory(&TextBuffer, 4096 * sizeof(wchar_t)); ZeroMemory(&Position, sizeof(COORD)); Handle = GetStdHandle(STD_OUTPUT_HANDLE); if (String == NULL) return false; if (Handle == INVALID_HANDLE_VALUE || Handle == NULL) return false; Position.X = x; Position.Y = y; if (ReadConsoleOutputCharacterW(Handle, TextBuffer, static_cast<unsigned long>(wcslen(String)), Position, &Safety) == FALSE) { return false; } for (unsigned int i = 0; i < wcslen(String); i++) { if (String[i] == L'\n') { Position.X = x; Position.Y++; } else { if (Position.X > 79) { Position.X = x; Position.Y++; } if (String[i] != TextBuffer[i]) { if (FillConsoleOutputCharacterW(Handle, String[i], 1, Position, &Safety) == FALSE) return false; } Position.X++; } } return true; } |
C-/C++-Quelltext |
|
1 |
bool WriteAt(unsigned short x, unsigned short y, const wchar_t* String) |
Sheddex
unregistriert
Sheddex
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
bool WriteAt(unsigned short x, unsigned short y, const wchar_t* String) { unsigned long Safety = 0; unsigned int CurrentBuffer = 0; void* Handle = NULL; wchar_t TextBuffer[4000]; COORD Position; ZeroMemory(&TextBuffer, 4000 * sizeof(wchar_t)); ZeroMemory(&Position, sizeof(COORD)); Handle = GetStdHandle(STD_OUTPUT_HANDLE); if (String == NULL || Handle == INVALID_HANDLE_VALUE || Handle == NULL) return false; if (ReadConsoleOutputCharacterW(Handle, TextBuffer, 4000, Position, &Safety) == FALSE) return false; Position.X = x; Position.Y = y; CurrentBuffer = x + (y * 80); for (unsigned int i = 0; i < wcslen(String); i++) { if (String[i] == L'\n') { CurrentBuffer += (80 - Position.X) + x; Position.X = x; Position.Y++; } else { if (Position.X > 79) { Position.X = x; Position.Y++; } if (String[i] != TextBuffer[CurrentBuffer]) { if (FillConsoleOutputCharacterW(Handle, String[i], 1, Position, &Safety) == FALSE) return false; } Position.X++; CurrentBuffer++; } } return true; } |
Werbeanzeige