I have been searching for hours and haven't found anything useful because all other issues are too localized, so here is my version of this (common) problem:
I have a WPF window with WindowStyle=None and ResizeMode=NoResize (otherwise I would get resize borders which I do not want) and most important AllowsTransparency= False and I must stick to this setup.
Changing the ResizeMode to CanResize and having a custom resize grip with the following MouseDown handler
[DllImport("User32.dll")]
public static extern bool ReleaseCapture();
[DllImport("User32.dll")]
public static extern IntPtr SendMessage(
IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);
private void OnResizeGripMouseDown(object sender, MouseButtonEventArgs e) {
ReleaseCapture();
SendMessage(Window.Handle, WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, 0);
}
allows me to resize the window perfectly, however there is the resize border left. Is there any way to force the resizability of the window although it has ResizeMode=NoResize?
(Maybe via SetWindowLong
and GWL_EXSTYLE
? If there is the the need for messages, I already have a WindowProc
setup to handle this.)
I was able to force the desired behaviour by using another message
SendMessage(Handle, WM_SYSCOMMAND, SC_SIZE + direction, 0);
where WM_SYSCOMMAND is the default Windows message, SC_SIZE is the wParam defined by 0xF000 and the direction is the numerical value of the hit test handle defined by this enum
public enum SysCommandSize : int {
SC_SIZE_HTLEFT = 1,
SC_SIZE_HTRIGHT = 2,
SC_SIZE_HTTOP = 3,
SC_SIZE_HTTOPLEFT = 4,
SC_SIZE_HTTOPRIGHT = 5,
SC_SIZE_HTBOTTOM = 6,
SC_SIZE_HTBOTTOMLEFT = 7,
SC_SIZE_HTBOTTOMRIGHT = 8
}