How to draw on the screen in C ++?

How would I draw something on the screen? not a console window, but the entire screen, preferably from a console minimized.

Also, will it be displayed on screen for printing? What I want to do is to create something like a layer on top of the screen that only me and my application know, but can still use applications, as usual.

Here's an example: Let's say I want 2 yellow squares measuring 5 by 5 pixels in the center of the screen on top of all other applications that are invisible and invisible to print. A.

[change]

I forgot to mention that I am using Visual Studio 2010 in Windows XP.

+6
c ++ screen draw invisible
source share
4 answers

in windows you can use the GetDC function. just a minimalist 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 with Windows Vista it is very slow

+6
source share

C ++ has no concept of a “screen” and especially a “graph”. The necessary functionality is provided by your operating system. On many systems, you will need a “Window” and draw it. To make this portable, a library like Qt can help. Windows solution was provided by Oops. Maybe you want to use some DirectX OpenGL or DirectDraw Direct3D library if you want to make some 3D materials with your graphics.

+4
source share

(quite nice, but not updated) the anti-grain geometry graphic library has very simple bindings for displaying its demonstrations on various window systems, you can look at them with examples. But for something much more active, you are probably talking about specific operating system libraries.

+2
source share

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

+2
source share

All Articles