Results 1 to 6 of 6

Thread: [RESOLVED] some kind of tooltip with opacity

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Resolved [RESOLVED] some kind of tooltip with opacity

    I have a regular form and if a certain condition comes up I want to pop up a small form/tooltip/message to the user. My first thought was to do a borderless form and have its opacity set to 80% and show the form when the condition arises. This works, but if I move the main form the message form stays put. I would like it better to show the message on the main form but I don't know what control to use that I can set opacity and some text on. What would be the best way to do this? I was figuring to show the message toward the bottom of the main form but still be able to see the forms contents behind the message. Hence why I want opacity.

    Any suggestions?

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: some kind of tooltip with opacity

    You can set the new form's location relative to the main form if you set it's left and top properties in its FormLoad, eg. to open the new form in the bottom right corner ....

    vb.net Code:
    1. Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    2.         Me.Left = Form1.Left + Form1.Width - Me.Width
    3.         Me.Top = Form1.Top + Form1.Height - Me.Height
    4.     End Sub
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: some kind of tooltip with opacity

    cool, thank you, better than using center screen so far.

    So, you can't think of anything that would follow the main form? Not that it moves much but always that chance.

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: some kind of tooltip with opacity

    Quote Originally Posted by phpman View Post
    So, you can't think of anything that would follow the main form? Not that it moves much but always that chance.
    You can use the same principle as follows:-
    vbnet Code:
    1. Public Class Form1
    2.  
    3.     Dim f As New Form
    4.  
    5.     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    6.         f.BackColor = Color.Red
    7.         f.Show()
    8.     End Sub
    9.  
    10.     Private Sub Form1_LocationChanged(sender As Object, e As System.EventArgs) Handles Me.LocationChanged
    11.         f.Top = Me.Top
    12.         f.Left = Me.Right
    13.     End Sub
    14. End Class

    Paste the above into a new Windows Forms project, run it and move the gray form.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: some kind of tooltip with opacity

    A tiny but important improvement to line 7 of Niya's code:
    Code:
                  f.Show(Me)
    That makes Form1 the Owner of f (alternatively set the Owner property). If you don't do it, the "tooltip" could get lost behind other forms when the user changes context. And it will be left on the screen when Form1 is minimized.

    (Now if I had a penny for every time I have had to recommend the Owner property, I would be able to afford a sandwich by now.)

    BB

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: some kind of tooltip with opacity

    Thanks guys, I think this will do the trick
    Code:
    Private Sub Form1_LocationChanged(sender As Object, e As System.EventArgs) Handles Me.LocationChanged
            FrmTempAlert.Left = Me.Left + (Me.Width - FrmTempAlert.Width) / 2
            FrmTempAlert.Top = Me.Top + (Me.Height - FrmTempAlert.Height) - 60
            
    
        End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width