The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: AeroASM on April 25, 2005, 01:55:57 PM

Title: Problem with "print screen" code
Post by: AeroASM on April 25, 2005, 01:55:57 PM

.code

invoke GetDesktopWindow
invoke GetDC,eax
invoke GetPixel,eax,500,600



WHy does this code not work? It returns -1 (=FFFFFFFF = white) for every pixel.
Title: Re: Problem with "print screen" code
Post by: Bieb on April 25, 2005, 04:39:44 PM
I think that you get the desktop DC with the parameter 0, not the return of GetDeskTopWindow (I'm not sure what that function does.)
Title: Re: Problem with "print screen" code
Post by: Tedd on April 25, 2005, 05:28:35 PM
-1 (0ffffffffh) is fail, not white :bdg
(000ffffffh would be white)

Anyway, the following appears to work for me (on Win2k anyway)

    invoke GetDC, 0
    mov hddc,eax

    invoke SetPixel, hddc,1,1,0ffh    ;set pixel to red



If you're planning on using GetPixel to grab the screen - good luck!!
- it's extremely slow
- windows on top of the desktop are not PART of the desktop, ie. you will get an image of the desktop without the windows on it