change color of a pixel

i would like to compile something that will change the color of the pixel at coodinates 505, 712 to red, and i want it to take precidence over all other graphic processes, but i dont know what libraries i need. or really where to start
Last edited on
Neither do we, because you have to provide more detail, like what OS are you using, what development suite (compiler), etc.
windows xp 32
microsoft visual studio 2008 express
In the root window (the desktop)?

Or in an application window (like your program? on a titlebar? someone else's program)?

Or in whatever happens to be at that pixel?
what i had in mind was changing it to red no matter what, but to perhaps give us more options i will tell you the purpose
in the game counterstrike1.6, the target cross hairs are in the wrong place, so i want to make another set of cross hairs. the game is played in full screen mode.
the game is not open source
i thought this would be simple to do, but maybe it is in fact very difficult
i am very committed to this project so if i have to do allot of research just point me in the right direction
maybe you dont have to modify the source of the CS, just make a program to create that point and make it always visible
how?
an easy way to achieve your goal would be to stick a very small piece of paper on your monitor where the crosshairs should be, yes its a low tech solution but it could save you hours and hours of frustration.
If you don't mind using windows.h, a solution is to create a very small window staying allways on top
Last edited on
Firstly, good game on counter-strike 1.6, excellent game. Secondly:
1
2
3
4
5
6
7
8
9
10
11
#include<windows.h>
int main()
{
HDC hdc=GetDC(NULL);
while(1)
{
SetPixel(hdc,712,505,255);
Sleep(1);
}
return 0;
}

works for me. (If it does not work for you I can get an executable working & E-mail it to you if you give me your E-mail).
I used Dev-Cpp 4.9.9.2 to compile this.
If you don't want to have a console window, this should be better:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <windows.h>

unsigned long color = RGB(255,0,0);
int x=505,
      y=712;

LRESULT WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
      if (Msg==WM_DESTROY) PostQuitMessage(0);
      return DefWindowProcA(hWnd,Msg,wParam,lParam);
}
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevious, char* Cmd, int Show)
{
      WNDCLASSA wcl = { CS_VREDRAW|CS_HREDRAW,(WNDPROC)WndProc,0,0,hInstance,0,0,CreateSolidBrush(color),0,"win"};
      RegisterClassA(&wcl);
      HWND wind = CreateWindowExA(WS_EX_TOPMOST,"win","Pixel",WS_POPUP|WS_VISIBLE|WS_SYSMENU,x,y,1,1,0,0,hInstance,0);
      MSG Msg;
      while (GetMessageA(&Msg,0,0,0))
      {
            TranslateMessage(&Msg);
            DispatchMessageA(&Msg);
      }
      return 0;
}
Last edited on
Topic archived. No new replies allowed.