怎样使用VBA去除窗体标题与边框?

 时间:2026-04-22 06:40:13

1、首先在开发工具中打开VBA编辑器

怎样使用VBA去除窗体标题与边框?

2、在单元格区域当中输入一些内容作为例子

怎样使用VBA去除窗体标题与边框?

3、在VBA编辑器中插入模块

怎样使用VBA去除窗体标题与边框?

4、在模块当中输入如下代码,然后运行

Private Declare Function FindWindow Lib "use32" Alias "FindWindowA"


(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long,
ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "use32" (ByVal hWnd As Long,
ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Sub UserForm_Click()
 Unload Me  '单击关闭窗体
End Sub
Private Sub UserForm_Initialize()
    Dim hWnd As Long, new_rgn As Long
    If Val(Application.Version) < 9 Then '如果是Windows 2000以下的系统
      hWnd=FindWindow("ThunderXFrame", Me.Caption)
                                          '获取窗口句柄ThunderXFrame
    Else                           '否则
      hWnd=FindWindow("ThunderDFrame", Me.Caption)
                                          '获取窗口句柄ThunderDFrame
    End If
    new_rgn=CreateRectRgn(3, 29, (Me.Width * 1.33)-2,
      (Me.Height * 1.33)-2) '创建一个由四个数据点描述的矩形区域
    SetWindowRgn hWnd, new_rgn, True  '按前面定义的区域重绘窗体形状
    Call DeleteObject(new_rgn)
End Sub

怎样使用VBA去除窗体标题与边框?

5、用快捷键F5运行窗体,窗体仅仅显示图片区,标题及边框已隐藏。隐藏边框前的窗体如图13.10所示,隐藏边框后的窗体如图

怎样使用VBA去除窗体标题与边框?

  • VBA数组与单元格区域
  • 如何通过Excel VBA设计用户信息查询工具
  • VBA如何使用Excel中的函数?
  • VBA如何添加模块
  • 怎样使用VBA两个列表框之间的内容转移?
  • 热门搜索
    12月6日是什么星座 看破红尘是什么意思 4月7日是什么星座 离殇是什么意思 p档是什么意思 籍贯是什么 雪纺是什么面料 星星是什么 属马的和什么属相最配 纲举目张是什么意思