怎样使用VBA去除窗体标题与边框?
来源:网络收集 点击: 时间:2024-03-02首先在开发工具中打开VBA编辑器

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

在VBA编辑器中插入模块

在模块当中输入如下代码,然后运行
Private Declare Function FindWindow Lib use32 Alias FindWindowA(ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function CreateRectRgn Lib gdi32 (ByVal X1 As Long,ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As LongPrivate Declare Function SetWindowRgn Lib use32 (ByVal hWnd As Long,ByVal hRgn As Long, ByVal bRedraw As Boolean) As LongPrivate Declare Function DeleteObject Lib gdi32 (ByVal hObject As Long) As LongPrivate Sub UserForm_Click()Unload Me 单击关闭窗体End SubPrivate 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

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

智能手机助理给我们的生活带来了极大的便利!
版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.ff371.cn/art_220488.html