simulating Explorer Cut/Copy/Paste of files

This is a discussion on simulating Explorer Cut/Copy/Paste of files within the Windows Programming forums, part of the Platform Specific Boards category; Hello all, I am writing a program that simulates a shell window. I am trying to get it to do ...

  1. #1
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195

    simulating Explorer Cut/Copy/Paste of files

    Hello all,

    I am writing a program that simulates a shell window. I am trying to get it to do some simple copy and paste stuff form the clip board so that, in theory, you could select a bunch of files in explorer, use CTRL+C (or whatever) to copy them, and then paste them into the folder that my custom shell viewer points to.

    EDIT: I figured out how to grab the files form the clipboard. Is there a way to figure out if the user initiated a Cut or a Copy command?

    EDIT: Also, If this is not possible, would forcfully sending a PASTE command to explorer get around the problem of querying for Cut or Copy? How would one send a paste command to Explorer if the target window is not open??
    Last edited by Mastadex; 03-24-2008 at 09:46 AM.
    Founder and avid member of the Internationsl Typo Associateion

  2. #2
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195
    Here is some more Info:

    I am not writing a shell extension, rather a separate program that querys for the explorer context menu. I am able to get the shell folder of the directory I want ot query. I use an IShellFolder to represent the folder. When I use it to get the desktop, I have the option of getting the IShellFolder of C:\Documents And Settings\Mastadex\Desktop or the Virtual folder that represents the desktop.

    Both of these menus are completely different. One has a "New" submenu on it and the other doesn't. The second menu has a properties menu item that launches the display settings, the first one doesn't.

    Is there an easy way of merging the two menus so that I can get both "New" and the properties menu item that launches the Display Settings.

    Here is how I am getting at the menu as if I was trying to get :

    Code:
    HMENU getMenu(IShellFolder *sh)
    {
      LPCONTEXTMENU icm1 = NULL, contextMenu = NULL;
      HMENU menu = NULL;
    
      shellFolder->CreateViewObject(NULL, IID_IContextMenu,(void**) &icm1);
    
      if (icm1)
      {
        icm1->QueryInterface(IID_IContextMenu3, contextMenu);
        contextMenu->QueryContextMenu(menu, 0, 1, 10000, CMF_NORMAL | CMF_EXTENDEDVERBS | CMF_EXPLORE);
    
        return menu;
      }
      return NULL;
    }
    Basically, the above approach gives me a menu that has the "New" submenu in it. If I hange the CreateViewObject() function call into the bottom example, it will NOT give me the "New" submenu, rather everything else (Paste, Paste Shotcut, Properties that launch the display settings) that I would assume you would get as if right clicked on the desktop.

    Code:
    HMENU getMenu(IShellFolder *sh, LPITEMIDLIST *pidlArray, int numPidls)
    
    {
      LPCONTEXTMENU icm1 = NULL, contextMenu = NULL;
      HMENU menu = NULL;
    
      shellFolder->GetUIObjectOf(NULL, numItems, (LPCITEMIDLIST *) pidlArray, IID_IContextMenu, NULL,(void**) &icm1);
    
      if (icm1)
      {
        icm1->QueryInterface(IID_IContextMenu3, ppContextMenu);
        contextMenu->QueryContextMenu(menu, 0, 1, 10000, CMF_NORMAL | CMF_EXTENDEDVERBS | CMF_EXPLORE);
    
        return menu;
      }
      return NULL;
    }
    Is there a way to merge the two LPCONTEXTMENU structures so that I can get all the options form both menus in one menu. I tried manually moving each item in the HMENU structures into one HMENU, but the funcitonallity of the menu (when invoked) did not do anything.

    I am basing my menu off of this example:
    http://www.codeproject.com/KB/shell/...ntextmenu.aspx
    Founder and avid member of the Internationsl Typo Associateion

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error opening files in a different dir
    By Ozzie in forum C++ Programming
    Replies: 3
    Last Post: 10-09-2008, 06:55 AM
  2. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  3. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21