ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 12654|回复: 15

如何去掉窗体中的关闭按钮

[复制链接]

TA的精华主题

TA的得分主题

发表于 2006-12-27 08:46 | 显示全部楼层 |阅读模式
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
如何去掉窗体中的关闭按钮,见附件,谢谢! YxxIJw1k.rar (9.36 KB, 下载次数: 209)

TA的精华主题

TA的得分主题

发表于 2006-12-27 08:47 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
OOfuYf2S.rar (9.92 KB, 下载次数: 530)
试试

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-12-27 10:17 | 显示全部楼层
简单一点告诉我加入哪些代码就行吧,太复杂了看不懂哦。

TA的精华主题

TA的得分主题

发表于 2006-12-27 10:47 | 显示全部楼层

Private Sub UserForm_Initialize()

Dim hWndForm As Long
Dim iStyle As Long, hMenu As Long
    If Val(Application.Version) < 9 Then
        hWndForm = FindWindow("ThunderXFrame", Me.Caption)  'XL97
    Else
        hWndForm = FindWindow("ThunderDFrame", Me.Caption)  'XL2000
    End If
    iStyle = GetWindowLong(hWndForm, GWL_STYLE)

   iStyle = iStyle And Not WS_CAPTION '无边框样式


      SetWindowLong hWndForm, GWL_STYLE, iStyle

    DrawMenuBar hWndForm

 End Sub

这样可以达到同样的效果!


TA的精华主题

TA的得分主题

发表于 2006-12-27 10:58 | 显示全部楼层
QUOTE:
以下是引用hhench1在2006-12-27 10:17:38的发言:
简单一点告诉我加入哪些代码就行吧,太复杂了看不懂哦。

把代码贴进你的程序中就行了。

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-12-27 11:28 | 显示全部楼层

知道把代码放进程序里,就是因为放进去了不行所以才要请教。

fang5852的代码放进去也不行,奇怪。

TA的精华主题

TA的得分主题

发表于 2006-12-27 12:03 | 显示全部楼层

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 UserForm_Initialize()
    Dim hwnd
    Dim rng As Range
    If Val(Application.Version) < 9 Then
        hwnd = FindWindow("ThunderXFrame", Me.Caption)
    Else
        hwnd = FindWindow("ThunderDFrame", Me.Caption)
    End If
    SetWindowLong hwnd, GWL_STYLE, IStyle
    DrawMenuBar hwnd

end

我用的行呀,你在试试这段

评分

1

查看全部评分

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-12-27 13:56 | 显示全部楼层
QUOTE:
以下是引用fang5852在2006-12-27 12:03:59的发言:

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 UserForm_Initialize()
    Dim hwnd
    Dim rng As Range
    If Val(Application.Version) < 9 Then
        hwnd = FindWindow("ThunderXFrame", Me.Caption)
    Else
        hwnd = FindWindow("ThunderDFrame", Me.Caption)
    End If
    SetWindowLong hwnd, GWL_STYLE, IStyle
    DrawMenuBar hwnd

end

我用的行呀,你在试试这段

用以上这个代码的效果如下,我想要的只是去掉关闭按钮,而不是把标题栏也去掉了。


如何去掉窗体中的关闭按钮

如何去掉窗体中的关闭按钮

TA的精华主题

TA的得分主题

发表于 2006-12-27 16:03 | 显示全部楼层
ovl13x03.rar (7.51 KB, 下载次数: 1541)
这个就是你要的效果。

评分

1

查看全部评分

TA的精华主题

TA的得分主题

发表于 2007-9-8 17:39 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
谢谢yuanzhuping版主,API好复杂呀!
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-9-29 16:27 , Processed in 0.040279 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表