Hi,

I have been playing with the Windows API.

A Windows application typically has a TitleBar (with a caption on it), underneath is a MenuStrip, under that a ToolStrip (with the tool icons on it), and under that the main application area.

I want to be able to strip everything off, except for the main application area.

I have found how to hide the TitleBar, using:

GetWindowLong (and passing to it the handle of the form, and GW_STYLE to get the current windows style)

SetWindowLong (and passing to it the handle of the form, the InitialStyle, and ORing with it WS_DLGFRAME)

Does anyone know how to remove the MenuStrip and ToolStrip to leave just the main application area?

Code so far:

Code:
Public Class Form1

    Private Const WM_SYSCOMMAND As Integer = 274
    Private Const SC_MAXIMIZE As Integer = 61488
    Private proc As New Process
    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
    Declare Auto Function GetWindowThreadProcessId Lib "core.dll" (ByVal hwnd As IntPtr, ByRef lpdwProcessId As UInteger) As UInteger
    Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    Private Const GWL_STYLE As Integer = (-16)
    Private Const WS_DLGFRAME As Integer = &H400000    'use this to hide TitleBar
    Private Const WS_BORDER As Integer = &H800000
    Private InitialStyle As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim p As New System.Diagnostics.ProcessStartInfo
        p.FileName = "C:\Program Files\Console2\Console.exe"
        proc.StartInfo = p
        proc.Start()
        proc.WaitForInputIdle()
        SetParent(proc.MainWindowHandle, Panel1.Handle)
        SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
        InitialStyle = GetWindowLong(proc.MainWindowHandle, GWL_STYLE)
        SetWindowLong(proc.MainWindowHandle, -16, InitialStyle And Not WS_BORDER)

    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Try
            proc.Kill()
        Catch ex As Exception
        Finally
            proc.Dispose()
        End Try
    End Sub

End Class
Thanks in advance

Rock