网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

vb.net禁用关闭按钮 excel关闭按钮

vb禁止窗口关闭命令

1、窗体属性ControlBox=False则不显示关闭、最大化、最小化按钮

为东山等地区用户提供了全套网页设计制作服务,及东山网站建设行业解决方案。主营业务为成都网站设计、网站建设、东山网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

2、如果还想保留最大化、最小化按钮,仅仅不允许关窗口,可以

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

Cancel = True

End Sub

在vb里,如何将窗口右上方的“关闭”按钮设为禁用??

复制以下代码就可以实现将窗口右上方的“关闭”按钮设为禁用

Option Explicit

Private Declare Function GetSystemMenu Lib "user32"_

(ByVal hwnd As Long, ByVal bRevert As Long) As Long

Private Declare Function GetMenuItemCount Lib "user32"_

(ByVal hMenu As Long) As Long

Private Declare Function RemoveMenu Lib "user32"_

(ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

Private Declare Function DrawMenuBar Lib "user32"_

(ByVal hwnd As Long) As Long

Private Const MF_BYPOSITION = H400

Private Const MF_REMOVE = H1000

Private Sub DisableX()

Dim hMenu As Long

Dim nCount As Long

hMenu = GetSystemMenu(Me.hWnd, 0)

nCount = GetMenuItemCount(hMenu)

'Get rid of the Close menu and its separator

Call RemoveMenu(hMenu, nCount - 1, MF_REMOVE Or MF_BYPOSITION)

Call RemoveMenu(hMenu, nCount - 2, MF_REMOVE Or MF_BYPOSITION)

'Make sure the screen updates

'our change DrawMenuBar Me.hWnd

End Sub

Private Sub Form_Load()

DisableX

End Sub

Private Sub Form_Click()

'We need a way out, since the X button'doesn't work :-)

Unload Me

End Sub

VB2008 如何取消窗体的关闭按钮

设置ControlBox为False是可以的,不过全部按钮都会消失(包括最小化,最大化)

用API可以单独把关闭按钮干掉……

'VB.NET Code

Public Class Form1

Private Declare Function GetSystemMenu Lib "User32 " (ByVal hwnd As Integer, ByVal bRevert As Long) As Integer

Private Declare Function RemoveMenu Lib "User32 " (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer

Private Declare Function DrawMenuBar Lib "User32 " (ByVal hwnd As Integer) As Integer

Private Declare Function GetMenuItemCount Lib "User32 " (ByVal hMenu As Integer) As Integer

Private Const MF_BYPOSITION = H400

Private Const MF_DISABLED = H2

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim hMenu As Integer, nCount As Integer

hMenu = GetSystemMenu(Me.Handle.ToInt32, 0)

nCount = GetMenuItemCount(hMenu)

'Debug.Print(nCount)

Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)

DrawMenuBar(Me.Handle.ToInt32)

End Sub

End Class

'VB6 code =============================================================

Private Declare Function GetSystemMenu Lib "User32 " (ByVal hwnd As Long, ByVal bRevert As Long) As Integer

Private Declare Function RemoveMenu Lib "User32 " (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

Private Declare Function DrawMenuBar Lib "User32 " (ByVal hwnd As Long) As Long

Private Declare Function GetMenuItemCount Lib "User32 " (ByVal hMenu As Long) As Long

Private Const MF_BYPOSITION = H400

Private Const MF_DISABLED = H2

Private Sub Form1_Load()

Dim hMenu As Long, nCount As Long

hMenu = GetSystemMenu(Me.hWnd, 0)

nCount = GetMenuItemCount(hMenu)

'Debug.Print nCount

Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)

DrawMenuBar Me.hWnd

End Sub

vb.net中 如何将窗体上的关闭按钮禁用 也就是变灰啊?

FormBorderStyle选为None,没有标题栏

form 的 controlbox 属性为false

VB如何恢复被ModifyMenu禁用窗体关闭按钮

'禁用关闭菜单

ModifyMenu GetSystemMenu(Me.hwnd, 0), SC_CLOSE, MF_GRAYED, 7, "不允许关闭"

将菜单ID为SC_CLOSE设置为菜单索引7的菜单项,并禁用关闭菜单

'恢复禁用的关闭菜单

ModifyMenu GetSystemMenu(Me.hwnd, 0), 7, MF_ENABLED, SC_CLOSE, "允许关闭"

将菜单的索引为7的菜单项重新设置回菜单ID,并启用关闭菜单


网站标题:vb.net禁用关闭按钮 excel关闭按钮
文章起源:http://bjjierui.cn/article/hhpeoh.html

其他资讯