Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I address the Titlebar

Status
Not open for further replies.

FrankExp

MIS
Dec 11, 2002
44
NL
I'm trying to open a application in full-screen. So I need to hide the titlebar of the application.

If that is not possible, I would like to know the vertical size of the bar so I can use this in the calculation of the rest of the screen.

How can I address this titlebar?



Frank van de Kant
 
VB.NET:

Code:
Public Class Form1

	Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
	Private 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_CAPTION As Integer = &HC00000 'use this to hide TitleBar Text/Icons etc
	Private Const WS_DLGFRAME As Integer = &H400000	'use this to hide TitleBar

	Private InitialStyle As Integer
	Private BorderStyle As FormBorderStyle

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

		BorderStyle = Me.FormBorderStyle
		Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedDialog
		InitialStyle = GetWindowLong(Me.Handle, GWL_STYLE)
		SetWindowLong(Me.Handle, -16, InitialStyle And Not WS_DLGFRAME)

	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

		SetWindowLong(Me.Handle, GWL_STYLE, InitialStyle)
		Me.FormBorderStyle = BorderStyle

	End Sub

	'To create a form with no TitleBar
	'Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
	'	Get
	'		Dim cp As CreateParams = MyBase.CreateParams
	'		cp.Style = cp.Style And Not WS_DLGFRAME
	'		Return cp
	'	End Get
	'End Property

End Class

Shouldn't be too difficult to convert.

[vampire][bat]
 
Thanks for your help,earthandfire. However, this may be not difficult to convert, when VB is a standard language.

Do you also have an example in C# ?

When I try to convert your code by using Reflection I do not get a correct C#-code.

Frank van de Kant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top