/[cvs]/nfo/projects/mess/src/client/windows/context_menu.py
ViewVC logotype

Diff of /nfo/projects/mess/src/client/windows/context_menu.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by joko, Sat Jun 3 00:41:42 2006 UTC revision 1.3 by joko, Sat Jun 3 15:11:27 2006 UTC
# Line 29  class ShellExtension: Line 29  class ShellExtension:
29          self.dataobj = dataobj          self.dataobj = dataobj
30    
31      def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags):      def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags):
32            
33            # debug
34          print "QCM", hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags          print "QCM", hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags
35          # Query the items clicked on          
36            # query the items clicked on
37          format_etc = win32con.CF_HDROP, None, 1, -1, pythoncom.TYMED_HGLOBAL          format_etc = win32con.CF_HDROP, None, 1, -1, pythoncom.TYMED_HGLOBAL
38          sm = self.dataobj.GetData(format_etc)          sm = self.dataobj.GetData(format_etc)
39          num_files = shell.DragQueryFile(sm.data_handle, -1)          num_files = shell.DragQueryFile(sm.data_handle, -1)
40          if num_files>1:          
41              msg = "&Hello from Python (with %d files selected)" % num_files          #if num_files>1:
42          else:          #    msg = "&Hello from Python (with %d files selected)" % num_files
43              fname = shell.DragQueryFile(sm.data_handle, 0)          #else:
44              msg = "&Hello from Python (with '%s' selected)" % fname          #    fname = shell.DragQueryFile(sm.data_handle, 0)
45            #    msg = "&Hello from Python (with '%s' selected)" % fname
46            self.files_selected = []
47            for i in range(0, num_files):
48              fname = shell.DragQueryFile(sm.data_handle, i)
49              if fname == 0: continue
50              self.files_selected.append(fname)
51    
52            # build context menu(s)
53            msg = "A&rchiveMe"
54          idCmd = idCmdFirst          idCmd = idCmdFirst
55          items = []          items = []
56          if (uFlags & 0x000F) == shellcon.CMF_NORMAL: # Check == here, since CMF_NORMAL=0          if (uFlags & 0x000F) == shellcon.CMF_NORMAL: # Check == here, since CMF_NORMAL=0
# Line 49  class ShellExtension: Line 61  class ShellExtension:
61              items.append(msg + " - shortcut")              items.append(msg + " - shortcut")
62          elif uFlags & shellcon.CMF_EXPLORE:          elif uFlags & shellcon.CMF_EXPLORE:
63              print "CMF_EXPLORE..."              print "CMF_EXPLORE..."
64              items.append(msg + " - normal file, right-click in Explorer")              #items.append(msg + " - normal file, right-click in Explorer")
65                items.append(msg)
66          elif uFlags & CMF_DEFAULTONLY:          elif uFlags & CMF_DEFAULTONLY:
67              print "CMF_DEFAULTONLY...\r\n"              print "CMF_DEFAULTONLY...\r\n"
68                items.append("hello world - 1!")
69          else:          else:
70              print "** unknown flags", uFlags              print "** unknown flags", uFlags
71                items.append("hello world - 2!")
72          win32gui.InsertMenu(hMenu, indexMenu,          win32gui.InsertMenu(hMenu, indexMenu,
73                              win32con.MF_SEPARATOR|win32con.MF_BYPOSITION,                              win32con.MF_SEPARATOR|win32con.MF_BYPOSITION,
74                              0, None)                              0, None)
# Line 73  class ShellExtension: Line 88  class ShellExtension:
88    
89      def InvokeCommand(self, ci):      def InvokeCommand(self, ci):
90          mask, hwnd, verb, params, dir, nShow, hotkey, hicon = ci          mask, hwnd, verb, params, dir, nShow, hotkey, hicon = ci
91          win32gui.MessageBox(hwnd, "Hello", "Wow", win32con.MB_OK)          win32gui.MessageBox(hwnd, "\n".join(self.files_selected), "ArchiveMe", win32con.MB_OK)
92    
93      def GetCommandString(self, cmd, typ):      def GetCommandString(self, cmd, typ):
94          return "Hello from Python!!"          return "Hello from Python!!"
# Line 82  class ShellExtension: Line 97  class ShellExtension:
97  def DllRegisterServer():  def DllRegisterServer():
98      import _winreg      import _winreg
99            
       
       
100      # extended (via http://mail.python.org/pipermail/python-list/2003-December/198390.html)      # extended (via http://mail.python.org/pipermail/python-list/2003-December/198390.html)
101        
102      # for folders      # for folders
103      folder_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Folder\\shellex")      folder_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Folder\\shellex")
104      folder_subkey = _winreg.CreateKey(folder_key, "ContextMenuHandlers")      folder_subkey = _winreg.CreateKey(folder_key, "ContextMenuHandlers")

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed