取消用户窗体的标题行
先发一通与命题无关的感慨,然后再进入正题。
写作的过程太艰难了,至少比写博客要难得多!经过这两天艰苦的努力,终于完成了《精粹》绪论的初稿,也不知道写得怎么样。唉!暂时这样吧,明天找个清静的时间再阅读一遍,然后……
现在进入正题。如题,这是EH论坛上一位网友的问题:
- 用户窗体加载时如何取消那个标题行?
某位给出了一段示例,实现的效果如下图:

很酷!将代码辑录在此,供日后参考。
Private Declare Function DrawMenuBar Lib “user32″ (ByVal hwnd As Long) As Long
Private 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 FindWindow Lib “user32″ Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const GWL_STYLE As Long = (-16)
Private Const WS_CAPTION As Long = &HC00000
Private Sub CommandButton4_Click()
If ComboBox2.Text = “” Or TextBox2.Text = “” Then
MsgBox “请填写齐全”, 1 + 64, “系统提示”
TextBox2.SetFocus
Else
‘if ………
‘……………….
MsgBox ComboBox2.Text & ” 您好!欢迎您使用本系统”, 0, “XXX系统”
Unload UserForm2
Application.Visible = True
‘…………..
‘ Else
‘ MsgBox “登录密码错误,请重新输入”
‘ Me.TextBox2 = “”
‘ TextBox2.SetFocus
‘ End If
End If
End Sub
Private Sub CommandButton3_Click()
Unload Me
‘…………
ActiveWorkbook.Save
Application.Quit
End Sub
Private Sub UserForm_Initialize()
hwnd = FindWindow(”ThunderDFrame”, Me.Caption)
SetWindowLong hwnd, GWL_STYLE, IStyle
DrawMenuBar hwnd
End Sub

发表评论