How to make the window redraw?

I have a full screen window using this code:

WindowStyle = System.Windows.WindowStyle.None; WindowState = System.Windows.WindowState.Maximized; Topmost = true; 

It works fine under Win7, but in WinXP some window elements do not redraw when the window goes into full-screen mode. Is there a way to make the window do a complete redraw and update the layout?

UPD everything redraws fine if I switch to another application using Atl-Tab and then back to mine

+4
source share
1 answer

You can force the window to redraw using the Windows API.

Class implementation example:

 public static class WindowsApi { private const int WmPaint = 0x000F; [DllImport("User32.dll")] public static extern Int64 SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); public static void ForcePaint(this Form form) { SendMessage(form.Handle, WmPaint, IntPtr.Zero, IntPtr.Zero); } } 

Using:

 Form testForm = new Form(); testForm.ForcePaint(); 
+3
source

Source: https://habr.com/ru/post/1347557/


All Articles