0

I try to integrate a window programm into a panel container in vb.net.

All is ok but the scroll bars is disabled, dou you know why ?

My code is:

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)

The program putty.exe is correctyl integrader in the panel container named "panel1" but the vertical scrollbar is disabled. Do you know why ?

The script use the following declarations:

   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

Xavier
  • 43
  • 1
  • 8
  • You could, more simply, transfer the console output to a WinForms control. Using a RichTextBox, with a little tweaking, you can also reproduce the colors. [Here's an example](https://stackoverflow.com/a/51313844/7444103). – Jimi Feb 11 '19 at 13:35
  • Hello, this is an interractive screen (putty / ssh client), not a simple log. – Xavier Feb 11 '19 at 15:31
  • Look, there are really many things that could be said about the code you're showing. That it looks like it came from another era, for example. Anyway, if you want to keep it as it is and just show the scroll bars, then set `lCurStyle = lCurStyle Or WS_VSCROLL`. Also, you just need `lCurStyle = lCurStyle And Not WS_CAPTION`, maybe also remove the frame (`WS_THICKFRAME`). Then, `proc.WaitForInputIdle`: this is used when the process has a graphical interface and you need to wait until is completely shown. A Console doesn't have one. Substitute with `Thread.Sleep(200)`. – Jimi Feb 11 '19 at 16:23
  • Thank you for your comment. If you think that the code seems to come from another era: Don't hesitate to let me see another code more "modern" to integrate the contents of an external program to a container with vb.net and keeping its interractivté like putty.exe or mstsc.exe. Thank you . – Xavier Feb 11 '19 at 18:23
  • That I can do. But, have you tried to modify the code as described in the previous comment? – Jimi Feb 11 '19 at 18:35

0 Answers0