Unable to move a window with no title bar. #9797
Unanswered
yvan-noume
asked this question in
Q&A
Replies: 1 comment 1 reply
-
you can do this easily, we can use TitleBar API (put a Grid on window):
and:
or you can use new Custom TitleBar API and set drag regions: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
And thank you in advance for you answers.
I created a window with no title bar and tried to implement a way to move the window myself. I want it to be draggable anywhere.
At first I tried to use the Win32 api call: SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam), but it seems to be broken in WinUI 3 because it doesn't work but in winforms and wfp it does work. Here is an exerpt that works in wpf:
Then I tried to move the window myself by using the position of the cursor. I did it successfully with the Win32 call: (GetCursorPos(out POINTL lpPoint)). It is relatively simple, I just had to take the new position of the cursor when the pointer moves and change the position of the window accordingly. It is not as smooth as the SendMessage(...) but it is good enough.
But I found out later that this approach doesn't work for touch screen since there is not mouse. So I tried multiple alternatives , all of them not yielding the same result as the position of the cursor. They are all very unstable. the most stable approach so far is using the GetCurrentPoint() from winUI 3 but it is not good enough. So please could you help me out?
I also saw that someone ask almost the same question here: microsoft/WindowsAppSDK#2962, but still the person uses the position of the cursor.
Beta Was this translation helpful? Give feedback.
All reactions