Hi,
I managed to make a little borderless launcher with a custom title bar and a drag&drop function using user32.dll.
I’m dragging the window using :
// Window drag&drop messages
[DllImport("User32.dll")] public static extern bool ReleaseCapture(); // Used for window drag&drop
delegate void SendMessageDelegate(IntPtr hWnd, uint uMsg, UIntPtr dwData, IntPtr lResult);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern bool SendMessageCallback(IntPtr hWnd, int Msg, int wParam, int lParam, SendMessageDelegate lpCallBack, int dwData);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")] static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll", SetLastError = true)] static extern IntPtr SetFocus(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "FindWindow")] public static extern System.IntPtr FindWindow(string className, string windowName);
// Drag Start
window = GetActiveWindow();
ReleaseCapture();
SendMessageCallback(window, WM_SYSCOMMAND, MOUSE_MOVE, 0, WindowDropCallback, 0);
It works well, except that I have to click twice after the drop, because of the loss of focus.
So i added this in the WindowDropCallback :
SetForegroundWindow(window);
SetFocus(window);
And it works exactly how I want, but ONLY in the editor !
When I build, the focus is still lost on drop and I still have to click twice.
Do you have an idea ?
Thanks for reading ![]()