Exemplo n.º 1
0
  def OnInitDialog (self, hwnd, msg, wparam, lparam):
    ur"""Attempt to position the dialog box more or less in
    the middle of its parent (possibly the desktop). Then
    force a resize of the dialog controls which should take
    into account the different label lengths and the dialog's
    new size.
    """
    self.hwnd = hwnd

    #
    # If you want to have a translucent dialog,
    # enable the next block.
    #
    if False:
      wrapped (
        win32gui.SetWindowLong,
        self.hwnd,
        win32con.GWL_EXSTYLE,
        win32con.WS_EX_LAYERED | wrapped (
          win32gui.GetWindowLong,
          self.hwnd,
          win32con.GWL_EXSTYLE
        )
      )
      wrapped (
        win32gui.SetLayeredWindowAttributes,
        self.hwnd,
        255,
        (255 * 80) / 100,
        win32con.LWA_ALPHA
      )

    pythoncom.RegisterDragDrop (
      hwnd,
      pythoncom.WrapObject (
        _DropTarget (hwnd),
        pythoncom.IID_IDropTarget,
        pythoncom.IID_IDropTarget
      )
    )

    for i, (field, default, callback) in enumerate (self.fields):
      id = self.IDC_FIELD_BASE + i
      self._set_item (id, default)

    parent = self.parent_hwnd or DESKTOP
    l, t, r, b = self.corners (*wrapped (win32gui.GetWindowRect, self.hwnd))
    r = min (r, l + self.MAX_W)

    dt_l, dt_t, dt_r, dt_b = wrapped (win32gui.GetWindowRect, parent)

    cx = int (round ((dt_r - dt_l) / 2))
    cy = int (round ((dt_b - dt_t) / 2))
    centre_x, centre_y = wrapped (win32gui.ClientToScreen, parent, (cx, cy))
    dx = int (round (centre_x - (r / 2)))
    dy = int (round (centre_y - (b / 2)))
    wrapped (win32gui.MoveWindow, self.hwnd, dx, dy, r - l, b - t, 0)
    l, t, r, b = wrapped (win32gui.GetClientRect, self.hwnd)
    self._resize (r - l, b - t, 0)
    return True
Exemplo n.º 2
0
 def register(self):
     try:
         pythoncom.RegisterDragDrop(
             self.hwnd,
             pythoncom.WrapObject(self, pythoncom.IID_IDropTarget,
                                  pythoncom.IID_IDropTarget))
     except pywintypes.com_error:
         global text_list
         text_list = ["COM failure!"]