Removing the Title bar of external application using c#

后端 未结 7 1196
眼角桃花
眼角桃花 2020-12-10 12:42

My application starts up another external application.

I want to remove the title bar of this external application once it has started.

Is this feasible, and

7条回答
  •  误落风尘
    2020-12-10 13:05

    Python version of Alex's answer if someone else needs:

    import win32gui
    
    #  get a handle to the window
    windowHandle = win32gui.FindWindowEx(None, None, None, "Untitled - Notepad")
    
    GWL_STYLE = -16  #  see https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlonga
    
    #  get current window style
    currentStyle = win32gui.GetWindowLong(windowHandle, GWL_STYLE)
    
    #  remove titlebar elements
    currentStyle = currentStyle & ~(0x00C00000)  #  WS_CAPTION
    currentStyle = currentStyle & ~(0x00080000)  #  WS_SYSMENU
    currentStyle = currentStyle & ~(0x00040000)  #  WS_THICKFRAME
    currentStyle = currentStyle & ~(0x20000000)  #  WS_MINIMIZE
    currentStyle = currentStyle & ~(0x00010000)  #  WS_MAXIMIZEBOX
    
    #  apply new style
    win32gui.SetWindowLong(windowHandle, GWL_STYLE, currentStyle)
    

提交回复
热议问题