[pywin32-checkins] pywin32/com/win32comext/shell/demos/servers shell_view.py, 1.9, 1.10
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-01-07 22:56:36
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10280 Modified Files: shell_view.py Log Message: * Fix IID handling so we can catch requests for unsupported IIDs. * Failed attempt to make ShellExecuteEx with Folders work as expected. Index: shell_view.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/shell_view.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** shell_view.py 30 Oct 2007 09:56:42 -0000 1.9 --- shell_view.py 7 Jan 2008 22:56:38 -0000 1.10 *************** *** 62,65 **** --- 62,67 ---- # version will spew output to win32traceutil. debug=0 + if debug: + import win32traceutil # markh is toying with an implementation that allows auto reload of a module *************** *** 270,275 **** def CreateViewObject(self, hwnd, iid): ! return wrap(ScintillaShellView(hwnd, self.path), useDispatcher=debug>0) ! # A ShellFolder for our Python objects class ShellFolderObject(ShellFolderBase): --- 272,276 ---- def CreateViewObject(self, hwnd, iid): ! return wrap(ScintillaShellView(hwnd, self.path), iid, useDispatcher=debug>0) # A ShellFolder for our Python objects class ShellFolderObject(ShellFolderBase): *************** *** 288,293 **** else: lineno = object.methods[self.method_name] ! return wrap(ScintillaShellView(hwnd, self.path, lineno), ! useDispatcher=debug>0) def EnumObjects(self, hwndOwner, flags): assert self.method_name is None, "Should not be enuming methods!" --- 289,295 ---- else: lineno = object.methods[self.method_name] ! return wrap(ScintillaShellView(hwnd, self.path, lineno), ! iid, useDispatcher=debug>0) ! def EnumObjects(self, hwndOwner, flags): assert self.method_name is None, "Should not be enuming methods!" *************** *** 337,341 **** self.pidl = pidl def CreateViewObject(self, hwnd, iid): ! return wrap(FileSystemView(self, hwnd), useDispatcher=debug>0) def EnumObjects(self, hwndOwner, flags): --- 339,343 ---- self.pidl = pidl def CreateViewObject(self, hwnd, iid): ! return wrap(FileSystemView(self, hwnd), iid, useDispatcher=debug>0) def EnumObjects(self, hwndOwner, flags): *************** *** 377,386 **** # IShellView def CreateViewWindow(self, prev, settings, browser, rect): ! print "CreateViewWindow", prev, settings, browser, rect self.cur_foldersettings = settings self.browser = browser self._CreateMainWindow(prev, settings, browser, rect) self._CreateChildWindow(prev) - return self.hwnd def _CreateMainWindow(self, prev, settings, browser, rect): --- 379,387 ---- # IShellView def CreateViewWindow(self, prev, settings, browser, rect): ! print "FileSystemView.CreateViewWindow", prev, settings, browser, rect self.cur_foldersettings = settings self.browser = browser self._CreateMainWindow(prev, settings, browser, rect) self._CreateChildWindow(prev) def _CreateMainWindow(self, prev, settings, browser, rect): *************** *** 527,531 **** # Enumerate and store the child PIDLs for cid in self.folder.EnumObjects(self.hwnd, 0): - print "Have CID" self.children.append(cid) --- 528,531 ---- *************** *** 584,588 **** def OnNotify(self, hwnd, msg, wparam, lparam): hwndFrom, idFrom, code = win32gui_struct.UnpackWMNOTIFY(lparam) ! print "OnNotify code=0x%x (0x%x, 0x%x)" % (code, wparam, lparam) if code == commctrl.NM_SETFOCUS: # Control got focus - Explorer may not know - tell it --- 584,588 ---- def OnNotify(self, hwnd, msg, wparam, lparam): hwndFrom, idFrom, code = win32gui_struct.UnpackWMNOTIFY(lparam) ! #print "OnNotify code=0x%x (0x%x, 0x%x)" % (code, wparam, lparam) if code == commctrl.NM_SETFOCUS: # Control got focus - Explorer may not know - tell it *************** *** 613,621 **** sel.append(self.children[n][-1:]) print "Selection is", sel - # Get the IContextMenu for the items. - inout, cm = self.folder.GetUIObjectOf(self.hwnd_parent, sel, - shell.IID_IContextMenu, 0) hmenu = win32gui.CreateMenu() try: # As per 'Q179911', we need to determine if the default operation # should be 'open' or 'explore' --- 613,622 ---- sel.append(self.children[n][-1:]) print "Selection is", sel hmenu = win32gui.CreateMenu() try: + # Get the IContextMenu for the items. + inout, cm = self.folder.GetUIObjectOf(self.hwnd_parent, sel, + shell.IID_IContextMenu, 0) + # As per 'Q179911', we need to determine if the default operation # should be 'open' or 'explore' *************** *** 626,638 **** except pythoncom.com_error: pass ! id_cmd_first = 1 # TrackPopupMenu makes it hard to use 0 ! cm.QueryContextMenu(hmenu, 0, id_cmd_first, -1, flags) ! # Find the default item in the returned menu. ! cmd = win32gui.GetMenuDefaultItem(hmenu, False, 0) ! if cmd == -1: ! print "Oops: _doDefaultActionFor found no default menu" else: ! ci = 0, self.hwnd_parent, cmd-id_cmd_first, None, None, 0, 0, 0 ! cm.InvokeCommand(ci) finally: win32gui.DestroyMenu(hmenu) --- 627,659 ---- except pythoncom.com_error: pass ! # *sob* - delegating to the shell does work - but lands us ! # in the original location. Q179911 also shows that ! # ShellExecuteEx should work - but I can't make it work as ! # described (XP: function call succeeds, but another thread ! # shows a dialog with text of E_INVALID_PARAM, and new ! # Explorer window opens with desktop view. Vista: function ! # call succeeds, but no window created at all. ! # On Vista, I'd love to get an IExplorerBrowser interface ! # from the shell, but a QI fails, and although the ! # IShellBrowser does appear to support IServiceProvider, I ! # still can't get it ! if 0: ! id_cmd_first = 1 # TrackPopupMenu makes it hard to use 0 ! cm.QueryContextMenu(hmenu, 0, id_cmd_first, -1, flags) ! # Find the default item in the returned menu. ! cmd = win32gui.GetMenuDefaultItem(hmenu, False, 0) ! if cmd == -1: ! print "Oops: _doDefaultActionFor found no default menu" ! else: ! ci = 0, self.hwnd_parent, cmd-id_cmd_first, None, None, 0, 0, 0 ! cm.InvokeCommand(ci) else: ! rv = shell.ShellExecuteEx( ! hwnd = self.hwnd_parent, ! nShow=win32con.SW_NORMAL, ! lpClass="folder", ! lpVerb="explore", ! lpIDList=sel[0]) ! print "ShellExecuteEx returned", rv finally: win32gui.DestroyMenu(hmenu) *************** *** 684,690 **** def OnSize(self, hwnd, msg, wparam, lparam): - # hrm - this doesn't seem to be called on XP, but is on Vista - # (and is *necessary* on Vista, as it seems to create windows with - # a zero client-rect, then moves it) #print "OnSize", self.hwnd_child, win32api.LOWORD(lparam), win32api.HIWORD(lparam) if self.hwnd_child is not None: --- 705,708 ---- *************** *** 707,717 **** def _SendSci(self, msg, wparam=0, lparam=0): return win32gui.SendMessage(self.hwnd, msg, wparam, lparam) - - def GetWindow(self): - return self.hwnd - # IShellView def CreateViewWindow(self, prev, settings, browser, rect): ! print "CreateViewWindow", prev, settings, browser, rect # Make sure scintilla.dll is loaded. If not, find it on sys.path # (which it generally is for Pythonwin) --- 725,731 ---- def _SendSci(self, msg, wparam=0, lparam=0): return win32gui.SendMessage(self.hwnd, msg, wparam, lparam) # IShellView def CreateViewWindow(self, prev, settings, browser, rect): ! print "ScintillaShellView.CreateViewWindow", prev, settings, browser, rect # Make sure scintilla.dll is loaded. If not, find it on sys.path # (which it generally is for Pythonwin) *************** *** 739,748 **** win32con.WM_SIZE: self.OnSize, } ! win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map) file_data = file(self.filename, "U").read() self._SetupLexer() ! self._SendSci(scintillacon.SCI_SETTEXT, 0, file_data) if self.lineno != None: self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno) --- 753,762 ---- win32con.WM_SIZE: self.OnSize, } ! # win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map) file_data = file(self.filename, "U").read() self._SetupLexer() ! self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data) if self.lineno != None: self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno) *************** *** 782,785 **** --- 796,806 ---- self._SendSci(scintillacon.SCI_STYLESETEOLFILLED, stylenum, 1) # Only needed for unclosed strings. + # IOleWindow + def GetWindow(self): + return self.hwnd + + def UIActivate(self, activate_state): + print "OnActivate" + def DestroyViewWindow(self): win32gui.DestroyWindow(self.hwnd) *************** *** 790,796 **** return winerror.S_FALSE - def UIActivate(self, activate_state): - print "Scintilla OnActivate" - def OnSize(self, hwnd, msg, wparam, lparam): x = win32api.LOWORD(lparam) --- 811,814 ---- |