三度网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

让窗体的标题栏不相应鼠标双击

时间:2024/6/2作者:未知来源:三度网教程人气:


1。新建一个VB6的标准EXE工程,然后添加一个模块,将下列代码加入新的模块中:

Option Explicit
                    
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
        
Const GWL_WNDPROC = (-4&)

Dim PrevWndProc&

Const WM_NCLBUTTONDBLCLK = &HA3
  
Public Sub Init(hWnd As Long)
  PrevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf SubWndProc)
End Sub

Public Sub Terminate(hWnd As Long)
  Call SetWindowLong(hWnd, GWL_WNDPROC, PrevWndProc)
End Sub

Private Function SubWndProc(ByVal hWnd As Long, ByVal Msg As Long, _
                            ByVal wParam As Long, ByVal lParam As Long) _
                            As Long
  
  If Msg = WM_NCLBUTTONDBLCLK Then
     Exit Function
  End If
  
  SubWndProc = CallWindowProc(PrevWndProc, hWnd, Msg, wParam, lParam)
End Function

2。在窗体的Load事件中加入一下代码:

Private Sub Form_Load()
Call Init(Me.hWnd)
End Sub

3。最后在窗体的Unload事件中加入:

Private Sub Form_Unload(Cancel As Integer)
Call Terminate(Me.hWnd)
End Sub
好啦,可以运行我们创建的这个工程了,现在双击窗体的标题栏是不是和以前不一样啊!

:)

以上程序在Win2000中文版、VB6下编译运行通过

关键词:  让窗体的标题栏不相应鼠标双击





Copyright © 2012-2018 三度网教程(http://www.3du8.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版