Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Detect Right Click

I am looking for some simple code to detect a right click event when right-clicking a label.

Suggestions appreciated

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Automate To Detect A Left Mouse Click Without Using The Form Mouse Click Event
hello all ,How do I automate to detect a left mouse click without using the form mouse click event ?

Can Someone Help Me? {Detect Right Click}
I'm fairly new to vb and have one more step to finish my program. I'm trying to detect a right mouse click anywhere on the screen but I can't figure out how to code it. I'm looking at mouse_event and SetWindowsHookEx API's. I'm leaning towards SetWindowsHookEx, it seems, but I don't know how to use it. The examples seem to be really complicated. Can someone show me how to do this?

Detect Click On X
how do you detect when a user clicks on the X in the right upper corner???


How To Detect Line Click
I need to detect the user clicking on a line drawn with the line tool. I have attempted to use invisible image objects to detect a line click, but the click has to be too sensitive with an image box. Is there any other way aside from this, or 2d math to solve this problem?

Detect Right Mouse Click
Hi there,

i want to clear the clipboard whenever user right click on the mouse or the press the ctrl key.

However i do not want to do this for all my controls on the form. Is there anyway i can intercept the right mouse click or the ctrl key on a higher level.

The main purpose is to prevent the user from pasting data into my controls.

Detect Mouse Click
Anywhere at all. Not just on the form.

All I need to know is when the mouse is left clicked, that's all ;-)

I have tried the SetCapture method, but I can't seem to get it to work properly ...

Detect Click On Desktop !

Is a way or another to detect mouse click, mousedown or others on the desktop?

Thanks in advance.

Detect Balloon Click
Greeting and Salutations,

I can create the cool Balloon windows in the tray.... How can I detect when they have been clicked by the mouse?

Thanks for any assistance or direction.

Webbrowser + Detect Click
Hello all,

I have got a little program that creates a generic html page. I have got real links and some things that aren't links, but should trigger a query in VB to create a new webpage.

How do i detect if a certain text is clicked (i could create buttons for it) and how do i parse that information towards VB?



Detect And Disable Right-click
Just a quick and easy (I hope) question. I have a Form with a Web Control and I want to detect and disable the right click function. So first question is, how do you detect a right click and then how would you tell the web control to not do anything with it? This basically keeps people from viewing the source within the application.

Thanks in advance.

Detect Mouse Click !
I answered a question like this the other day. (At least it would do what you are looking for, but does require subclassing your window). Anyway, if you are interested, take a look at this thread

Hope this helps.

Detect A Right Click On A Combobox
Does anyone know how to detect a right click on a vb6 combobox?

Detect A Click On A Record?
I have a subform on a form that displays the records in the current recordset. I would like to be able to click on a record to edit it. When clicked the clicked record values will be displayed in text boxes or in one case the field is an item in a drop down list. When all of this is visible in the correct spots the user can make changes to some of the fields.

How can I tell which record on the subform was clicked?


Detect Mouse Click

I am making a 'usage' program that will do things like keep track of how long the computer is running, and how many times the mouse is clicked.
I already made the time-logging part of it, but I find any code which would detect a mouse click.

Any help would be great,

Detect Mouse Click

I need help writing a little VBA "coordinate detector", so that I can navigate my mouse to the proper place on my alien applications, Click it, and have a message box pop up with the coordinates. It sure would save a lot of time if I could replace my "Guess and Check It" coordinate detection method I use now.

I've included a bunch of detail below, just in case you need a larger perspective.

How do I detect a mouse click anywhere on the screen using VBA?



Here's the details:

I'm writing a little VBA utility that moves the mouse around the screen, clicks it, and executes things I can't do with a SendKeys command. All that works fine.

There's one little thing - finding the x an y coordinates of where I want to click is a big PAIN!

The following code will identify the coordinates:

x as Long
y as Long
End Type
Declare Sub GetCursorPos Lib "user32" (lpPoint as POINTAPI)
'Every so often do this:

Call GetCursorPos(v_coord)
MsgBox "X is " & v_coord.x & chr(13) & "Y is " & v_coord.y


The final thing I need is a way to detect a mouse click anywhere on the screen (over any window), so that my detector responds to my command. In other words, instead of "Every so often", I'd like "On Mouse Click".

How can I code that?

Tx again!

How To Detect Mouse Click Outside The Form
I want to add to my app a foot switch that emulates the center button of the mouse, fot that reason I need to detect the click or mouse up/down, without matter where the mouse pointer is.

