|
-
Feb 1st, 2009, 02:25 PM
#1
Thread Starter
Junior Member
[2005] Hiding the Titlebar, MenuStrip, ToolStrip etc
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
-
Feb 1st, 2009, 02:38 PM
#2
Re: [2005] Hiding the Titlebar, MenuStrip, ToolStrip etc
Can you read the window handle of the menu and use setwindowlong to unset WS_VISIBLE?
I haven't tried it, but it might be worth a shot.
-
Feb 1st, 2009, 02:55 PM
#3
Thread Starter
Junior Member
Re: [2005] Hiding the Titlebar, MenuStrip, ToolStrip etc
 Originally Posted by Negative0
Can you read the window handle of the menu and use setwindowlong to unset WS_VISIBLE?
I haven't tried it, but it might be worth a shot.

Well, that hid the MenuStrip and ToolStrip OK, but also hides the application area, and brings back the TitleBar.
Rock
-
Feb 1st, 2009, 03:16 PM
#4
Re: [2005] Hiding the Titlebar, MenuStrip, ToolStrip etc
What if you do them in a different order, does that make a difference?
-
Feb 1st, 2009, 04:05 PM
#5
Thread Starter
Junior Member
Re: [2005] Hiding the Titlebar, MenuStrip, ToolStrip etc
 Originally Posted by Negative0
What if you do them in a different order, does that make a difference?
I am not sure what you mean by 'a different order', but certainly you can OR two or more of the 40 or so Windows style constants to produce a huge number of combinations.
I was rather hoping that someone has been down this road before and knows which combination can produce the effect I am after.
Rock
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|