的位置结果不完美,所以你可能需要弄乱API参数,但沿着这些线(一个VB.NET端口this answer)可能会接近。
Dim p = Process.Start("notepad.exe")
p.WaitForInputIdle()
Dim styles As WindowStyles = GetWindowLong(p.MainWindowHandle, GWL_STYLE)
styles = styles And Not (WindowStyles.WS_CAPTION Or WindowStyles.WS_THICKFRAME Or WindowStyles.WS_MINIMIZE Or WindowStyles.WS_MAXIMIZE Or WindowStyles.WS_SYSMENU)
SetWindowLong(p.MainWindowHandle, GWL_STYLE, styles)
Dim stylesex As ExtendedWindowStyles = GetWindowLong(p.MainWindowHandle, GWL_EXSTYLE)
stylesex = stylesex And Not (ExtendedWindowStyles.WS_EX_DLGMODALFRAME Or ExtendedWindowStyles.WS_EX_CLIENTEDGE Or ExtendedWindowStyles.WS_EX_STATICEDGE)
SetWindowLong(p.MainWindowHandle, GWL_EXSTYLE, stylesex)
SetWindowPos(p.MainWindowHandle, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosFlags.SWP_FRAMECHANGED Or SetWindowPosFlags.SWP_NOMOVE Or SetWindowPosFlags.SWP_NOSIZE Or SetWindowPosFlags.SWP_NOZORDER Or SetWindowPosFlags.SWP_NOOWNERZORDER)
<DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Shared Function GetWindowLong(hWnd As IntPtr, nIndex As Int16) As Int32
End Function
<DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Shared Function SetWindowLong(hWnd As IntPtr, nIndex As Int16, dwNewLong As Int32) As Int32
End Function
<DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Shared Function SetWindowPos(hWnd As IntPtr, hWndInsertAfter As IntPtr, X As Int16, Y As Int16, cx As Int16, cy As Int16, uFlags As UInt16) As Boolean
End Function
Const GWL_STYLE As Int16 = -16
Const GWL_EXSTYLE As Int16 = -20
<Flags>
Enum WindowStyles
WS_CAPTION = &HC00000
WS_THICKFRAME = &H40000
WS_MINIMIZE = &H20000000
WS_MAXIMIZE = &H1000000
WS_SYSMENU = &H80000
End Enum
<Flags>
Enum ExtendedWindowStyles
WS_EX_DLGMODALFRAME = &h00000001
WS_EX_CLIENTEDGE = &h00000200
WS_EX_STATICEDGE = &h00020000
End Enum
<Flags>
Enum SetWindowPosFlags As UInt16
SWP_FRAMECHANGED = &h0020
SWP_NOMOVE = &h0002
SWP_NOSIZE = &h0001
SWP_NOZORDER = &h0004
SWP_NOOWNERZORDER = &h0200
End Enum
结果是我的电脑上有点时髦(蓝色是我的桌面颜色),因为菜单仍然显示,一切都已经转移到采取了由边界所占用的空间,而不是扩大到拿增加额外的空间。也许不同的参数会解决这个问题
你将无法直接与.NET,你将需要使用Windows动态链接库,看看他们是否允许你改变窗口风格的应用程序不是专为做到这一点。最糟糕的情况下,你可以创建一个无边框的文本框来创建你自己的无边界记事本 – Mederic
嘿,谢谢你的信息。我不能只导入Windows DLL文件,并使用它来操纵给定窗口的边框,在这种情况下,记事本?因为那是我遇到的麻烦。 – EliasWick
我不知道,如果这甚至可能你需要做研究抱歉。 – Mederic