If anyone know a way to do this please let me know...

Right Click RTF Detect For Custom Menu
When the user right clicks on an RTF box, I need to know whether they clicked on an image, OLE object, or text, so that I can select the appropriate right click menu to use.

Detect Click On Picture In MSFlexGrid
Hi there...

I need to create a grid that display column with a picture and text.
The picture lets say it a small clock and 1mm from it to the right the text starts, lets say "Wake up"

I want to catch a click event ON THE PICTURE ONLY AND NOT ON THE TEXT OR ALL CELL.

One way I found is to devide the picture and the text into two columns, but I couldn't find way to hide the grid line between the two columns to let it seems as one.

If someone have any idea how to do that I will realy aapreciate it.
One thing! I have to use the MSFlexGrid and cannot use other grid control.


How To Detect A Click On Web Browser Control?
hi everybody,

one new problem i couldn't solved after trying really hard.. i want to detect a click on my web browser control. when it detect that the user have click on the page, then it will let the user enter the main program. the code i think of is below.. but they dont work. actually it work but it enable the button as soon as the site load on the browser..

Private Sub Form_Load()
WebBrowser1.Navigate ("")
End Sub

Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
enterButton.Enabled = True
End Sub

so please help me....

How Do I Detect A Scrollbar Click In A Listbox
Hi team, how do I detect when a user slides or clicks on a list box's scrollbar?



Detect Mouse Click Anywhere On Screen?
I've created a simple "color picker" which allows the user to move the mouse anywhere on the screen and "pick up" a color under the cursor.

Right now, the user has to press the <esc> key to "grab" the color.

I'd like to be able to use a mouse click instead.

How can I tell when the user has clicked the mouse(left button) if the mouse is no longer in MY window (somewhere else on the screen) ?

If I can't use the mouse click, can I disable all mouse clicks until, say, the user presses the <esc> key?

Once the user has initiated the color "pick" process, I don't want them to be able to click on anything else until they have selcted a color.....

