7

How would I draw something on the screen ? not the console window but the entire screen, preferably with the console minimised.

Also, would it show up on a printscreen ? What I want to do is create something like a layer on top of the screen that only me and my aplication are aware of yet still be able to use aplications as usual.

Here's an example: Let's say I want 2 yellow squares 5 by 5 pixels in size appearing in the center of the screen on top of all the other applications, unclickable and invisible to a printscreen.

[Edit]

I forgot to mention that I'm using Visual Studio 2010 on Windows XP.

Kesarion
  • 2,808
  • 5
  • 31
  • 52

4 Answers4

9

in windows you can use the GetDC-function. just a minimalistic example:

#include <Windows.h>
#include <iostream>

void drawRect(){
    HDC screenDC = ::GetDC(0);
    ::Rectangle(screenDC, 200, 200, 300, 300);
::ReleaseDC(0, screenDC);
}
int main(void){
    char c;
    std::cin >> c;
    if (c == 'd') drawRect();
    std::cin >> c;
    return 0;
}

but since Windows Vista it is very slow

OlimilOops
  • 6,747
  • 6
  • 26
  • 36
4

C++ has no notion of a "screen" and especially none of "graphics". The functionality needed is provided by your operating system. On many systems you will need a "Window" and draw on it. To do this portably, a library like Qt might help. A Windows solution was given by Oops. Maybe you want to use some OpenGL library, or Windows' DirectDraw/Direct3D from DirectX, in case you want to do some 3D stuff with your graphics.

Ry-
  • 218,210
  • 55
  • 464
  • 476
johannes
  • 15,807
  • 3
  • 44
  • 57
2

Windows offers GDI/+, WPF, and DirectX (including Direct2D on Vista+).

Puppy
  • 144,682
  • 38
  • 256
  • 465
1

The (rather nice but not recently updated) graphics library anti-grain geometry has very simple bindings to display its demos on a variety of windowing systems, you could look at those for examples. But for anything much more involved you're probably talking about operating system specific libraries.

Pete Kirkham
  • 48,893
  • 5
  • 92
  • 171