1

我试图让一些更有趣的 Windows Aero 效果在 Python 中工作。

DwmExtendFrameIntoClientArea函数可用于将 Aero 玻璃扩展到客户区域它需要一个窗口句柄和一个指向MARGINS结构的指针。我已经知道如何在 Python 中获取窗口句柄;但是,我不知道如何制作边距结构。

MARGINS 结构,MSDN Docs

这是我到目前为止所拥有的:

import Tkinter as tk
import string
import ctypes

root = tk.Tk()

handle = string.atoi(root.wm_frame(), 0)

dwm = ctypes.windll.dwmapi

# needs pointertomarginsstruct
dwm.DwmExtendFrameIntoClientArea(handel, pointertomarginsstruct)

root.mainloop()
4

1 回答 1

4

我没有运行 Win7 来测试它,但尝试使用 ctypes 定义结构:

class MARGINS(ctypes.Structure):
  _fields_ = [("cxLeftWidth", c_int),
              ("cxRightWidth", c_int),
              ("cyTopHeight", c_int),
              ("cyBottomHeight", c_int)
             ]
margins = MARGINS(1, 2, 1, 1)

dwm.DwmExtendFrameIntoClientArea(handel, ctypes.byref(margins))
于 2011-08-27T17:02:00.080 回答