在SetParent之后获取滚动条的问题

时间:2019-02-11 13:01:16

标签: vb.net integrate setparent setwindowlong

我尝试将窗口程序集成到vb.net的面板容器中。

一切正常,但滚动条已禁用,你知道为什么吗?

我的代码是:

Dim info As ProcessStartInfo = New ProcessStartInfo
info.FileName = "C:\putty\\putty.exe"
info.Arguments = "-ssh 192.168.1.1 -l root -pw myPassword"
info.UseShellExecute = True

proc = New Process
proc.StartInfo = info

proc.Start()
proc.WaitForInputIdle()

lCurStyle = GetWindowLong(proc.MainWindowHandle, GWL.GWL_STYLE)

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
lCurStyle = lCurStyle And Not WS_HSCROLL
lCurStyle = lCurStyle And WS_VSCROLL

SetWindowLong(proc.MainWindowHandle, GWL.GWL_STYLE, lCurStyle)
SetParent(proc.MainWindowHandle, Panel1.Handle)

SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 1)

程序putty.exe是名为“ panel1”的面板容器中的正确集合体,但垂直滚动条已禁用。你知道为什么吗?

该脚本使用以下声明:

   Declare Auto Function DeleteMenu Lib "user32.dll" (hMenu As IntPtr, uPosition As IntPtr, uFlags As IntPtr) As Boolean

    Declare Auto Function GetWindowLong Lib "user32.dll" (ByVal HWND As IntPtr, ByVal Index As Integer) As Integer
    Declare Auto Function SetWindowLong Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer

    Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Public Const SC_CLOSE As Integer = &HF060&
Public Const SC_SIZE As Integer = &HF000&
Public Const SC_MAXIMIZE As Integer = &HF030&
Public Const SC_MINIMIZE As Long = &HF020&
Public Const SC_RESTORE As Long = &HF120&

Public Const WM_SYSCOMMAND As Integer = 274
Public Const WS_BORDER = &H800000
Public Const WS_CAPTION = &HC00000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_OVERLAPPED As Integer = &H0
Public Const WS_POPUP As Integer = &H80000000
Public Const WS_CHILD As Integer = &H40000000
Public Const WS_MINIMIZE As Integer = &H20000000
Public Const WS_VISIBLE As Integer = &H10000000
Public Const WS_DISABLED As Integer = &H8000000
Public Const WS_CLIPSIBLINGS As Integer = &H4000000
Public Const WS_CLIPCHILDREN As Integer = &H2000000
Public Const WS_MAXIMIZE As Integer = &H1000000
Public Const WS_DLGFRAME As Integer = &H400000
Public Const WS_VSCROLL As Integer = &H200000
Public Const WS_HSCROLL As Integer = &H100000
Public Const WS_SYSMENU As Integer = &H80000
Public Const WS_THICKFRAME As Integer = &H40000
Public Const WS_GROUP As Integer = &H20000
Public Const WS_TABSTOP As Integer = &H10000

enter image description here

0 个答案:

没有答案