/// <summary> /// Gets the size in pixel of a window's border. /// </summary> /// <param name="window">The handle of the window.</param> /// <returns>Returns the border size in pixel.</returns> public static Rectangle GetWindowBorderSizes(IntPtr window) { Rectangle windowBorderSizes = new Rectangle(); WindowStyles styles = GetWindowLong(window, GetWindowLongIndex.GWL_STYLE); // Window has title-bar if (styles.HasFlag(WindowStyles.WS_CAPTION)) { windowBorderSizes.Top += GetSystemMetrics(SystemMetric.SM_CYCAPTION); } // Window has re-sizable borders if (styles.HasFlag(WindowStyles.WS_THICKFRAME)) { windowBorderSizes.Left += GetSystemMetrics(SystemMetric.SM_CXSIZEFRAME); windowBorderSizes.Right += GetSystemMetrics(SystemMetric.SM_CXSIZEFRAME); windowBorderSizes.Top += GetSystemMetrics(SystemMetric.SM_CYSIZEFRAME); windowBorderSizes.Bottom += GetSystemMetrics(SystemMetric.SM_CYSIZEFRAME); } else if (styles.HasFlag(WindowStyles.WS_BORDER) || styles.HasFlag(WindowStyles.WS_CAPTION)) { // Window has normal borders windowBorderSizes.Left += GetSystemMetrics(SystemMetric.SM_CXFIXEDFRAME); windowBorderSizes.Right += GetSystemMetrics(SystemMetric.SM_CXFIXEDFRAME); windowBorderSizes.Top += GetSystemMetrics(SystemMetric.SM_CYFIXEDFRAME); windowBorderSizes.Bottom += GetSystemMetrics(SystemMetric.SM_CYFIXEDFRAME); } return(windowBorderSizes); }
public bool IsVisible() { //return ((int)dwStyle & (int)WindowStyles.WS_VISIBLE) != 0; return(dwStyle.HasFlag(WindowStyles.WS_VISIBLE)); }