Click here to Skip to main content
15,894,907 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Is learning win32 only learning functions in dll? Pin
Waldermort26-Aug-06 22:14
Waldermort26-Aug-06 22:14 
GeneralRe: Is learning win32 only learning functions in dll? Pin
Andy Moore27-Aug-06 10:08
Andy Moore27-Aug-06 10:08 
GeneralRe: Is learning win32 only learning functions in dll? Pin
Christian Graus27-Aug-06 12:05
protectorChristian Graus27-Aug-06 12:05 
QuestionCreating Vista Style Menus and controls on XP and Windows 2000 Pin
wildbird198126-Aug-06 13:39
wildbird198126-Aug-06 13:39 
AnswerRe: Creating Vista Style Menus and controls on XP and Windows 2000 Pin
Hamid_RT3-Sep-06 9:04
Hamid_RT3-Sep-06 9:04 
QuestionWIN32 Console application colour ? Pin
James Laing26-Aug-06 12:14
James Laing26-Aug-06 12:14 
AnswerRe: WIN32 Console application colour ? Pin
Waldermort26-Aug-06 12:30
Waldermort26-Aug-06 12:30 
GeneralRe: WIN32 Console application colour ? Pin
James Laing26-Aug-06 12:35
James Laing26-Aug-06 12:35 
GeneralRe: WIN32 Console application colour ? Pin
James Brown27-Aug-06 4:26
James Brown27-Aug-06 4:26 
GeneralRe: WIN32 Console application colour ? Pin
James Laing28-Aug-06 1:44
James Laing28-Aug-06 1:44 
GeneralRe: WIN32 Console application colour ? Pin
James Brown28-Aug-06 2:35
James Brown28-Aug-06 2:35 
GeneralRe: WIN32 Console application colour ? Pin
James Laing28-Aug-06 3:54
James Laing28-Aug-06 3:54 
GeneralRe: WIN32 Console application colour ? Pin
James Brown28-Aug-06 4:13
James Brown28-Aug-06 4:13 
GeneralRe: WIN32 Console application colour ? Pin
James Laing28-Aug-06 9:50
James Laing28-Aug-06 9:50 
GeneralRe: WIN32 Console application colour ? Pin
James Brown28-Aug-06 10:39
James Brown28-Aug-06 10:39 
James,
I really do believe the FillConsoleOutputAttribute will solve your problem - and do shouldn't need to know how many characters/bytes have been written. I had assumed you just wanted to fill the entire console buffer with the same colour? You can use FillConsoleOutputAttribute to colour all cell-positions within the console, not just those characters already written (think about how the 'CLS' command might work). So the number of characters to fill = width_of_console * height_of_console. Filling the entire console does not alter the 'cursor position' it just sets the cell-colours.

GetConsoleScreenBufferInfo API will return you information regarding the size of the output-window (in the CONSOLE_SCREEN_BUFFER_INFO::dwSize field). So your number of characters. This is untested code:

HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;

GetConsoleScreenBufferInfo(hConsole, &csbi);

COORD top = { 0, 0 };
DWORD written;
WORD attr = << colour value here >>
FillConsoleOutputAttribute(hConsole, attr, csbi.dwSize.x * csbi.dwSize.y, top,
&written);

Documentation for FillConsoleOutputAttribute states: "If the number of character cells whose attributes are to be set extends beyond the end of the specified row in the screen buffer, the cells are written up to the end of the screen buffer". So you could in fact omit the GetConsoleScreenBufferInfo and just specify a "big" number for the number-of-characters. (i.e. 2^31).

Hope this was of some help, and sorry that we got off on the wrong foot.

regards,
James



GeneralRe: WIN32 Console application colour ? Pin
James Laing28-Aug-06 11:41
James Laing28-Aug-06 11:41 
GeneralRe: WIN32 Console application colour ? Pin
Laing,James28-Aug-06 11:59
Laing,James28-Aug-06 11:59 
QuestionI hate Unicode!! Pin
Waldermort26-Aug-06 10:24
Waldermort26-Aug-06 10:24 
AnswerRe: I hate Unicode!! Pin
Michael Dunn26-Aug-06 21:27
sitebuilderMichael Dunn26-Aug-06 21:27 
GeneralRe: I hate Unicode!! [modified] Pin
Waldermort26-Aug-06 22:08
Waldermort26-Aug-06 22:08 
GeneralRe: I hate Unicode!! [modified] Pin
fefe.wyx26-Aug-06 22:24
fefe.wyx26-Aug-06 22:24 
GeneralRe: I hate Unicode!! Pin
Waldermort26-Aug-06 22:48
Waldermort26-Aug-06 22:48 
GeneralRe: I hate Unicode!! Pin
fefe.wyx26-Aug-06 23:33
fefe.wyx26-Aug-06 23:33 
GeneralRe: I hate Unicode!! Pin
Waldermort27-Aug-06 0:27
Waldermort27-Aug-06 0:27 
QuestionRegistry Unicode Problem Pin
lucki_luke26-Aug-06 9:55
lucki_luke26-Aug-06 9:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.