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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window Tiltle Bar

Status
Not open for further replies.

aaaaaaaaaaaa

Programmer
Aug 4, 2001
25
IN
I want to hide the window title bar .........
Is there any API thru which i can do that
 
The titlebar of a window from your own VB application, or the title bar in a 3rd party application?
 
Well for a VB application you just need to set the forms ControlBox property to false at designtime, and then you can use toggle the state of the titlebar at runtime by setting or unsetting the Caption property. Unfortunately you can't get the ControlBox back.

And here's an illustration of a method that theoetically works for any window (to demonstrate the example you'll need to create a project with a single form with a command button; you'll also need to open a copy of Notepad):
[tt]
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

' SetWindowPos flag constants
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_FRAMECHANGED = &H20

Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000


Private Sub Command1_Click()
ToggleTitleBar "Untitled - Notepad"
End Sub

' Toggles visibility of a named window's titlebar
' Returns handle of window changed if successful
' Returns 0 if window cannot be found
Private Function ToggleTitleBar(strWindowTitle As String) As Long
Dim hWnd As Long

hWnd = FindWindow(vbNullString, strWindowTitle)

If hWnd Then
SetWindowLong hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) Xor WS_CAPTION
SetWindowPos hWnd, 0&, 0&, 0&, 0&, 0&, SWP_NOACTIVATE Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_FRAMECHANGED ' Forces nominated window to redraw itself correctly
End If
ToggleTitleBar = hWnd
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top