Python win32gui.DestroyWindow() Examples

The following are 21 code examples of win32gui.DestroyWindow(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module win32gui , or try the search function .
Example #1
Source File: win32gui_taskbar.py    From ironpython2 with Apache License 2.0 9 votes vote down vote up
def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam==win32con.WM_LBUTTONUP:
            print "You clicked me."
        elif lparam==win32con.WM_LBUTTONDBLCLK:
            print "You double-clicked me - goodbye"
            win32gui.DestroyWindow(self.hwnd)
        elif lparam==win32con.WM_RBUTTONUP:
            print "You right clicked me."
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1023, "Display Dialog")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1024, "Say Hello")
            win32gui.AppendMenu( menu, win32con.MF_STRING, 1025, "Exit program" )
            pos = win32gui.GetCursorPos()
            # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
            win32gui.SetForegroundWindow(self.hwnd)
            win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0], pos[1], 0, self.hwnd, None)
            win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
        return 1 
Example #2
Source File: win32gui_demo.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def TestSetWorldTransform():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_1'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_1
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindow(wc.lpszClassName,
        'Spin the Lobster!',
        win32con.WS_CAPTION|win32con.WS_VISIBLE,
        100,100,900,900, 0, 0, 0, None)
    for x in xrange(500):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.01)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(wc.lpszClassName, None) 
Example #3
Source File: win32gui_demo.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def TestGradientFill():
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_win32gui_2'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc=wndproc_2
    class_atom=win32gui.RegisterClass(wc)       
    hwnd = win32gui.CreateWindowEx(0, class_atom,'Kaleidoscope',
        win32con.WS_CAPTION|win32con.WS_VISIBLE|win32con.WS_THICKFRAME|win32con.WS_SYSMENU,
        100,100,900,900, 0, 0, 0, None)
    s=win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE)
    win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, s|win32con.WS_EX_LAYERED)
    win32gui.SetLayeredWindowAttributes(hwnd, 0, 175, win32con.LWA_ALPHA)
    for x in xrange(30):
        win32gui.InvalidateRect(hwnd,None,True)
        win32gui.PumpWaitingMessages()
        time.sleep(0.3)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(class_atom,None) 
Example #4
Source File: __init__.py    From pyrexecd with MIT License 5 votes vote down vote up
def _close(klass, hwnd, msg, wparam, lparam):
        win32gui.DestroyWindow(hwnd)
        return 
Example #5
Source File: shell_view.py    From Email_My_PC with MIT License 5 votes vote down vote up
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print "Destroyed scintilla window" 
Example #6
Source File: shell_view.py    From Email_My_PC with MIT License 5 votes vote down vote up
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print "Destroyed view window"

    # Message handlers. 
Example #7
Source File: winapi.py    From gui-o-matic with GNU Lesser General Public License v3.0 5 votes vote down vote up
def destroy( self ):
        self.set_systray( None, None )
        win32gui.DestroyWindow( self.window_handle )
        win32gui.UnregisterClass( self.window_class_name, self.module_handle )
        self.window_handle = None 
Example #8
Source File: winapi.py    From gui-o-matic with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __del__( self ):
            if hasattr( self, 'handle' ):
                win32gui.DestroyWindow( self.handle ) 
Example #9
Source File: taskbar_widget.py    From termite-visualizations with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def Destroy(self):
        win32gui.DestroyWindow(self.hwnd) 
Example #10
Source File: gui_win.py    From ComicStreamer with Apache License 2.0 5 votes vote down vote up
def execute_menu_option(self, id):
        menu_action = self.menu_actions_by_id[id]      
        if menu_action == self.QUIT:
            win32gui.DestroyWindow(self.hwnd)
        else:
            menu_action(self) 
Example #11
Source File: shell.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def _terminate(self):
        win32gui.DestroyWindow(self.main_frame.hwnd) 
Example #12
Source File: shell.py    From eavatar-me with Apache License 2.0 5 votes vote down vote up
def execute_menu_option(self, id):
        if id == _ID_QUIT:
            win32gui.DestroyWindow(self.main_frame.hwnd)
        elif id == _ID_OPEN_FOLDER:
            self.open_folder()
        elif id == _ID_OPEN_WEBFRONT:
            self.open_ui()
        elif id == _ID_OPEN_CONSOLE:
            self._show_console()
        elif (_ID_NOTICE <= id < (_ID_NOTICE + base.NUM_OF_NOTICES)):
            self._show_notice(id)
        elif (_ID_STATUS_AVAILABLE <= id <= _ID_STATUS_DND):
            self._update_user_status(id) 
Example #13
Source File: systray.py    From OpenBazaar-Installer with MIT License 5 votes vote down vote up
def execute_menu_option(self, id):
        menu_action = self.menu_actions_by_id[id]
        if menu_action == self.QUIT:
            win32gui.DestroyWindow(self.hwnd)
        else:
            menu_action(self) 
Example #14
Source File: shell_view.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print "Destroyed view window"

    # Message handlers. 
Example #15
Source File: tray.py    From MouseTracks with GNU General Public License v3.0 5 votes vote down vote up
def quit(cls):
    """Quit the program."""
    win32gui.DestroyWindow(cls.hwnd)


#Example usage 
Example #16
Source File: SysTrayIcon.py    From LIFX-Control-Panel with MIT License 5 votes vote down vote up
def execute_menu_option(self, id):
        menu_action = self.menu_actions_by_id[id]
        if menu_action == self.QUIT:
            win32gui.DestroyWindow(self.hwnd)
        else:
            menu_action(self) 
