Jigberto
Jigberto

Reputation: 1533

create drag and drop event c++

How to send drag and drop files to other program from my program in background with c++ WIN API. My program must do that programatically without user action, without visible effects, smooth in background. I'm not very familiar with drag and drop techniques, and so far I understood that I need to use OLE drag and drop operation.

Upvotes: 1

Views: 8074

Answers (1)

Ibrahim Magdy
Ibrahim Magdy

Reputation: 343

You may check this code link

http://blogs.msdn.com/b/oldnewthing/archive/2004/12/06/275659.aspx

Then to use this code you may use a COM ActiveX in visual studio as follows

// declare a single instance of the DropTarget class

CDropSource codrop;

BOOL CALLBACK 
DlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)
      { 
      case WM_INITDIALOG:
     // bind the drop target to the dialog
     codrop.SetHwnd(hwnd);
     RegisterDragDrop(hwnd, &codrop);
     return TRUE;
      case WM_COMMAND:
     if (LOWORD(wParam) == IDCANCEL)
        EndDialog(hwnd, IDCANCEL);
     return TRUE;
     case WM_LBUTTONDOWN:
       OnLButtonDown(hwnd, false,
               LOWORD(lParam), HIWORD(lParam), 0);
      break;
      case WM_DESTROY:
     // unbind the drop target from the dialog
     RevokeDragDrop(hwnd);
     return FALSE;
      }

   return FALSE;
}

// the standard WinMain for an Applet

int WINAPI 
WinMain(HINSTANCE hinstance, HINSTANCE, LPSTR, int)
{
   OleInitialize(0);
   DialogBox(hinstance, MAKEINTRESOURCE(IDD_DIALOG1), 0, DlgProc);
   OleUninitialize();
   return 0;
}

of course I didn't test the code it might need a lot of tweaking to work, but you get the idea

I guess you can use this shell API to implment wuty

http://msdn.microsoft.com/en-us/library/bb762151(v=vs.85).aspx

Upvotes: 2

Related Questions