(Get what I'm rying to do?)


How Do I Detect A Mouse Click Anywhere In Windows?
i'm making Missile command for a school project.
i need to know if the user has click with the mouse or not, i don't care about the x,y becuase i have that part, the problem is that i have picture boxes upon picture boxes and if i put form_mouseclick, it will only trigger it when i click on the form... i have all kinds of pic boxes that they should be able to click on. is there a "user32" funcion i can use... i searched everywhere and can't find it.

Detect A ResizeForm Click (Not Just RESIZE!!)
I need to be able to detect when the user simply clicks on the border of my form. (Like when you reach the end of a window and it turns into the resize mouse icon).

Simply clicking the border does not activate the form's resize event, so I need to know what kind of message is sent when you just click on the border so I can subclass it.

Any Suggestions?

How To Detect A Mouse Click On A Wallpaper...
When ever I click on the wallpaper, I want a msgbox to show.


How To Detect The PictureBox On Click Events.
Does anyone know how can I detect a portion of the image is
being click? Whereby the image is created through
the BitBlt API function. My code is show below:

Option Explicit
Private Type Btn
xw As Long
xh As Long
xhDC As Long
End Type
Private xButton(10) As Btn
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Sub Form_Load()
picMask.Move 0, 0, frmMain.Width, frmMain.Height
xButton(0).xw = picButton.Width / 2
xButton(0).xh = picButton.Height
xButton(0).xhDC = picButton.hDC
End Sub

Private Sub CreateScene()
BitBlt picMask.hDC, 0, 0, picMask.Width, picMask.Height, picVSideBar.hDC, 0, 0, vbSrcCopy
BitBlt picMask.hDC, 20, 210, picMask.Width, picMask.Height, picHSideBar.hDC, 0, 0, vbSrcCopy

'Create Exit Button
BitBlt picMask.hDC, 1, 20, xButton(0).xw, xButton(0).xh, xButton(0).xhDC, xButton(0).xw, 0, vbSrcPaint
BitBlt picMask.hDC, 1, 20, xButton(0).xw, xButton(0).xh, xButton(0).xhDC, 0, 0, vbSrcAnd

BitBlt frmMain.hDC, 0, 0, frmMain.Width, frmMain.Height, picMask.hDC, 0, 0, vbSrcCopy
End Sub

Private Sub Form_Unload(Cancel As Integer)
TmrDrawScene.Enabled = False
End Sub

Private Sub TmrDrawScene_Timer()
End Sub

I hope you can get what I mean. I want to detect the
PicButton_Click events. After the picture from the
PicButton (PictureBox) is being merge with others picture from picVSideBar (PictureBox).

Again, it is we must always set the ScaleMode to Pixel? can
we set it to others like Twip or Milimeters.

Thanks for you feedback.

How To Detect The Mouse Click Out My Application
i writing a program in vb to detect the mouse down,up and move. in my app i can detect it but outside . it there anyway i use api command to send a message to my application that the mouse is down


How To Detect Mouse Click In A Circle
I am trying to create a user control that draws a circle and when the user clicks in the control I can detect where in the circle the user has clicked and then perform an action based on the coordinates. I have created a button which inherits from a user control and drawn a circle in it, however it still acts like a square button when the user clicks on the button.

I though I could use the square button and work out if the mouse point was within the radius of the circle and so ignore clicks on the button that were outside my cirlce. However I coulnd't get a consistent value from the screen coordinates (after translating them into client coordinates) to do this? This could be down to me changing where the control is displayed within my form?

Please can anyone let me know if I am heading in the right direction or if i am barking up the wrong tree?

Detect A Random Click - Resolved -
Hi there!!!

  I'm so stupid!, first I asked how to "generate" a click... Now, I want to "get" a click. I want my program to recognize when the user does a click anywhere in the screen... how?!, plz help me! cya!

Bye!!! Pol1
- trying to make the world graphically better -

Edited by - Pol1 on 6/2/2004 8:07:37 AM

How Can I Detect Mouse Click And Button With Api?
Can anyone please help?

I want to detect the mouse click and button number within a mousemove event and not in its own event.

What it is, im using Waty Thierry's tray icon code (avaliable all over the net & that uses a picture box as a tray icon, however mousedown/up dont work from the tray icon, but mousemove does, so i need to somehow detect the mouse down inside the mouse move event..

Does anyone have any ideas?

thanks in advance

How To Detect [click/access To] Form?
hi all

anyone knowing that how to detect the form is being click/access by user? my purpose is to anaylst how frequent the user access the form in the program.

Please help/advise.

Detect External Button Click On Msgbox
I wanted to close the msgbox by clicking the 'ok' using the external button. Anyone can help???? need it urgently thanks alot!!!!!!!!!!

Detect Double-Click On External Program
I am trying to detect a double-click on an external program but the following is not working.

Timer1.interval = 1

Option Explicit

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_RBUTTONDBLCLK = &H206

Private Sub Timer1_Timer()
If GetAsyncKeyState(WM_LBUTTONDBLCLK) Then MsgBox GetAsyncKeyState(WM_LBUTTONDBLCLK) & " Left Button Double-Click"
If GetAsyncKeyState(WM_RBUTTONDBLCLK) Then MsgBox GetAsyncKeyState(WM_RBUTTONDBLCLK) & " Right Button Double-Click"
End Sub

I found from this post.

To Detect Double Click On Desktop Icon
I need to detect when a user double clicks on the Internet Explorer icon seen on the desktop.After detecting the double click event i need to run an.exe file on the double click event.Do i need to use the function mouse_event or any other Windows XP API?

Detect Keypress Under Label Click Event
Hi all..

i have a label, i want to make if a click to this label together with Ctrl+W will do to do that in VB?

Detect And Stop Mouse Click Anywhere On Screen?
I'm currently using this code to detect a mouse click any where on screen and retrieve the pixel color underneath:

Dim sTmp As String
Dim lColor As Long
Dim lDC As Long
lDC = GetWindowDC(0)
Call GetCursorPos(tPOS)
lColor = GetPixel(lDC, tPOS.X, tPOS.Y)
' sTmp = Right$("000000" & Hex(lColor), 6)
inputtext.Text = lColor
tester = GetAsyncKeyState(vbKeyEscape)
If tester And &H8000 Then
Timer1.Interval = 0
Timer1.Enabled = False
End If

My question is: how can I also stop the mouse click from executing?

I have a 'color picker' program so the user can select any color on-screen, but when they click to select the pixel, the click changes Focus, or selects what's underneath, etc.

I want the pixel color, but not the mouse click....

Shapes Runtime Created/detect Click
Can anyone help please?

I am drawing 5 shapes onto a page and want to draw a rubberband line only if user has clicked into shape requested. After identifying that user has clicked into each shape only then proceding to continue the rubber line to next shape. End result is drawn polygon. In a mess as you will see - code below for mouseup & mousedown functions.

clickMouseX = X: clickMouseY = Y ' initialise mouse start click

Jacqui (Beginner)shape click detection

Detect Shift+left Mouse Click
how would I detect if any shift button and the left mouse button has been clicked anywhere on the desktop?

How To Detect Item Chosen In A Right Click Context Menu?
When you right click on a textbox, you get the cut,copy,paste, and delete context menu. How can I detect which of these choices was selected?
I need to create a text validation on what action was taken, but validation only happens when you move off the textbox. So if a user should close the app or refresh the app, I can detect what action was taken and validate it.

Detect Refresh Button Click In Internet Explorer
I am wondering if there is anyway to detect refresh button click in Internet Explorer in ASP.


How To Detect A Click Event On Embeded Image Inside An Activex Control.
Hello All,

I need some help figuring this out. I am developing an ActiveX control that contain an array of multiple image boxes embedded inside a windowless transparent form (container). Based on property settings at design time, only one imagebox is visible, and all others are set to be invisible. I have a method (property) set in the control that decides which image is going to be visible. This is settable during a standard VB exe project development, and at run time via user selction. When I compile the OCX and use it to on a standard VB EXE project, I don't have an option available to write code for an Image click event. Only events available are control got focus, & lost focus etc. How do I go about adding the Image click event (to the Visible Image) inside my control?

Do I have to implement another method/event within my Activex control? If I did that, how would I then pass the name of the caller (name of the form where the control click was initiated) in to my activex event, and have the activex report back to the "SAME" calling form during run time?


Is It Possible To Detect A HTML Form On A Remote Site, And Click The 'submit' Button?

Lets say there is a form which would be called through VB, etc, etc, I have that part working fine.

What I essentially want, is when They user clicks submit on the VB Application, it will somehow locate the submit button, and click it.

I cannot use Exact X/Y Coordinates, because they change (Long story).

Is there any possible way to do this?

There are also two buttons, Reset and submit, so I would only need the Submit one, obviously.

Detect SMTP Server And Detect E-mailaddresses From My MSN Messenger Contactlist.
does anybody know how I can make a program that automaticaly sends an e-mail to my full msn list ...

I allready know how to send E-mails ...

But I don't know yet how to get a list of all the e-mailadresses of your msn messenger contactlist.

And I also have a problem with automatically detecting the SMTP-server. (If I want to E-mail something using Visual Basic ... I always need to set my SMTP-server and I don't like that anymore. There should be a way to automatically detecting it)

Making Right-Click In A ListBox Select An Item Exactly Like The Left Click.
Heres a start:

Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
'Place code to select the item
End Sub

I need help where the comment is. Thanks

Telling The Difference Between A OK Click And A Cancel Click On A Common Dialog Box..
When I load a mp3 file into my MMControl, it should then go and get the ID3 tags from it. But, I have a common dialog box so the user can specify what file they want to open. Now when they click the Cancel button it gives me an error because it's trying to get the ID3 tags from a file that blank filename.

To make a long story short: How do I tell when a user clicks the cancel button instead of the OK button on a File Open common dialog box.


Right-click Menu And Sending Left Click To Item
Can anyone tell me how I can use insert a right-click menu into my program so that when the user has selected a file (in a file list) and right-clicks, a menu appears at the location of the mouse pointer. I aleady know how to use the PopupMenu function to show a menu as I suppose that will need to be used, I just don't know how to capture a right-click mouse event and also use the position of the mouse pointer to show the menu.

Thanks in advance!

Single-click Vs. Double-click On Listview
Hey gang, can you help me on this one?
In my listview, if the user clicks an item, I basically don't want to do anything (the item that they clicked will be the current "SelectedItem" which can be used when needed).
However, if they double-click an item, I want that to act as a "shortcut" to an Update command.

Bottom line - how do I manage both single and double-click events?

Catching Right-click Or Double-Click In Excel

What I want to do is open a VBA form (already developed and in my VBA project) when the user right-clicks or double-clicks a cell on a worksheet.

I cannot find any way to trap those events in MS Excel 97. I'm sure it can be done, any suggestions?



How Do You Make The Mouse Click/dbl-click Outside Of A VB Form
How do you make the mouse click/dbl-click outside of a VB form, like on the desktop? In otherwords how can I make the mouse click on desktop icons and/or start menu applications?

Copyright 2005-08, All rights reserved