Windows 7中的MARGINS结构在Python中的应用
我正在尝试在Python中实现一些有趣的Windows Aero效果。
DwmExtendFrameIntoClientArea这个函数可以用来把Aero玻璃效果扩展到窗口的客户区域。使用这个函数需要一个窗口的句柄和一个指向MARGINS结构的指针。我已经知道如何在Python中获取窗口的句柄了,但我不知道怎么创建一个margins结构。
这是我目前的进展:
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()
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))