Hello , i would like to add a hover text when i have my mouse in fronnt of the image , not from the properties because i want to add some code on it .. it could be like 150x40 or more or less in size .. i would like to make the hover label in code and not visually because i want to add hovers in many pictures

Regards.

if you need more clarification please reply.

Recommended Answers

All 17 Replies

You need to determine the X and Y coordinates of your mouse and let the pop up message (hover label) appears where you choose in your code by using these coordinates.

I already made it hover with a Panel but my problem is that i have to put way too many panels in my form as disabled and then enable them and put the coordinates to show when i have my mouse in front of the picture .. the problem is that i want to restrict all these panels and it could be better to do it code-side if its possible


basically i want to create a panel or label with 2-3 lines of text but not from the properties since i want to add some code for some other stuff in it and make it hover on a picture

Try to write a function then that will control the label in one hover button only. Call the function every time you want to show the button. This will eliminate all the others and obviously will speed up your app as well by having only one. You can also manipulate the labels properties from the function as in "if the user's mouse is there then the label pops, else it scrolls etc.

I have done this with a custom message box because I do not like windows message style at all. I have only one form with three labels and an image which calls to my function every time I need to show a message box to the user in an application with 163 forms.

What i would like to do is : have a panel disabled by default and then create a label with my own size and put it inside the panel with both the same size and put the panels location to hover onto the picture

is it possible?

I think we need to get back to basics first. You refer to a panel. What does this panel do? What is the label suppose to do in the app when hovered over the panel. Why do you need many panels, are they for different purposes, or can it be controlled through one panel?

Hi ,

my first idea was to create a panel and add inside a label with the text i want to hover on it ...

my second idea was only to create one label and when i have my mouse in front of the picture it will hover the label

the label is suppose to hover when i have my mouse in front of the picture and have some code on it for example the text i want to add and if i have clicked on the picture 1 time it will have the x message but if i click 2nd time it will have the y message on it.

I hope this post is more specific

It does. Write your function first containing the panel. Again, only use one panel. Load whatever picture via code to this panel. write a different function for the label to show when hovering. In other words, if panel contains a picture of 1, then hover will do this, else hover shows over panel with picture 2. use select case to cover all panel loads. Sorry I'm new from vb6 (which i'm very good in to .net) Try and use all your scenarios into two functions, one for the panels and two for the labels or hover button. Thats where OOPS come from, even in .Net

thanks for the help , i will try it and reply as soon as possible.

See if this helps.

'// Prerequisites: 1 Label, 3 PictureBoxes.
Public Class Form1

    Private myClickCounter As Integer = 1
    Private myCursorLocation As Point

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label1.Visible = False
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles PictureBox1.Click, PictureBox2.Click, PictureBox3.Click
        Select Case sender.name
            Case "PictureBox1"
                Select Case myClickCounter
                    Case 1 : Label1.Text = sender.name & " clicked 1 time."
                        myClickCounter += 1
                    Case 2 : Label1.Text = sender.name & " clicked 2 times."
                        myClickCounter = 1
                End Select
            Case "PictureBox2"
                Select Case myClickCounter
                    Case 1 : Label1.Text = sender.name & " clicked 1 time."
                        myClickCounter += 1
                    Case 2 : Label1.Text = sender.name & " clicked 2 times."
                        myClickCounter = 1
                End Select
            Case "PictureBox3"
                Select Case myClickCounter
                    Case 1 : Label1.Text = sender.name & " clicked 1 time."
                        myClickCounter += 1
                    Case 2 : Label1.Text = sender.name & " clicked 2 times."
                        myClickCounter = 1
                End Select
        End Select
    End Sub

    Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles PictureBox1.MouseEnter, PictureBox2.MouseEnter, PictureBox3.MouseEnter
        Label1.Visible = True
        PictureBox1_Click(sender, e) '// if you want to reset the clicks.
        Label1.Location = New Point(myCursorLocation.X + 5, myCursorLocation.Y + 5) '// offset label.
    End Sub

    Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles PictureBox1.MouseLeave, PictureBox2.MouseLeave, PictureBox3.MouseLeave
        Label1.Visible = False
        myClickCounter = 1
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        myCursorLocation = e.Location
    End Sub
End Class

thanks it seems to work pretty well , with some modifications it will be perfect for what i want to do .. thanks both for helping me out!

Only a pleasure. Happy coding.

Hi , it works pretty well now i came up with another problem , nothing to do with previosu stuff.


I have the label on the code and i want to have 3 lines on it , i know how to change lines , i want to have my first line on white color and bold , next line normal white and third line on yellow normal .. im still searching how to change the color for each line .. would love to get a help over here

Regards,
Steve.

xVent, you will unfortunately have to start a new thread with your new question because this is now a solved thread, sorry bud.

As to your question, manipulate the strings, in other words, count the first line of text in the label, make it white and so on. I know in vb6 we used the Mid function, Instr function etc. Not sure about .Net though, but I'm sure you will find a sample if you search through Google - string count in .net for example.

thank you , ill create a new topic while ill be searching for a hopefully solution, ill try what you said and see how it goes.

Thanks a lot again.

thanks for the links, btw days now i was trying to access dreamincode but always the page doesnt load , seems the site is broken or ? ... can u access dreamincode?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.