HDC TargethDC;
HWND TargetHwnd;
DWORD ColorR;
TargetHwnd = GetForegroundWindow();
TargethDC = GetWindowDC(TargetHwnd);
ColorR = GetPixel(TargethDC,gMouse.x,gMouse.y);
ReleaseDC(TargetHwnd,TargethDC);
r = GetRValue(ColorR);
g = GetGValue(ColorR);
b = GetBValue(ColorR);
gMouse is my custom mouse coordinates that return the mouse coordinate inside my application starting from 0,0 top left inside all windows borders.
I need it to not return any colors of the windows border, you know the top window bar and edges around.
As I said its an artificial mouse, and it returns the coordinate from the top left of my window (not including window outline).
... also, this method doesnt work when its in full screen, what should I use rather than GetForegroundWindow to work for full screen?
[Edited by - RogerThat123 on October 10, 2009 8:59:54 PM]
GetPixel Color
If full screen you could just get the pixel from your backbuffer/frontbuffer
Are you using directx?
Are you using directx?
When you do GetWindowDC() you're getting a device context of the entire window. If you used GetDC() instead you'd get a device context for the client area of the window (i.e. the area without the caption bar and borders)
In terms of the GetForegroundWindow() problem, you can use WindowFromPoint(), given you convert your mouse coordinates to screen coordinates. You'd be the only one that would know how to do this conversion. But if you're using 0,0 as top left and you're using pixel units you can probably use ClientToScreen() to do the conversion.
Again, as mentioned before, if you're using DirectX then there are probably better ways to be doing this.
Again, as mentioned before, if you're using DirectX then there are probably better ways to be doing this.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement