예제 #1
0
        private static IntPtr Callback(int code, IntPtr wParam, ref MSG lParam)
        {
            OnAnyEvent?.Invoke(lParam.message);
            if (code == 0 && lParam.message == WM.DROPFILES)
            {
                POINT pos;
                WinAPI.DragQueryPoint(lParam.wParam, out pos);

                // 0xFFFFFFFF as index makes the method return the number of files
                uint n  = WinAPI.DragQueryFile(lParam.wParam, 0xFFFFFFFF, null, 0);
                var  sb = new System.Text.StringBuilder(1024);

                List <string> result = new List <string>();
                for (uint i = 0; i < n; i++)
                {
                    int len = (int)WinAPI.DragQueryFile(lParam.wParam, i, sb, 1024);
                    result.Add(sb.ToString(0, len));
                    sb.Length = 0;
                }
                WinAPI.DragFinish(lParam.wParam);
                if (OnDroppedFiles != null)
                {
                    OnDroppedFiles(result, pos);
                }
            }
            return(WinAPI.CallNextHookEx(m_Hook, code, wParam, ref lParam));
        }
예제 #2
0
 public void InvokeEvent(string msg, object args = null)
 {
     OnAnyEvent?.Invoke(msg, args);
 }