标题:VB6如何取消掉这两个按钮的功能
只看楼主
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册:2009-12-22
结帖率:89.13%
 问题点数:0 回复次数:4 
VB6如何取消掉这两个按钮的功能
如何让这两个按钮正常显示(不变灰,不隐藏),但点击无任何反应,实现弹窗广告的效果?

搜索更多相关主题的帖子: 按钮 效果 取消 广告 VB6 
2022-06-29 19:07
chenyucheng
Rank: 3Rank: 3
来 自:浙江省台州市临海市
等 级:论坛游侠
威 望:3
帖 子:141
专家分:181
注 册:2022-7-1
得分:0 
Private Sub Form_Resize()
    WindowState = 0
End Sub

爱玩编程的小学生,有Python,但只会一点点C++。

版主->斑竹->竹子,所以版主是竹子。(doge)
//不要让我当版主
2022-07-01 17:34
yuma
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:银河系
等 级:贵宾
威 望:33
帖 子:1883
专家分:2904
注 册:2009-12-22
得分:0 
最大化完美不动,最小化窗口还动了。

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。
2022-07-01 20:59
apull
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:三体星系
等 级:版主
威 望:185
帖 子:1404
专家分:8479
注 册:2010-3-16
得分:0 
直接做个无边框窗口,右上角放个按钮关闭窗口好了。
2022-07-01 21:48
William1949
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:109
专家分:0
注 册:2009-3-17
得分:0 
Module1
程序代码:
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 CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const GWL_WNDPROC = -4

Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTMINBUTTON = 8
Private Const HTMAXBUTTON = 9

Private OldWndProc  As Long

 
Public Sub StartSubClass(ByVal hWnd As Long)
    OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub ExitSubClass(ByVal hWnd As Long)
    Call SetWindowLong(hWnd, GWL_WNDPROC, OldWndProc)
End Sub

Private Function WindowProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Select Case Msg
        Case WM_NCLBUTTONDOWN   '只禁用两个按钮,系统菜单可用
            If wParam = HTMINBUTTON Or wParam = HTMAXBUTTON Then
                WindowProc = True
                Exit Function
            End If
    End Select
    WindowProc = CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam)
End Function


Form1
程序代码:
Private Sub Form_Load()
    Call StartSubClass(Me.hWnd)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call ExitSubClass(Me.hWnd)
End Sub





Module1(禁用两个按钮 和 系统菜单)
程序代码:
Private Const WM_SYSCOMMAND = &H112
Private Const SC_MINIMIZE = &HF020&
Private Const SC_MAXIMIZE = &HF030&

Private Function WindowProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Select Case Msg
        Case WM_SYSCOMMAND   '禁用两个按钮,包含系统菜单
            If wParam = SC_MINIMIZE Or wParam = SC_MAXIMIZE Then
                WindowProc = True
                Exit Function
            End If
    End Select
    WindowProc = CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam)
End Function



[此贴子已经被作者于2022-7-13 22:15编辑过]

2022-07-13 22:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-509453-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018956 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved