请问在VB中如何去掉标题栏

解决方案 »

  1.   

    Form的BorderStyle属性为0 - None假如不想要标题栏上的系统操作功能,设置Form属性的ControlBox=false
      

  2.   

    ControlBox = False
    Caption = ""
      

  3.   

    Form的BorderStyle属性为0 - None
      

  4.   

    ControlBox = False
    Caption = ""
    Form的BorderStyle属性为0 - None
    Form的BorderStyle属性为0 - None
      

  5.   

    Form1.BorderStyle=0 '无边框
    Form1.Caption = ""  '无标题,这个一定要加,否则如果你的窗体有标题文字,标题栏还是会有的。
      

  6.   

    Form1.BorderStyle设置窗体状态栏的形式
    Form1.ControlBox设置有无状态栏
      

  7.   

    ControlBox = False
    Caption = ""
      

  8.   

    是不是动态设计?
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Const GWL_STYLE = (-16)
    Private Const WS_CAPTION = &HC00000     ' WS_BORDER 或 WS_DLGFRAME
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const WS_MINIMIZEBOX = &H20000
    Private Const WS_SYSMENU = &H80000Private 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 LongPrivate Enum ESetWindowPosStyles
        SWP_SHOWWINDOW = &H40
        SWP_HIDEWINDOW = &H80
        SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE
        SWP_NOACTIVATE = &H10
        SWP_NOCOPYBITS = &H100
        SWP_NOMOVE = &H2
        SWP_NOOWNERZORDER = &H200 ' Don't do owner Z ordering
        SWP_NOREDRAW = &H8
        SWP_NOREPOSITION = SWP_NOOWNERZORDER
        SWP_NOSIZE = &H1
        SWP_NOZORDER = &H4
        SWP_DRAWFRAME = SWP_FRAMECHANGED
        HWND_NOTOPMOST = -2
    End EnumPrivate Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End TypePrivate Function ShowTitleBar(ByVal bState As Boolean)
    Dim lStyle As Long
    Dim tR As RECT    ' 获取窗口的位置:
        GetWindowRect Me.hwnd, tR    ' 调整标题栏是否可见:
        lStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
        If (bState) Then
        Me.Caption = Me.Tag
        If Me.ControlBox Then
            lStyle = lStyle Or WS_SYSMENU
        End If
        If Me.MaxButton Then
            lStyle = lStyle Or WS_MAXIMIZEBOX
        End If
        If Me.MinButton Then
            lStyle = lStyle Or WS_MINIMIZEBOX
        End If
        If Me.Caption <> "" Then
            lStyle = lStyle Or WS_CAPTION
        End If
        Else
        Me.Tag = Me.Caption
        Me.Caption = ""
        lStyle = lStyle And Not WS_SYSMENU
        lStyle = lStyle And Not WS_MAXIMIZEBOX
        lStyle = lStyle And Not WS_MINIMIZEBOX
        lStyle = lStyle And Not WS_CAPTION
    End If
    SetWindowLong Me.hwnd, GWL_STYLE, lStyle' 重新设定窗口:
    SetWindowPos Me.hwnd, 0, tR.Left, tR.Top, tR.Right - tR.Left, tR.Bottom - tR.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED
    Me.Refresh' 你可能需要在Form_Resize中加一点代码,因为客户区的大小已经改变:
    'Form_ResizeEnd Function
        '为了试验一下代码,在窗体上放一个CheckBox,将它的Value属性设为1 (Checked)。然后写入以下代码:Private Sub Check1_Click()
        If (Check1.Value = Checked) Then
        ShowTitleBar True
        Else
        ShowTitleBar False
    End If
    End Sub