如何绘制到c ++中的屏幕? [英] How to draw to screen in c++?
问题描述
如何在屏幕上绘制东西?不是控制台窗口,而是整个屏幕,最好是控制台最小化。
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.
这里有一个例子:
假设我想要在屏幕中心的所有其他应用程序的顶部显示5 x 5像素的2个黄色方块,不可打印和不可见的打印屏幕。
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.
我忘了提到我在Windows XP上使用Visual Studio 2010。
I forgot to mention that I'm using Visual Studio 2010 on Windows XP.
推荐答案
在Windows中,您可以使用GetDC函数。
只是一个简单的例子:
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;
}
但是由于Windows Vista非常慢
but since Windows Vista it is very slow
这篇关于如何绘制到c ++中的屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!