LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default set textbox cursor in mouse right-click

Hi Bart,

This seemed to work for me with no more testing than shown below. Not sure
about other implications, eg might want to flag and early exit other Textbox
events.

Private Declare Sub mouse_event Lib "user32" ( _
ByVal dwFlags As Long, ByVal dX As Long, _
ByVal dY As Long, ByVal dwData As Long, _
ByVal dwExtraInfo As Long)

Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
'Dim mbExit As Boolean

Private Sub TextBox1_Mouseup(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Static bExit As Boolean

Debug.Print "Button"; Button, "bExit "; bExit

If bExit Then
bExit = False
Debug.Print "Exit Sub"
Debug.Print
Exit Sub
End If

If Button = 2 Then
bExit = True
MouseClick
End If

End Sub

Sub MouseClick()
Debug.Print "MouseClick"

mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
DoEvents
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

End Sub

But this prevents the default right-click to 'select entire word' ?

Regards,
Peter T
"RB Smissaert" wrote in message
...
Is there an easy way to set the cursor in a textbox in the the mouse down
event when the right mouse button is used?
This is an ordinary textbox in a VBA userform, so I am not sure the

Windows
API can help out here.

RBS





 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA - Click mouse to change cursor to cross hair that spans the en gary Excel Programming 26 May 26th 06 04:15 PM
Mouse Over Graph, Capture Information on Click(Double Click) Dean Hinson[_3_] Excel Programming 1 December 6th 04 04:49 AM
position mouse cursor in msg box swatsp0p[_2_] Excel Programming 2 September 24th 04 07:12 AM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM
How to move cursor from one textbox control to another textbox con KMoore007 Excel Programming 0 September 16th 04 02:47 PM


All times are GMT +1. The time now is 11:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"