windows - masm assembly how to use getpixel to build a color picker -


i build color picker. have tried code

invoke getdc,null mov esi,eax invoke getpixel,esi,400,400 invoke lstrcpy,string ,eax invoke setdlgitemtext,hwin,textbox1,string invoke releasedc,null,esi 

but returns p»© , things that. how return things 00f0f0f0h

you not trying format string number, need pass correct flags , specifier wsprintf. *printf format whatever pass it, , convert string according format specifier , put string address passed lpout.

the %s specifier formatting strings. lets wanted display return value of getpixel 8 digit hex number 0x in front of number.

.data szfmt       db  "%#08x", 0  .data? buf         db  12 dup (?)  .code     invoke  getdc, null     invoke  getpixel, eax, 200, 200      invoke  wsprintf, offset buf, offset szfmt, eax     invoke  messagebox, null, offset buf, null, mb_ok 

instead of calling messagebox, can do:

invoke  setdlgitemtext, hwin, textbox1, offset buf 

try , see messagebox displays

http://msdn.microsoft.com/en-us/library/windows/desktop/ms647550(v=vs.85).aspx


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -