borderstyle在程序运行中是只读的,无法改变

解决方案 »

  1.   

    用API应该可以吧,具体是哪个忘了
      

  2.   

    等我找下
    你可以email给我
    [email protected]
      

  3.   

    可以的,用API函数即可
    GetWindowLong和SetWindowLong
    利用GetWindowLong获取窗口当前样式设置,利用逻辑运算符And与逻辑运算符Not来从样式值中删除WS_THICKFRAME属性,接着回调SetWindowLong函数一变为制定的窗口设置新的属性值!
    const gwl_style=(-16)
    const ws_thickframe=&h40000
    dim curstyle as long
    dim newstyle as long
    curstyle=getwindowlong(form1.hwnd,gwl_style)
    newstyle=setwindowlong(form1.hwnd,gwl_style,curstyle and not(ws_thickframe))
      

  4.   

    可以,举个例:
    在窗体上新增command1控件,代码如下:
    Option ExplicitPrivate 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 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
    Const SWP_NOSIZE = &H1
    Const SWP_NOZORDER = &H4
    Const SWP_NOMOVE = &H2
    Const SWP_DRAWFRAME = &H20
    Const GWL_STYLE = (-16)
    Private Const WS_BORDER = &H800000Private Sub Command1_Click()
        Dim l As Long
        l = GetWindowLong(Me.hwnd, GWL_STYLE)
        If l And WS_BORDER = WS_BORDER Then
            SetWindowLong Me.hwnd, GWL_STYLE, l - WS_BORDER
        Else
            SetWindowLong Me.hwnd, GWL_STYLE, l + WS_BORDER
        End If
        SetWindowPos Me.hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
    End Sub