def DropShadow(self, drop=True): """ Adds a shadow under the window. :param `drop`: whether to drop a shadow or not. :note: This method is available only on Windows and requires Mark Hammond's pywin32 package. """ if not _libimported: # No Mark Hammond's win32all extension return if wx.Platform != "__WXMSW__": # This works only on Windows XP return hwnd = self.GetHandle() # Create a rounded rectangle region size = self.GetSize() if drop: if hasattr(win32gui, "CreateRoundRectRgn"): rgn = win32gui.CreateRoundRectRgn(0, 0, size.x, size.y, 9, 9) win32gui.SetWindowRgn(hwnd, rgn, True) CS_DROPSHADOW = 0x00020000 # Load the user32 library if not hasattr(self, "_winlib"): self._winlib = win32api.LoadLibrary("user32") csstyle = win32api.GetWindowLong(hwnd, win32con.GCL_STYLE) if drop: if csstyle & CS_DROPSHADOW: return else: csstyle |= CS_DROPSHADOW #Nothing to be done else: csstyle &= ~CS_DROPSHADOW # Drop the shadow underneath the window GCL_STYLE = -26 cstyle = win32gui.GetClassLong(hwnd, GCL_STYLE) if drop: if cstyle & CS_DROPSHADOW == 0: win32api.SetClassLong(hwnd, GCL_STYLE, cstyle | CS_DROPSHADOW) else: win32api.SetClassLong(hwnd, GCL_STYLE, cstyle & ~CS_DROPSHADOW)
def DropShadow(w, drop=True): if wx.Platform != "__WXMSW__" or _importFail: return hwnd = w.GetHandle() size = w.GetSize() rgn = win32gui.CreateRoundRectRgn(0, 0, size.x + 1, size.y + 1, _rounded, _rounded) win32gui.SetWindowRgn(hwnd, rgn, True) CS_DROPSHADOW = 0x00020000 GCL_STYLE = -26 cstyle = win32gui.GetClassLong(hwnd, GCL_STYLE) if drop: if cstyle & CS_DROPSHADOW == 0: win32api.SetClassLong(hwnd, GCL_STYLE, cstyle | CS_DROPSHADOW) else: win32api.SetClassLong(hwnd, GCL_STYLE, cstyle & ~ CS_DROPSHADOW)
def __init__(self, **kwds): style = kwds.get('style', 'standard') flags = win_calculate_flags(style, kwds) #if style == 'fullscreen': # rect = WinUtils.win_screen_rect #else: rect = (0, 0, self._default_width, self._default_height) frame = ui.CreateFrame() frame.CreateWindow(None, "New Window", 0, rect) hwnd = frame.GetSafeHwnd() #api.SetClassLong(hwnd, wc.GCL_HBRBACKGROUND, win_bg_hbrush) api.SetClassLong(hwnd, wc.GCL_HBRBACKGROUND, 0) # print "Window: Setting style:" ### # win_deconstruct_style(flags) ### frame.ModifyStyle(-1, flags) # print "Window: Style is now:" ### # win_deconstruct_style(frame.GetStyle()) ### frame.ModifyStyleEx(win_no_ex_flags, win_ex_flags) if style == 'fullscreen': self._win_fullscreen = True frame.HookMessage(self._win_wm_initmenu, wc.WM_INITMENU) self._win = frame if style in win_no_menu_styles: self._win_has_menubar = False else: self._win_set_empty_menubar() kwds['closable'] = flags & wc.WS_CAPTION <> 0 GWindow.__init__(self, _win=frame, **kwds)
def __init__(self, *args, **kwargs): super(Window, self).__init__(*args, **kwargs) c = win32gui.LoadImage(None, os.path.abspath('cursor.ani'), win32con.IMAGE_CURSOR, 0, 0, win32con.LR_LOADFROMFILE) print(c) win32api.SetClassLong(int(self.winId()), win32con.GCL_HCURSOR, c)
def __init__(self, text="text", style='white', position='fly', parent=None): super(Danmaku, self).__init__(text, parent) self._text = text self._style = style self._position = position self.setWindowTitle("Danmaku") self.setStyleSheet("background:transparent; border:none;") self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.setWindowFlags(QtCore.Qt.ToolTip | QtCore.Qt.FramelessWindowHint) if sys.platform == "win32": # Win32 Dark Magic, disable window drop shadows win32api.SetClassLong(self.winId().__int__(), -26, 0x0008 & ~0x00020000) self.init_text(text, style) self._width = self.frameSize().width() self._height = self.frameSize().height() self.screenGeo = QtGui.QDesktopWidget().screenGeometry() with Danmaku._lock: if Danmaku.vertical_slots is None: Danmaku.vertical_slots = [0] * \ int((self.screenGeo.height() - 20) / self._height) self.quited = False self.position_inited = False self.init_position()