0

I want to drag and drop pictures from windows into a winforms despite that I have coded required methods DragDrop an DragEnter AllowDrag is true. the same app functionalty works well in other computers.

here is the code: I can't understand why DragEnter is never fired !!

private void CtrlVignette_DragEnter(object sender, DragEventArgs e) `
{
    if ((((sender != CtrlVignette) &&
       (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)) ||
        ((sender == CtrlVignette) &&
         (e.Data.GetDataPresent("objet", false) == false))) &&
       (Selectedpatient != null))
            e.Effect = DragDropEffects.All;
}

private void CtrlVignette_DragDrop(object sender, DragEventArgs e)
{
    // the code of this method is too long and it works very well
 }

CtrlVignette.AllowDrop is true

TaW
  • 53,122
  • 8
  • 69
  • 111
wael mrabet
  • 109
  • 1
  • 9
  • please post the code, we cannot read minds. If you want us to tell you what is wrong with your code, then it is essential for us to see it :) – Mong Zhu Sep 25 '19 at 09:11
  • _I want to drag and drop pictures from windows_ Meaning what: From a file explorer/desktop etc or some other application?? The source application must allow dragging! [Example](https://stackoverflow.com/questions/68598/how-do-i-drag-and-drop-files-into-an-application) for file explorer. – TaW Sep 25 '19 at 10:06
  • 1
    thank you any way :) @Mong Zhu – wael mrabet Sep 25 '19 at 11:10
  • 1
    The standard it-doesn't-work scenario is trying to drag to a window of a process that runs elevated. Commonly happens when you run VS elevated. Another aspect of UAC [called UIPI](https://en.wikipedia.org/wiki/User_Interface_Privilege_Isolation). – Hans Passant Sep 25 '19 at 11:11
  • I want to do it from desktop to my application @Taw – wael mrabet Sep 25 '19 at 11:12
  • @Hans Passant sorry bro, but I didn't understand what to do what is the problem and what to do with it !! – wael mrabet Sep 25 '19 at 11:19
  • So? What is the problem? The link I gave you has worked for 100s of others.. – TaW Sep 25 '19 at 11:43
  • @Downvoters question is edited now you can take back your votes if you see problem is fixed. – Mohammad Reza Shahrestani Sep 25 '19 at 13:13
  • the porblem is the DragEnter event does not fire and I am a 100% sure of my code is right @TaW – wael mrabet Sep 25 '19 at 13:13
  • What does the debugger tell you: Is DragEnter never fired/entered of do just your conditions not work as expected? – TaW Sep 25 '19 at 13:17
  • DragEnter never entred even I put a stop point !! @TaW – wael mrabet Sep 27 '19 at 08:13
  • If AllowDrop is true then the DrawEnter event is not hooked up. – TaW Sep 27 '19 at 08:47
  • when I run VS as Admin the drag and drop function never works but when I run it simple user It works fine . So what to do if my app works only with admin mode !! @Hans Passant – wael mrabet Sep 30 '19 at 14:17
  • The wikipedia article I linked to tells you what to do, hard to guess why you don't know what to do. – Hans Passant Sep 30 '19 at 14:29
  • @Hans Passant the problem was comming from windows 10 that blocks this functionnality. I've got to disable LUA . so I soveld the issue by editing the register value from 1 to 0 . first step oper register editor , then go under the following path ( " Ordinateur\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System " ) . Finally modifie EnableLUA value from 1 to 0 and restart the computer. I thank you all. – wael mrabet Oct 01 '19 at 09:01

1 Answers1

1

Solution : disable LUA

step 1 : open RegisterEditor.

step 2 : go under the following directory :( Ordinateur\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System )

step 3: modifie EnableLUA value form 1 to 0

step 4: restart the computer

Finally I thank you all Guys @Hans Passant @Taw, @Mohamad Shahrestani and @Mong Zhu

wael mrabet
  • 109
  • 1
  • 9