文档库

最新最全的文档下载
当前位置:文档库 > 显示隐藏Excel VBA窗体标题栏

显示隐藏Excel VBA窗体标题栏

Dim hMain As Long

Dim tStr As String

Private Function TitleBar(ByVal bState As Boolean)

Dim lStyle As Long

Dim tR As excelba.RECT

GetWindowRect hMain, tR

lStyle = GetWindowLong(hMain, GWL_STYLE)

If (bState) Then

Me.Caption = tStr

lStyle = lStyle Or WS_SYSMENU

lStyle = lStyle Or WS_CAPTION

Else

Me.Caption = ""

lStyle = lStyle And Not WS_SYSMENU

lStyle = lStyle And Not WS_CAPTION

End If

SetWindowLong hMain, GWL_STYLE, lStyle

SetWindowPos hMain, 0, tR.Left, tR.Top, tR.Right - tR.Left, tR.Bottom - tR.Top, SWP_NOREPOSITION End Function

Private Sub CheckBox1_Click()

If CheckBox1.Value = True Then

TitleBar True

CheckBox1.Caption = "单击隐藏标题"

Else

TitleBar False

CheckBox1.Caption = "单击显示标题"

End If

End Sub

Private Sub UserForm_Initialize()

hMain = FindWindow(vbNullString, Me.Caption)

tStr = Me.Caption

CheckBox1.Caption = "单击隐藏标题"

End Sub

ITION Or SWP_NOZORDER Or SWP_FRAMECHANGED