|
-
Mar 20th, 2013, 02:22 PM
#1
Thread Starter
Frenzied Member
[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?
-
Mar 20th, 2013, 02:44 PM
#2
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:
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Left = Form1.Left + Form1.Width - Me.Width
Me.Top = Form1.Top + Form1.Height - Me.Height
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!
-
Mar 20th, 2013, 03:59 PM
#3
Thread Starter
Frenzied Member
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.
-
Mar 20th, 2013, 05:13 PM
#4
Re: some kind of tooltip with opacity
 Originally Posted by phpman
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:
Public Class Form1
Dim f As New Form
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
f.BackColor = Color.Red
f.Show()
End Sub
Private Sub Form1_LocationChanged(sender As Object, e As System.EventArgs) Handles Me.LocationChanged
f.Top = Me.Top
f.Left = Me.Right
End Sub
End Class
Paste the above into a new Windows Forms project, run it and move the gray form.
-
Mar 21st, 2013, 07:37 AM
#5
Re: some kind of tooltip with opacity
A tiny but important improvement to line 7 of Niya's code:
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
-
Mar 21st, 2013, 10:19 AM
#6
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|