Advertisement

Printing text. Yep. I need help printing text. doh.

Started by November 11, 2000 10:18 AM
0 comments, last by Telamon 24 years, 1 month ago
Does anyone have experience using this function? BOOL WriteConsoleOutputCharacter( HANDLE hConsoleOutput, // handle to screen buffer LPCTSTR lpCharacter, // characters DWORD nLength, // number of characters to write COORD dwWriteCoord, // first cell coordinates LPDWORD lpNumberOfCharsWritten // number of cells written ); It''s used for low level output in console applications. I''m trying to write an ASCII graphics game. The problem is, I don''t know how to get the handle of the screen buffer. I didn''t even know there was one and I don''t know why there needs to be one. Doesn''t a console app only have one screen buffer? If anyone uses this function, could you write a brief snippet showing how you would write a character to the screen using it? If not, I can probably figure it out given a method to get the buffer handle. Thanks, you guys are great

Shedletsky's Bits: A Blog | ROBLOX | Twitter
Time held me green and dying
Though I sang in my chains like the sea...

You can get the handle using GetStdHandle(STD_OUTPUT_HANDLE).

So, the code to print something might look a little like this:
  HANDLE  conOut;COORD   pos;DWORD   numWritten;char    string[32]; //Not 32 for any particular reason...conOut=GetStdHandle(STD_OUTPUT_HANDLE);pos.x=5;pos.y=5;strcpy(string, "Boo!");WriteConsoleOutputCharacter(conOut, string, strlen(string), pos, &numWritten);  


I haven''t actually tried that, but I think it should work. You could adapt it to printing one char at a time if you wished, of course.

This topic is closed to new replies.

Advertisement