|
-
Mar 10th, 2001, 11:20 AM
#1
Thread Starter
Hyperactive Member
I've written a sub that transfers selected text from one box to another, however it's triggered by a double click, and when you double click the text box is programmed to highlight the whole word that the cursor is over. I have the box reselect all the text that was transferred, however you still see the quick flash of the box's reselection from double click. Is there a way to disable this code? Thanks in advance.
-
Mar 10th, 2001, 11:37 AM
#2
why put it in a dbl-click? why not just right mouse click and bring up a popupmenu to call the sub?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 10th, 2001, 02:13 PM
#3
Thread Starter
Hyperactive Member
Because I'm programming it for my father, and he wants it this way because he says all the physicians at his office are computer illiterate and that's how he wants it.
-
Mar 10th, 2001, 02:24 PM
#4
You can subclass your TextBox to catch the WM_LBUTTONDBLCLK message.
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)
Private 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
'<-- Add your custom code here-->
Debug.Print Form1.Text1.SelText
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
Add to a Form
Code:
Private Sub Form_Load()
SubClassWnd Text1.hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubclassWnd Text1.hwnd
End Sub
-
Mar 10th, 2001, 02:43 PM
#5
I've always wondered...what would happen if you didn't put that call in the Form_Unload?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 10th, 2001, 03:02 PM
#6
its not pretty. Usually windows will crash.
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
|