public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
private static void CreateWindow() { lock (GraphicsWindow._syncLock) { GraphicsWindow.Invoke(delegate { GraphicsWindow._window = new Window(); GraphicsWindow._windowCreated = true; GraphicsWindow._window.Title = "Small Basic Graphics Window"; if (GraphicsWindow._backgroundBrush == null) { GraphicsWindow._backgroundBrush = System.Windows.Media.Brushes.White; } GraphicsWindow._window.Background = GraphicsWindow._backgroundBrush; if (GraphicsWindow._fillBrush == null) { GraphicsWindow._fillBrush = System.Windows.Media.Brushes.CornflowerBlue; } if (GraphicsWindow._pen == null) { GraphicsWindow._pen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 2.0); } if (GraphicsWindow._fontFamily == null) { GraphicsWindow._fontFamily = new System.Windows.Media.FontFamily("Tahoma"); } GraphicsWindow._window.Height = 480.0; GraphicsWindow._window.Width = 640.0; if (!GraphicsWindow._isHidden) { GraphicsWindow._window.Show(); } GraphicsWindow._window.SourceInitialized += delegate(object param0, EventArgs param1) { IntPtr handle = ((HwndSource)PresentationSource.FromVisual(GraphicsWindow._window)).Handle; uint num = NativeHelper.GetWindowLong(handle, -16); num = ((num & 4294901759u) | 131072u); NativeHelper.SetWindowLong(handle, -16, num); RECT rECT = new RECT { Left = 0, Top = 0, Right = (int)GraphicsWindow._window.Width, Bottom = (int)GraphicsWindow._window.Height }; NativeHelper.AdjustWindowRect(ref rECT, num, false); GraphicsWindow._window.Width = (double)(rECT.Right - rECT.Left); GraphicsWindow._window.Height = (double)(rECT.Bottom - rECT.Top); NativeHelper.SetForegroundWindow(handle); }; GraphicsWindow.SetWindowContent(); GraphicsWindow.SignupForWindowEvents(); GraphicsWindow._window.UpdateLayout(); }); } }