Autor Beitrag
ebber
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: So 25.01.09 19:11 
Hallo,

ich habe ein Programm in das ich vom Windows Explorer Dateien reinziehen möchte. Das funktioniert auch. So:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
        private void SeFiWin_Drop(object sender, DragEventArgs e)
        {
            if (e.Data is DataObject && ((DataObject)e.Data).ContainsFileDropList())
            {
                foreach (string filePath in ((DataObject)e.Data).GetFileDropList())
                {
                        WindowAdd winAdd = new WindowAdd(this, filePath);
                        winAdd.ShowDialog();
                }
            } 
        }


Aber solange wie das läuft hängt der Explorer. Also so wie ich das sehe liegt das am ShowDialog. Aber wie kann ich das umgehen?

MfG
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 25.01.09 19:57 
Du müsstest die Dateiliste dort nur auslesen und die Dialoge erst nach dem Ende von SeFiWin_Drop anzeigen.

Wie man dies am besten mit C# löst kann ich dir leider nicht sagen.
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: So 25.01.09 20:05 
Das sollte mit BeginInvoke möglich sein: Schickt eine Windows-Message los, die erst nach Beenden des Drag-Vorgangs verarbeitet wird und den Delegate aufruft.

_________________
>λ=
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: So 25.01.09 20:34 
Danke. Das hat funktioniert.


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
        delegate void InsertDropsInvoke(DataObject da);
        private void SeFiWin_Drop(object sender, DragEventArgs e)
        {
            if (e.Data is DataObject && ((DataObject)e.Data).ContainsFileDropList())
            {
                this.Dispatcher.BeginInvoke(new InsertDropsInvoke(InsertDrops), ((DataObject)e.Data));
            }

            e.Handled = true;
        }

        private void InsertDrops(DataObject da)
        {
            foreach (string filePath in da.GetFileDropList())
            {
                    WindowAdd winAdd = new WindowAdd(this, filePath );
                    winAdd.ShowDialog();
            }
        }