Hey everyone,
Does anyone know how i can make it so when somebody right clicks on one of the items in a text box then a form will show?
So basically
User > right clicks item in text box > form5.show
Thankyou,
Printable View
Hey everyone,
Does anyone know how i can make it so when somebody right clicks on one of the items in a text box then a form will show?
So basically
User > right clicks item in text box > form5.show
Thankyou,
vb Code:
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) '~~> If user presses Right Click If Button = 2 Then '~~> Dirty Trick to disable the popup menu that comes '~~> When you right click Text1.Enabled = False Me.SetFocus Text1.Enabled = True '~~> Show the form Form2.Show End If End Sub
koolsid uses mousedown... I use mouseup ... either way....
-tg
Interesting 'dirty trick' with the right click popup menu, but it doesn't seem to work for me.
The menu still appears after form2 opens?
Any ideas?
@Paul: Show me the code that you are trying...
This is how you should do it.
Code:Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any) As Long
Private Const WM_RBUTTONDOWN As Long = &H204
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
SendMessage Me.hWnd, WM_RBUTTONDOWN, 0, 0&
Form2.Show
End Sub
Awesome thanks guys,
Infact, How can i make it when they right click a menu comes up? with menu items i've put in the "Menu Editor?"
Thanks!
Use PopupMenu.
Code:PopupMenu MenuName
Remove the dirty trick.... and show your menu
awesome thanks, How ever...
When i am clicking on the item in the listbox, even without right clicking but left clicking on it, it shows the menu! I need it so just when i right click,
I used Dee-U's code!
Thanks,
vb Code:
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) '~~> If user presses Right Click If Button = 2 Then '~~> Dirty Trick to disable the popup menu that comes '~~> When you right click Text1.Enabled = False Me.SetFocus Text1.Enabled = True '~~> Show your popup menu PopupMenu MenuName End If End Sub
this is the part that determines if the button was the left (1) or right (2)
If Button = 2 Then
So you'll need that.
-tg
Hiay, that works ! Thanks, how ever.
Im using a list box which is getting information from my web server. The code im using for that is
vb Code:
Dim Titles() As String Dim Tmp, Tmparray ReDim tvStations(0) As String myURL = "http://www.onlinetvr.com/software/tv.dat" StringVariable = Inet4.OpenURL(myURL, 0) Titles = Split(StringVariable, vbLf) alista.Clear For i = 0 To UBound(Titles) If Trim(Titles(i)) <> "" Then Tmparray = Split(Titles(i), "==>") ReDim Preserve tvStations(UBound(tvStations) + 1) As String If Tmparray(0) <> "" Then tvStations(UBound(tvStations) - 1) = Trim(Tmparray(1)) alista.AddItem Trim(Tmparray(0)) End If End If Next i ' '
And it splits them into seperate items in the listbox.
Im trying to use your code so that when a user right clicks one of the items (Not the list box it's self. ) Then the mnu pops up. Cause at the moment no matter where i right click in the list box even if a item aint selected on then it shows the menu still. Which i cant have as the mnu is so when a user clicks preview in the menu it plays the item thats selected in the list box.
this is what the mnu items code im using is
Hope this makes sense and sorry for the long message!vb Code:
Private Sub mnu_preview_Click() SendMessage Me.hWnd, WM_RBUTTONDOWN, 0, 0& preview.Close preview.URL = tvStations(alista.ListIndex) End Sub
Use the .SelCount property to determine if an item is selected or not.
How do i do that? Please explain, Thanks
If .SelCount is greater than 0 then there is a selected item, otherwise none.