![]() |
| | #1 |
| Registered User Join Date: Jun 2010
Posts: 182
| writing to the console I'm trying to write to the console with WriteConsoleOutput, but I get some errors during compilation. The code I've written so far: Code: //--------------------------------------------------------------------------------------------------
//Display a 80cols x 25 rows fixed size console
//--------------------------------------------------------------------------------------------------
void DisplayCon(char target[]){
COORD bufferSize = {80, 25};
COORD TopLeft = {0,0};
SMALL_RECT Out_buf;
Out_buf.Left = 0;
Out_buf.Top = 0;
Out_buf.Right = 24;
Out_buf.Bottom = 79;
WriteConsoleOutput(wHnd, target, bufferSize, TopLeft, Out_buf);
return;
}
Code: Type error in argument 2 to 'function'; expected 'const CHAR_INFO *' but found 'char *'. Type error in argument 5 to 'function'; expected 'PSMALL_RECT' but found 'SMALL_RECT'. What am I missing? The array I'm using to store the data to be displayed: target[] should be a CHAR_INFO structure. If I want to use the same area using union, the same that I'm using for array target[], how should I define the structure? CHAR_INFO has already a union inside: Code: typedef struct _CHAR_INFO { // chi
union { /* Unicode or ANSI character */
WCHAR UnicodeChar;
CHAR AsciiChar;
} Char;
WORD Attributes; // text and background colors
} CHAR_INFO, *PCHAR_INFO;
have the same area of 8000 bytes usable in both array mode and struct mode. Thanks for any help you can give me. Last edited by frktons; 07-30-2010 at 06:33 AM. |
| frktons is offline | |
| | #2 |
| and the hat of Destiny Join Date: Aug 2001 Location: The edge of the known universe
Posts: 22,695
| Start with Code: CHAR_INFO array[10]; // pick your size Code: array[0].Char.AsciiChar = mystring[0]; // and the rest of them array[0].Attributes = 0; // RTM for RED, FLASH, whatever... Code: WriteConsoleOutput(wHnd, array, bufferSize, TopLeft, &Out_buf); |
| Salem is offline | |
| | #3 |
| Registered User Join Date: Jun 2010
Posts: 182
| Thanks salem. This is a different solution, but it can be feasible. I have the Code: AsciiChar Attributes Code: first character: source[0] contains the AsciiChar source[1] contains the Attributes second character: source[2] contains the AsciiChar source[3] contains the Attributes and so on. Code: array[0].Char.AsciiChar = source[0]; array[0].Attributes =source[1]; and so on contain both a space [ASCII 32]. So I need to put some value also in the remaining 2 bytes of the structure. How do I access them? Last edited by frktons; 07-30-2010 at 10:49 AM. |
| frktons is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with console program | feso4 | C++ Programming | 3 | 10-22-2006 11:53 AM |
| Eeks! locating a the cursor in a console app is a real _bear(). | Pete_2000 | C Programming | 12 | 05-06-2006 03:34 PM |
| Windows console problems | tigs | Windows Programming | 2 | 03-14-2003 11:20 AM |
| Linux console window questions | GaPe | Linux Programming | 1 | 12-28-2002 12:18 PM |
| Sprites In Console | c++_n00b | A Brief History of Cprogramming.com | 4 | 04-13-2002 07:02 AM |