private void HandleDragDropMessage(Message m)
        {
            dynamic sb       = new StringBuilder(260);
            uint    numFiles = DragQueryFile(m.WParam, 0xffffffffu, sb, 0);
            dynamic list     = new List <string>();

            for (uint i = 0; i <= numFiles - 1; i++)
            {
                if (DragQueryFile(m.WParam, i, sb, Convert.ToUInt32(sb.Capacity) * 2) > 0)
                {
                    list.Add(sb.ToString());
                }
            }

            POINT p = default;

            DragQueryPoint(m.WParam, ref p);
            DragFinish(m.WParam);

            dynamic args = new ElevatedDragDropArgs();

            args.HWnd  = m.HWnd;
            args.Files = list;
            args.X     = p.X;
            args.Y     = p.Y;

            ElevatedDragDrop?.Invoke(this, args);
        }
Exemple #2
0
 //文件拖拽
 private void ElevatedDragDrop(object sender, ElevatedDragDropArgs e)
 {
     if (e.HWnd == grpPreview.Handle)
     {
         string filePath = e.Files[0];
         string fileName = Path.GetFileNameWithoutExtension(filePath);
         filePath = GetRealPath(filePath);
         if (filePath == null)
         {
             return;
         }
         FillInfo(filePath, fileName);
     }
 }