Beispiel #1
0
        private static IntPtr Callback(int code, IntPtr wParam, ref MSG lParam)
        {
            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));
        }
Beispiel #2
0
        private IntPtr Callback(int code, IntPtr wParam, ref MSG lParam)
        {
            if (lParam.message != WM.NCMBUTTONDOWN && lParam.message != WM.MOUSEHWHEEL && lParam.message != WM.MOUSEWHEEL && lParam.message != WM.INPUT && lParam.message != WM.MOUSEFIRST && lParam.message != WM.NCMOUSEMOVE && lParam.message != WM.NCMOUSELEAVE)
            {
                UnityEngine.Debug.LogWarning("Callback outSide: " + code + ":" + wParam + ":" + lParam.message);
            }

            if (code == 0 && lParam.message == WM.DROPFILES)
            {
                UnityEngine.Debug.Log("Callback inSide: " + code + ":" + wParam);

                POINT pos;
                WinAPI.DragQueryPoint(lParam.wParam, out pos);

                UnityEngine.Debug.Log("Callback inSide: " + pos.ToString());
                // 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));
        }
Beispiel #3
0
        private static IntPtr Callback(int code, IntPtr wParam, ref MSG lParam)
        {
            if (lParam.message == WM.CREATE)
            {
            }

            if (code == 0 && lParam.message == WM.DROPFILES)
            {
                Debug.Log(123);
                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);
                }
            }

            //   Debug.Log(lParam.message);

            //if (lParam.message == WM.DRAWCLIPBOARD)
            //{
            //     Debug.Log(123);

            //        WinAPI.SendMessage(nextClipboardViewer, (int)lParam.message, lParam.wParam, lParam.lParam);

            //}
            //if (lParam.message == WM.WM_CHANGECBCHAIN)
            //{
            //         Debug.Log(123);

            //            if (lParam.wParam == nextClipboardViewer)
            //        nextClipboardViewer = lParam.lParam;
            //    else
            //        WinAPI.SendMessage(nextClipboardViewer, (int)lParam.message, lParam.wParam, lParam.lParam);
            //}



            return(WinAPI.CallNextHookEx(m_Hook, code, wParam, ref lParam));
        }