|
-
Apr 12th, 2001, 07:10 AM
#1
Thread Starter
Member
Is there a way to disable DblClick event on ActiveX control ?
The problem is, if I click on a control, MouseDown will run first, then MouseUp, but the next click, DblClick will run instade of MouseUp and MouseDown.
I want in all cases, MouseDown and MouseUp to run
-
Apr 12th, 2001, 02:40 PM
#2
Double click will only run if you press the mouse fast enough.
-
Apr 12th, 2001, 02:43 PM
#3
I guess you could always subclass your Form.
Add to a Module.
Code:
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
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)
Const WM_LBUTTONDBLCLK = &H203
Global WndProcOld As Long
Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If wMsg = WM_LBUTTONDBLCLK Then Exit Function
WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
End Function
Sub SubClassWnd(hwnd As Long)
WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
End Sub
Sub UnSubclassWnd(hwnd As Long)
SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
WndProcOld& = 0
End Sub
Add to a Form.
Code:
Private Sub Form_Load()
SubClassWnd hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubclassWnd hwnd
End Sub
-
Apr 13th, 2001, 10:18 AM
#4
Thread Starter
Member
Thanks Megatron for your reply..
Your code has diabled DblClick event but still i can not make MouseDown and MouseUp runs fast..
What I want is, even if you double click on a form (or
picturebox) the MouseDown and MouseUp should run,
like this : -
Click (1)
>> MouseDown
>> MouseUp
Click(2)
>> MouseDown
>> MouseUp
But it VB works like this: -
Click(1)
>> MouseDown
>> MouseUp
Click(2)
>> DblClick <-- here is the problem !
Plz help..
-
Apr 13th, 2001, 10:37 AM
#5
Just send the WM_LBUTTONDOWN message on the double click message.
Replace the former Module with this one:
Code:
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
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)
Const WM_LBUTTONDBLCLK = &H203
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Global WndProcOld As Long
Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If wMsg = WM_LBUTTONDBLCLK Then
PostMessage hwnd, WM_LBUTTONDOWN, 0, 0
Exit Function
End If
WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
End Function
Sub SubClassWnd(hwnd As Long)
WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
End Sub
Sub UnSubclassWnd(hwnd As Long)
SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
WndProcOld& = 0
End Sub
-
Apr 14th, 2001, 04:59 AM
#6
Thread Starter
Member
It works nicly... thanks..
Btw.. What is sub classing excactly ? it seams to be powerfull...
Where can i get good resource of sub classing ?
Thanks again megatron..
(I will add new thread for SubClassing !)
Last edited by hassan; Apr 14th, 2001 at 05:03 AM.
-
Apr 14th, 2001, 10:08 AM
#7
Basically, subclassing allows to intercept messages. This can be useful, because VB doesn't provide even for all messages. It's also useful because you can override VB's commands. For example, you can intercept the Right-Click in a TextBox, so the context menu doesn't pop-up.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|