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

1 Reply , Posted in 程序代码 on 2017 28, 2017

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

好啦,可以运行我们创建的这个工程了,现在双击窗体的标题栏是不是和以前不一样啊!

:)

标签:    

相关推荐

vb读取access并且显示  (2017-5-11 9:18:27)

VB 获取CPU温度示例  (2017-5-8 10:35:11)

VB程序逆向反汇编常见的函数   (2017-5-8 10:32:0)

VB内嵌汇编的模块示例  (2017-5-8 10:24:4)

内存数据的读写(PC)   (2017-3-1 17:51:40)

用VB制作外挂   (2017-3-1 16:16:53)

root
root 发布于 2022-8-8 11:23:51
default/yell%2Epngdefault/smile%2Epngdefault/waii%2Epng
回复

发表评论:



◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

                       

  鄂公网安备 42112502000156号     鄂ICP备16019550号