Retrieves information about the specified title bar.
Code:Const CCHILDREN_TITLEBAR As Int32 = 5 Private Enum TitleState STATE_SYSTEM_UNAVAILABLE = 1 STATE_SYSTEM_PRESSED = 8 STATE_SYSTEM_INVISIBLE = 32768 STATE_SYSTEM_OFFSCREEN = 65536 STATE_SYSTEM_FOCUSABLE = 1048576 End Enum Private Structure TitleBarButtonStates Public TitleBarState As TitleState Public Reserved As TitleState Public MinState As TitleState Public MaxState As TitleState Public HelpState As TitleState Public CloseState As TitleState End Structure Private Structure RECT Public Left, Top, Right, Bottom As Int32 End Structure Private Structure TITLEBARINFO Public cbSize As Int32, rcTitleBar As RECT, rgState As TitleBarButtonStates End Structure Private Declare Function apiGetTitleBarInfo Lib "user32" Alias "GetTitleBarInfo" (ByVal hwnd As Int32, ByRef pti As TITLEBARINFO) As Int32 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim t As New TITLEBARINFO t.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(t) apiGetTitleBarInfo(Me.Handle.ToInt32, t) MessageBox.Show("Left:" & t.rcTitleBar.Left & " Top:" & t.rcTitleBar.Top & " Right:" & t.rcTitleBar.Right & " Bottom:" & t.rcTitleBar.Bottom) If t.rgState.TitleBarState <> TitleState.STATE_SYSTEM_FOCUSABLE Then MessageBox.Show("Title bar not focusable", "Title bar info") Else MessageBox.Show("Title bar is focusable", "Title bar info") End If End Sub


Reply With Quote