Search code examples
c#winformshandleformborderstyle

Is there way to check whether a Form has a Form Border? (by handle)


I want to check whether a form has a Form Border by its handle. And, the handle is from the another Application.

How can I handle this? Please help me.. Thanks!


Solution

  • [DllImport("user32.dll")]
    extern static int GetWindowLong(IntPtr hWnd, int nIndex);
    
    const int GWL_STYLE = -16;
    const int WS_BORDER = 0x00800000;  // thin border
    const int WS_THICKFRAME = 0x00040000;  // sizing (thick) border
    
    public static bool NativeWindowHasBorder(IntPtr hWnd)
    {
         return (GetWindowLong(hWnd, GWL_STYLE) & (WS_BORDER | WS_THICKFRAME)) != 0;
    }