在屏幕上绘制与GDI +(或GDI)类似检查 [英] Draw on screen with GDI+ (or GDI) similar to Inspect

查看:391
本文介绍了在屏幕上绘制与GDI +(或GDI)类似检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在屏幕上绘制(整个屏幕上,每个其他窗口的顶部)使用GDI +。结果
我已经通过NULL来的GetDC获得HDC到屏幕上,然后用这来创建一个图形对象,并使用的DrawRectangle绘制在屏幕上的矩形。结果
一切works..except ...的矩形的内部将不会更新

I'm trying to draw on the screen (the whole screen, on top of every other window) using GDI+.
I've passed NULL to GetDC to get a HDC to the screen, and then used that to create a Graphics object, and used DrawRectangle to draw rectangles on the screen.
Everything works..except...the inside of the rectangle won't update.

就像如果我画过来一个命令提示符,然后移动命令提示符下,矩形内保持黑色。
我希望看到矩形下的项目。

Like if I draw it over a command prompt, and move the command prompt, the inside of the rectangle remains black. I expect to see whats under the rectangle.

这里的code,它在做图纸。

Here's the code that's doing the drawing..

Pen BluePen(Color(255, 0, 255, 0), 2);
Graphics graphics(screenDC);
graphics.DrawRectangle(&BluePen, myRect);

pretty简单,所以是有什么我要做得到矩形的内部时,屏幕并更新吗?或者把它忠实地透明。

Pretty simple, so is there something I have to do to get the inside of the rectangle to update when the screen does? Or to get it truely transparent.

=================编辑=================

好吧,我已经放弃了这一点,并认为这是不可能的,直到......我意识到Windows自带的SDK做到这一点完全的检查工具。

Well I had given up on this, and assumed it wasn't possible, until...I realized the Inspect tool that comes with the Windows SDK does this perfectly.

我想重建类似于亮点长方形的东西,如果我选择一个窗口(如Firefox),然后将检查成为关注的焦点,我可以用一切被完全更新自由走动了。
甚至还有没有任何闪烁。

I would like to recreate something similar to the highlight rectangle, and if I select a window (such as Firefox) and then bring Inspect into focus I can move it around freely with everything being updated perfectly. There's not even any flickering.

所以...没有人知道如何检查管理做到这一点?

So...does anyone know how Inspect manages to do this?

还回答了在GDI而不是GDI +是很好...

Also answers in GDI instead of GDI+ are fine...

推荐答案

在窗口屏幕(和Windows ...)的表面(S)的...挥发,像沙箱。窗户的重叠和裸露表面的重画是通过适当事件管理层的一种错觉。

In windows the screen (and the windows ...) surface(s) are ... volatile, like sandboxes. The "overlapping" of windows and the re-painting of uncovered surfaces is an illusion made by proper event management.

一切都画一直保留,直到别的东西吸引了它。
揭露的表面使窗口重新presenting的表面接收WM_PAINT消息。它是由该窗口程序,通过重新书画样样到消息作出反应应该是下了。

Everything is drawn remain there until something else is drawn over it. "Uncovering" a surface makes the window representing that surface to receive a WM_PAINT message. It's up to that window procedure to react to that message by re-painting everything is supposed to be under it.

现在,除非你拦截莫名其妙地发送到桌面窗口WM_PAINT消息,你有大多没有机会知道桌面需要重新绘制,因此您的油漆code将不会被调用,也没有重绘会发生。或者更好它发生在刚桌面窗口更新code,这并不意识到你的油漆。

Now, unless you intercept somehow the WM_PAINT message that is sent to the desktop window, you have mostly no chance to know the desktop needs a repaint and hence your paint code will not be called and no repaint will happen. Or better it happens following just the desktop window updating code, that's not aware of your paint.

这篇关于在屏幕上绘制与GDI +(或GDI)类似检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