Color Palette (VBA/Excel), "right mouse" event for Frame objects

Asked

Viewed 845 times

0

I found no reference to the event that is triggered by the right mouse button on a Frame object. With the event of the left mouse button select the desired color, this is working, however, with the right button I would set the custom colors dynamically, but I did not find the desired event to do this.

The idea is to change the background color of colors to be customized (it already works too) by right-clicking a Frame object. Each frame represents an additional color to customize (these are the sixteen blank areas of the lower palette).

Paleta de cores

There is corresponding event by right-clicking the mouse to the Frame object?

UPDATING

See the solution found in the Answer below

  • Shows the screen where you are programming. Shows a print

  • Hi Eduardo, I don’t understand. This palette is already an edited Printscreen that I put in an image object. By mouse move (x,y), I know the region the cursor is, and with the click which color was selected. What I want is, in the same way, to right-click on one of the sixteen blank frames, to open another image that I have that uses the RGB according to the coordinates x and y (showing several colors dynamically) and to click, it returns the chosen color (this already works)..

1 answer

0


SOLUTION

I found the way to control the right mouse click under a frame (serves other objects as well).

You must use the event Mousedown or Mouseup, for example (after creating the Frame1 on the form):

Private Sub Frame1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If Button = 2 Then MsgBox "Botão direito do mouse"

End Sub

In this link appears the values corresponding to each mouse button, and the sum can be combined to know if more than one has been triggered at the same time:

https://msdn.microsoft.com/pt-br/library/office/gg278486.aspx

A detail, see the name of the parameters created within the event you are manipulating (look at the arguments of the event), because there are differences of what is reported in website, since the description is for form events (fm), for example, the variable fmButton is indicated to capture the value of the mouse button triggered in a form, but in the event of the frame the variable is simply Button.

That’s it!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.