c - Getting character attributes -
using winapi attribute of character located in y line , x column of screen console. trying after call getconsolescreenbufferinfo(getstdhandle(std_output_handle), &nativedata); console cursor set specified location. won't work. return last used attribute change instead.
how obtain attributes used on characters on locations?
edit: code used test readconsoleoutput() : http://hastebin.com/atohetisin.pl throws garbage values.
i see several problems off top of head:
no error checking. must check return value readconsoleoutput , other functions, documented. if function fails, must call getlasterror() error code. if don't check errors, you're flying blind.
you don't allocate buffer receive data in. (granted, documentation confusingly implies allocates buffer you, that's wrong since there's no way return pointer it. also, sample code shows have allocate buffer yourself. i've added note.)
it looks if had intended read characters had written, writing (10,5) , reading (0,0).
you're passing
newpos, set (10,5),dwbuffercoordwhen call readconsoleoutput, specified buffer size of (2,1). doesn't make sense target coordinates outside buffer.
taking last 2 points think perhaps have dwbuffercoord , lpreadregion confused, though i'm not sure meant coordinates (200,50) do.
- you're interpreting
char_infointeger in finalprintfstatement. first element ofchar_infocharacter itself, not attribute. wantedchibuffer[0].attributesratherchibuffer[0]. (of course, moot @ moment, sincechibufferpoints random memory address.)
if want retrieve character, you'll first need work out whether console in unicode or ascii mode, , retrieve unicodechar or asciichar accordingly.
Comments
Post a Comment