在没有边框的情况下打开记事本的最简单,最快捷的方法是什么。 我想要的是删除您在下图中看到的蓝色标记:
我到目前为止的代码[打开记事本]:
Private Sub Button_StartQuiz_Click(sender As Object, e As EventArgs) Handles Button_StartQuiz.Click
Dim vPID As Object
vPID = Shell("notepad.exe", vbNormalFocus)
End Sub
答案 0 :(得分:1)
此处的结果并不完美,因此您可能需要弄乱API参数,但这些内容(this answer的VB.NET端口)可能很接近。
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
结果在我的电脑上有点时髦(蓝色是我的桌面颜色),因为菜单仍在显示,所有内容都已转移到占用边框所占用的空间,但未扩展以占用额外的空间。也许不同的参数会解决这个问题?