Example #17
Source File: desktopmanager.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def desktop_name_dlgproc(hwnd,msg,wparam,lparam):
    """ Handles messages from the desktop name dialog box """
    if msg in (win32con.WM_CLOSE,win32con.WM_DESTROY):
        win32gui.DestroyWindow(hwnd)
    elif msg == win32con.WM_COMMAND:
        if wparam == win32con.IDOK:
            desktop_name=win32gui.GetDlgItemText(hwnd, 72)
            print 'new desktop name: ',desktop_name
            win32gui.DestroyWindow(hwnd)
            create_desktop(desktop_name)
            
        elif wparam == win32con.IDCANCEL:
            win32gui.DestroyWindow(hwnd) 
Example #18
Source File: win32gui_dialog.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def OnClose(self, hwnd, msg, wparam, lparam):
        win32gui.DestroyWindow(hwnd)

    # We need to arrange to a WM_QUIT message to be sent to our
    # PumpMessages() loop. 
Example #19
Source File: shell_view.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DestroyViewWindow(self):
        win32gui.DestroyWindow(self.hwnd)
        self.hwnd = None
        print "Destroyed scintilla window" 
Example #20
Source File: utils.py    From QuLab with MIT License 4 votes vote down vote up
def _WindowsShutdownBlocker(title='Python script'):
    """
    Block Windows shutdown when you do something important.
    """
    from ctypes import CFUNCTYPE, c_bool, c_uint, c_void_p, c_wchar_p, windll
    import win32con
    import win32gui

    def WndProc(hWnd, message, wParam, lParam):
        if message == win32con.WM_QUERYENDSESSION:
            return False
        else:
            return win32gui.DefWindowProc(hWnd, message, wParam, lParam)

    CALLBACK = CFUNCTYPE(c_bool, c_void_p, c_uint, c_void_p, c_void_p)

    wc = win32gui.WNDCLASS()
    wc.style = win32con.CS_GLOBALCLASS | win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.lpfnWndProc = CALLBACK(WndProc)
    wc.hbrBackground = win32con.COLOR_WINDOW + 1
    wc.lpszClassName = "block_shutdown_class"
    win32gui.RegisterClass(wc)

    hwnd = win32gui.CreateWindow(wc.lpszClassName, title,
                                 win32con.WS_OVERLAPPEDWINDOW, 50,
                                 50, 100, 100, 0, 0,
                                 win32gui.GetForegroundWindow(), None)

    win32gui.ShowWindow(hwnd, win32con.SW_HIDE)

    windll.user32.ShutdownBlockReasonCreate.argtypes = [c_void_p, c_wchar_p]
    windll.user32.ShutdownBlockReasonCreate.restype = c_bool
    windll.user32.ShutdownBlockReasonCreate(
        hwnd, "Important work in processing, don't shutdown :-(")

    yield

    windll.user32.ShutdownBlockReasonDestroy.argtypes = [c_void_p]
    windll.user32.ShutdownBlockReasonDestroy.restype = c_bool
    windll.user32.ShutdownBlockReasonDestroy(hwnd)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(wc.lpszClassName, None) 
Example #21
Source File: win32gui_devicenotify.py    From ironpython2 with Apache License 2.0 4 votes vote down vote up
def TestDeviceNotifications(dir_names):
    wc = win32gui.WNDCLASS()
    wc.lpszClassName = 'test_devicenotify'
    wc.style =  win32con.CS_GLOBALCLASS|win32con.CS_VREDRAW | win32con.CS_HREDRAW
    wc.hbrBackground = win32con.COLOR_WINDOW+1
    wc.lpfnWndProc={win32con.WM_DEVICECHANGE:OnDeviceChange}
    class_atom=win32gui.RegisterClass(wc)
    hwnd = win32gui.CreateWindow(wc.lpszClassName,
        'Testing some devices',
        # no need for it to be visible.
        win32con.WS_CAPTION,
        100,100,900,900, 0, 0, 0, None)

    hdevs = []
    # Watch for all USB device notifications
    filter = win32gui_struct.PackDEV_BROADCAST_DEVICEINTERFACE(
                                        GUID_DEVINTERFACE_USB_DEVICE)
    hdev = win32gui.RegisterDeviceNotification(hwnd, filter,
                                               win32con.DEVICE_NOTIFY_WINDOW_HANDLE)
    hdevs.append(hdev)
    # and create handles for all specified directories
    for d in dir_names:
        hdir = win32file.CreateFile(d, 
                                    winnt.FILE_LIST_DIRECTORY, 
                                    winnt.FILE_SHARE_READ | winnt.FILE_SHARE_WRITE | winnt.FILE_SHARE_DELETE,
                                    None, # security attributes
                                    win32con.OPEN_EXISTING,
                                    win32con.FILE_FLAG_BACKUP_SEMANTICS | # required privileges: SE_BACKUP_NAME and SE_RESTORE_NAME.
                                    win32con.FILE_FLAG_OVERLAPPED,
                                    None)

        filter = win32gui_struct.PackDEV_BROADCAST_HANDLE(hdir)
        hdev = win32gui.RegisterDeviceNotification(hwnd, filter,
                                          win32con.DEVICE_NOTIFY_WINDOW_HANDLE)
        hdevs.append(hdev)

    # now start a message pump and wait for messages to be delivered.
    print "Watching", len(hdevs), "handles - press Ctrl+C to terminate, or"
    print "add and remove some USB devices..."
    if not dir_names:
        print "(Note you can also pass paths to watch on the command-line - eg,"
        print "pass the root of an inserted USB stick to see events specific to"
        print "that volume)"
    while 1:
        win32gui.PumpWaitingMessages()
        time.sleep(0.01)
    win32gui.DestroyWindow(hwnd)
    win32gui.UnregisterClass(wc.lpszClassName, None)