[PyQt] Using Windows DwmApi

Knacktus knacktus at googlemail.com
Thu Nov 3 07:22:56 GMT 2011


Hi guys,

I want use the DwmApi on Windows 7. Mainly the 
DwmExtendFrameIntoClientArea method.

The API doc is here:

http://msdn.microsoft.com/library/ms748975.aspx

and a Qt Example here:

http://nicug.blogspot.com/2011/03/qt-windows-7-extend-frame-into-client.html

I'm trying to use the Python ctypes module to call the native method.

The Code is here:

#######################################################
import sys
from ctypes import *

from PyQt4 import QtGui
from PyQt4 import QtCore

# struct needed as input for DwmExtendFrameIntoClientArea
class Margins(Structure):
     _fields_ = [("cxLeftWidth", c_int),
                 ("cxRightWidth", c_int),
                 ("cyTopHeight", c_int),
                 ("cyBottomHeight", c_int)]

margins = Margins(-1, -1, -1, -1)

app = QtGui.QApplication(sys.argv)
w = QtGui.QWidget()

w_handle = w.winId()

# The question is how to create proper args
proper_w_handle_arg = byref(c_int(w_handle))
proper_margins_arg = byref(margins)

# From an Internet research I assume windll for stdcall convention
# but not sure, really
windll.DwmApi.DwmExtendFrameIntoClientArea(proper_w_handle_arg, 
proper_margins_arg)

w.show()
app.exec_()
########################################################

1) I'm not 100 % sure about the calling convention (windll vs. cdll)
2) It seems I don't get the arguments right.

How do I do it properly?

Cheers,

Jan


More information about the PyQt mailing list