Api Question.
-
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...
-
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...
You should be able to call
CreateGraphics
on your top level form, then use theGetHdc
/ReleaseHdc
methods on theGraphics
object to retreive the HDC which you can use withGetPixel
. 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 -
You should be able to call
CreateGraphics
on your top level form, then use theGetHdc
/ReleaseHdc
methods on theGraphics
object to retreive the HDC which you can use withGetPixel
. 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 himThanks 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...