动态设定窗体的BorderStyle
或者使用API函数!

解决方案 »

  1.   

    如果你熟悉API函数的话,可以用SetWindowLong去动态改变它。注意把最后一个参数改为GWL_STYLE。
      

  2.   

    controlbox=falseOption ExplicitPrivate Sub Command1_Click()
    Me.Caption = ""
    End SubPrivate Sub Command2_Click()
    Me.Caption = "asdf"
    End Sub
      

  3.   

    getsystemmatrixsetwindowrgn (...rect...)
      

  4.   

    feihong0233(泓) :
    我想在设计时让controlbox=true
    在运行时使controlbox=false
      

  5.   

    我是这么用的,只是因为标题栏实在是难看!用这个函数关掉。
    form_load
        ShowTitleBar false
        .....
    Private Function Private 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
            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
    End Function
    (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
            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
    End Function
      

  6.   

    Private 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
            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
    End Function
      

  7.   


    '先设定form1.controlbox=falsePrivate Sub Form_Load()
    With Me
        .BorderStyle = 3
        .Tag = .Caption
        .Caption = ""
        .RefreshEnd WithEnd Sub