Announcement

Collapse
No announcement yet.

Dumb question about Desktop pixels

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dumb question about Desktop pixels

    Among other things, one goal is to test the color of a particular pixel of the DESKTOP.

    I can see how to apply the GRAPHICS statements in GRAPHICS windows that I create in my program and it's cool stuff! However, I haven't been able to tell if there's a way to apply them to the DESKTOP. Is it possible?

    I've read everything in the Help about GRAPHICS, I've examined the Sample programs, I've searched the Forums, but I have not come close to figuring this one out.

    I'm currently trying to overlay the Desktop with my own graphics window, which will have transparent foreground and background pixels, and read the Desktop pixel color through that... I have no idea if that will work, but at least I'm trying!

    #2
    see getpixel in the Win32 Programmers Reference or MSDN.

    Comment


      #3
      Window style WS_EX_TRANSPARENT?

      (Don't know if that's allowed on a GRAPHIC WINDOW NEW but let me look at help...nah, doesn't look like you get a style... Maybe GRAPHIC CLEAR with color %NULL will be "transparent?")

      Then again, there's always CreateWindowEx...

      MCM
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


        #4
        ...still reading, testing, etc...

        ...while trying to get the suggestions to work, I'm trying to figure out whether or not the Desktop meets the criteria of being a "device context"... While it makes sense it would have a Bitmap and a Region, I have a hunch it might not have a Brush, Font, or Pen...

        OK, off to do more reading! ...A guy could lose a whole football game trying to read the MSDN!

        Comment


          #5
          John,
          if this what you're after?
          Paul.
          Code:
          #INCLUDE "win32api.inc"
          
          FUNCTION PBMAIN () AS LONG
          
          DO
              DeskTopDC&=GetDc(0)  'get the DC of the desktop
             
              FOR x& = 1 TO 100
                  FOR y& = 1 TO 100
                      PixelColour&= getpixel(DeskTopDC&,x&,y&)   'find the colour of the pixel at position x,y
                      setpixel(DeskTopDC&,100+x&,100+y&,PixelColour&) 'copy that pixel to somewhere else on the desktop
                  NEXT
                  
              NEXT
          
              ReleaseDC(0,DeskTopDC&)
          
              SLEEP 1000
          LOOP UNTIL INSTAT
          
                 
          WAITKEY$
          
          END FUNCTION

          Comment


            #6
            Indeed it is, and a lot more! Thank you!

            I was getting closer, but still had a long way to go. I had started out mistakenly giving getpixel a handle and not a device context handle. Further reading got me tinkering with GetDC, but I had gotten sidetracked into trying to see if GetObjectType was needed...

            I expected to see the copied area remain visible on the desktop, but it vanished after I cycled through open windows and closed them...

            I have SOOooooo much more to learn about this.

            Meanwhile, I'm good to go. This was a BIG help in my first venture into the world of GRAPHICS.

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