d3d11.Window

A window class.

Methods

class Window
Window(style=WS_OVERLAPPEDWINDOW, handle=0) → Window
Parameters:
  • style – Window style.
  • handle – A native HWND as an integer which will be used instead of creating a new window. Useful when using some third party windowing toolkits.

Creates a new window. The window is initially hidden so you have to show it later: window.show(SW_SHOW).

clipCursor(bool yes) → None

Clips (or frees) the cursor to the client area of the window. Use with care.

close() → None

Closes the window. Do not attempt to use the window after this. This is also called when the Window is garbage collected.

getHandle() → int

Returns the internal window handle (HWND) as an integer.

getMessages() → list

Returns all new messages and empties the message queue. A message is a 11-component named tuple. They are normal Windows messages and most MSDN-information applies to them. Some related constants are not in d3d11c (yet).

Message attributes:

  • code - Message code, for example WM_MOUSEMOVE.
  • wparam - Meaning depends from the code. See MSDN documentation. For example if code is WM_KEYDOWN this would be a virtual key code.
  • lparam - Meaning depends from the code. See MSDN documentation.
  • x - Mouse x-coordinate in client coordinates (ie. can be negative or outside the window).
  • y - Mouse y-coordiante in client coordinates.
  • wheel - Mouse wheel delta. 0 if not a mouse wheel message.
  • vk - Virtual key code, for example VK_SPACE. This has the same value as wparam but is easier to remember.
  • char - Unicode character if a WM_CHAR-message, otherwise None.
  • shift - True if any shift key was down when the message was received.
  • ctrl - True if any ctrl key was down when the message was received.
  • alt - True if any alt key was down when the message was received.
getMonitorRect() → x, y, width, height

Takes the monitor which is nearest to this window and returns it’s virtual screen area. In multi-monitor systems x and y can be negative.

getRect() → x, y, width, height

Returns the window area.

setCallback(callback) → callback

With this function it is possible to set a message “hook” function which receives messages before they are handled (when getMessages() is called). This is useful when message parameters contain pointers to some data which is only valid during the message handling. If the callback returns True message will be ignored and certain internal processing is not done. So don’t return True if you don’t know what you are doing! The returned value will be the old callback (if any) so that you can “chain” callbacks.

oldCallback = None

def messageCallback(msg):
    if msg.code == WM_KEYUP and msg.vk == VK_F1:
        showHelpOrSomething()
    elif oldCallback:
        return oldCallback(msg) #Call the old callback.

oldCallback = w.setCallback(messageCallback)
setCursor(cursor) → None
Parameters:
  • cursor – If this is a string it should be a path to a .cur or .ani file. If this is an integer it can be one of Cursors values.

Sets the cursor.

setIcon(path) → None
Parameters:
  • path – Path to a .ico file.

Sets the window’s class icon. All windows created by DirectPython will share this icon.

setRect(rect, client=False) → None
Parameters:
  • rect – New area (x, y, width, height) for the window.
  • client – If True the client area will match the given rect and the total size of the window will be slightly larger (borders etc.).

Updates window area.

setTitle(str title) → None

Updates window title.

show(int style) → None
Parameters:

Changes (hides, shows, maximises etc.) window state.

showCursor(bool yes) → None

Shows or hides the cursor. This applies only when the mouse cursor is inside the client area.

Table Of Contents

Get DirectPython 11 at SourceForge.net. Fast, secure and Free Open Source software downloads