|
-
Oct 28th, 2009, 03:21 PM
#1
Thread Starter
Fanatic Member
how to use a Right click option?
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,
-
Oct 28th, 2009, 03:34 PM
#2
Re: how to use a Right click option?
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
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 28th, 2009, 03:37 PM
#3
Re: how to use a Right click option?
koolsid uses mousedown... I use mouseup ... either way....
-tg
-
Oct 28th, 2009, 03:38 PM
#4
Addicted Member
Re: how to use a Right click option?
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?
-
Oct 28th, 2009, 03:42 PM
#5
Re: how to use a Right click option?
@Paul: Show me the code that you are trying...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 28th, 2009, 03:53 PM
#6
Re: how to use a Right click option?
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
-
Oct 28th, 2009, 03:53 PM
#7
Thread Starter
Fanatic Member
Re: how to use a Right click option?
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!
-
Oct 28th, 2009, 03:55 PM
#8
Re: how to use a Right click option?
-
Oct 28th, 2009, 03:56 PM
#9
Re: how to use a Right click option?
Remove the dirty trick.... and show your menu
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 28th, 2009, 04:00 PM
#10
Thread Starter
Fanatic Member
Re: how to use a Right click option?
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,
-
Oct 28th, 2009, 04:04 PM
#11
Re: how to use a Right click option?
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
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 28th, 2009, 04:09 PM
#12
Re: how to use a Right click option?
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
-
Oct 28th, 2009, 04:18 PM
#13
Thread Starter
Fanatic Member
Re: how to use a Right click option?
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
vb Code:
Private Sub mnu_preview_Click() SendMessage Me.hWnd, WM_RBUTTONDOWN, 0, 0& preview.Close preview.URL = tvStations(alista.ListIndex) End Sub
Hope this makes sense and sorry for the long message!
-
Oct 28th, 2009, 04:41 PM
#14
Re: how to use a Right click option?
Use the .SelCount property to determine if an item is selected or not.
-
Oct 28th, 2009, 05:17 PM
#15
Thread Starter
Fanatic Member
Re: how to use a Right click option?
How do i do that? Please explain, Thanks
-
Oct 30th, 2009, 01:24 AM
#16
Re: how to use a Right click option?
If .SelCount is greater than 0 then there is a selected item, otherwise none.
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
|