Removing the Title bar of external application using c#

后端 未结 7 1182
眼角桃花
眼角桃花 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:13

    No need to inject anything, you can just modify the windows style bits as using the API, e.g. this works for Notepad, however YMMV depending on the app your playing with.

    //Get current style
    lCurStyle = GetWindowLong(hwnd, GWL_STYLE)
    
    //remove titlebar elements
    lCurStyle = lCurStyle And Not WS_CAPTION
    lCurStyle = lCurStyle And Not WS_SYSMENU
    lCurStyle = lCurStyle And Not WS_THICKFRAME
    lCurStyle = lCurStyle And Not WS_MINIMIZE
    lCurStyle = lCurStyle And Not WS_MAXIMIZEBOX
    
    //apply new style
    SetWindowLong hwnd, GWL_STYLE, lCurStyle
    
    //reapply a 3d border
    lCurStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
    
    SetWindowLong hwnd, GWL_EXSTYLE, lCurStyle Or WS_EX_DLGMODALFRAME
    
    //redraw
    SetWindowPos hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_FRAMECHANGED
    

提交回复
热议问题