如何在窗外画画? [英] How to draw outside a window?

查看:24
本文介绍了如何在窗外画画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看 Windows tooltips 类提示窗口,我看到它在提示窗口的实际矩形外面绘制了它的阴影.

Looking at a Windows tooltips class hint window, i see that it draws its drop-shadow outside the hint window's actual rectangle.

使用 SpyXX - 我可以获得工具提示的窗口矩形和类样式:

Using SpyXX - i can get the tooltip's window rect, and class styles:

Rectangle:     (440, 229)-(544, 249), 104x20
Restored Rect: (440, 229)-(544, 249), 104x20
Client Rect:   (0, 0)-(104, 20), 104x20

您会注意到您看到的阴影实际上在正在绘制的窗口之外.如何在外面我的窗户的同时在我的窗户周围画一个阴影?

You'll notice that the drop shadow you see is physically outside the window that's being drawn. How can i draw a shadow outside around my window, while being outside my window?

注意:阴影不是使用标准的 CS_DROPSHADOW 类样式绘制的. 我已经通过实验确认了这一点,并且还可以在 SpyXX 中查看窗口的类样式;它不使用 CS_DROPSHADOW:

Note: The shadow is not drawn using the standard CS_DROPSHADOW class style. i've confirmed this experimentally, and can also see the class style's for the window in SpyXX; it does not use CS_DROPSHADOW:

Windows Styles:     94000001

    WS_POPUP        80000000
    WS_VISIBLE      10000000
    WS_CLIPSIBLINGS  4000000
    TTS_ALWAYSTIP          1

Extended Styles:    00080088

    WS_EX_LAYERED      80000
    WS_EX_TOOLWIN         80
    WS_EX_TOPMOST          8

那么我怎样才能在我的窗外画画呢?

So how can i draw outside my window?

注意:尝试在桌面 DC 上绘图已过时.来自 Greg Schechter 的 重定向 GDI,DirectX 和 WPF 应用程序:

Note: Trying to draw on the desktop DC is out. From Greg Schechter's Redirecting GDI, DirectX, and WPF applications:

在屏幕上绘图和阅读-- 呜呜呜!

Drawing To and Reading From the Screen -- Baaaad!

最后,因为我们在重定向一个特别危险的话题练习是写到屏幕上,通过使用 GetDC(NULL)并写信,或试图做异或橡皮筋线等.有是写作的两大原因屏幕坏了:

Lastly, since we're on the redirection topic, one particularly dangerous practice is writing to the screen, either through the use of GetDC(NULL) and writing to that, or attempting to do XOR rubber-band lines, etc. There are two big reasons that writing to the screen is bad:

太贵了……写信给屏幕本身并不昂贵,但它几乎总是伴随着从屏幕上阅读,因为一个通常做读-修改-写写入时的 XOR 等操作屏幕.从视频中阅读内存表面非常昂贵,需要与 DWM 同步,并停止整个 GPU 管道,如以及 DWM 应用程序管道.
这是不可预测的......如果你以某种方式设法到达实际的主要并写信给它,不可能有可预测的时间长短写给主要的将保持在屏幕.因为 UCE 不知道关于它,它可能会在下一帧刷新,否则它可能会持续存在很长一段时间,取决于还有什么需要更新的屏幕.(我们真的不允许直接无论如何写给主要的,因为这就是原因......如果你尝试访问 DirectDraw 主,用于例如,DWM 将关闭,直到访问应用程序退出)

It's expensive... writing to the screen itself isn't expensive, but it is almost always accompanied by reading from the screen because one typically does read-modify-write operations like XOR when writing to the screen. Reading from the video memory surface is very expensive, requires synchronization with the DWM, and stalls the entire GPU pipe, as well as the DWM application pipe.
It's unpredictable... if you somehow manage to get to the actual primary and write to it, there can be no predictability as to how long what you wrote to the primary will remain on screen. Since the UCE doesn't know about it, it may get cleared in the next frame refresh, or it may persist for a very long time, depending on what else needs to be updated on the screen. (We really don't allow direct writing to the primary anyhow, for that very reason... if you try to access the DirectDraw primary, for instance, the DWM will turn off until the accessing application exits)

推荐答案

你不能以你描述的方式在你的窗外画画.

You can't draw outside your window in the manner you describe.

如果您右键单击桌面,然后转到属性/外观/效果并取消选中在菜单下显示阴影"……您将不再有阴影.

If you right click your desktop then go to properties/appearance/effects and uncheck 'Show shadows under menus' ... you will no longer have the shadow.

最重要的是,这是窗口管理器的产物,而不是您的程序.

Bottom line is that this is a product of the window manager not your program.

这篇关于如何在窗外画画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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