private static void FindWindowSize(ref int cxWindow, ref int cyWindow) { TextMetrics tm; using (DeviceContext dcScreen = Gdi.CreateInformationContext("DISPLAY", null)) { dcScreen.GetTextMetrics(out tm); } cxWindow = 2 * Windows.GetSystemMetrics(SystemMetric.BorderWidth) + 12 * tm.AverageCharWidth; cyWindow = 2 * Windows.GetSystemMetrics(SystemMetric.BorderHeight) + Windows.GetSystemMetrics(SystemMetric.CaptionAreaHeight) + 2 * tm.Height; }