Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Api Question.

Api Question.

Scheduled Pinned Locked Moved C#
questiongraphicsjsonhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jtmtv18
    wrote on last edited by
    #1

    Hi peoples. I have a quick question reguarding API usuage....im trying to create collision detection by grapping just the color of the pixel on the outer edge of my object. This works okay for me using the API call GetPixel the problem lies in that i have to get the pointer to the GetPixel call for this i have been using GetDesktopWindow() another api call that returns the Handle for the graphics on the entire desktop. Now this worked.. the problem is that its the hole desktop i.e everything drawn on it....if im trying to get the color in ONLY my program and someone opens a window above mine the GetPixel will grap the pixel from the open window not my program. What im looking for is a way for the API to only look at my program. Is there a easy / way to do this ? Jesse M The Code Project Is Your Friend...

    J 1 Reply Last reply
    0
    • J jtmtv18

      Hi peoples. I have a quick question reguarding API usuage....im trying to create collision detection by grapping just the color of the pixel on the outer edge of my object. This works okay for me using the API call GetPixel the problem lies in that i have to get the pointer to the GetPixel call for this i have been using GetDesktopWindow() another api call that returns the Handle for the graphics on the entire desktop. Now this worked.. the problem is that its the hole desktop i.e everything drawn on it....if im trying to get the color in ONLY my program and someone opens a window above mine the GetPixel will grap the pixel from the open window not my program. What im looking for is a way for the API to only look at my program. Is there a easy / way to do this ? Jesse M The Code Project Is Your Friend...

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      You should be able to call CreateGraphics on your top level form, then use the GetHdc/ReleaseHdc methods on the Graphics object to retreive the HDC which you can use with GetPixel. The only thing I'm unsure of is if the HDC returned is clipped around the child controls. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him

      J 1 Reply Last reply
      0
      • J James T Johnson

        You should be able to call CreateGraphics on your top level form, then use the GetHdc/ReleaseHdc methods on the Graphics object to retreive the HDC which you can use with GetPixel. The only thing I'm unsure of is if the HDC returned is clipped around the child controls. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him

        J Offline
        J Offline
        jtmtv18
        wrote on last edited by
        #3

        Thanks for your help james. It turns out that it is clipped around the controls. and i need it for only the controls. I tryed passing the Handle to just the control i want (Ctrl.CreateGraphics().GetHdc) but i get a out of memory exception. But when i call the api call with another api call in it (GetDesktopWindow()-returns pointer to desktop) it works fine. Any ideas ? Jesse M The Code Project Is Your Friend...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups