In Windows you have a setting to "Show window contents while dragging". When this is off you are instead resizing with an outline of the window.
My WPF application has many controls on it, so it is extremely slow to resize. Is there a way to make my application resize by showing only the window outline instead of always updating the contents?
I found this question regarding WinForms but unfortunately I'm not able to adapt it to WPF. I can hook onto the HwndSource
, but the message numbers may have changed in Windows 10, so the if
statement in that answer is never entered... or there may be other things at work.
Also, inside the if
it calls the WndProc
base after is has changed a system parameter, then resetting the system parameter when it has finished calling it. But calling that method is not an option in WPF as a Window
object does not have a way to forward the message.
public void OnViewLoaded() {
HwndSource source = HwndSource.FromHwnd(
new WindowInteropHelper(this).Handle);
source?.AddHook(WndProc);
}
private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam,
IntPtr lParam, ref bool handled) {
if (msg == WM_SYSCOMMAND && (wParam.ToInt32() & 0xfff0) == SC_SIZE) {
// This if is never entered
int isDragFullWindow;
GetSystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, out isDragFullWindow, 0);
if (isDragFullWindow != 0)
SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 0, 0, 0);
// How to call this?
base.WndProc(ref m);
if (isDragFullWindow != 0)
SetSystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 1, 0, 0);
}
}