I don't know what you mean. There are four effects supported by AnimateWindow: Roll, Centre, Slide and Blend. All four are supported on both loading and closing.Quote:
Originally Posted by danasegarane
Printable View
I don't know what you mean. There are four effects supported by AnimateWindow: Roll, Centre, Slide and Blend. All four are supported on both loading and closing.Quote:
Originally Posted by danasegarane
Dear Jhon,
I want to show the form like a blend. Is this posible ?
Yes it is, and the very first paragraph of the very first post of this thread explains how.Quote:
Originally Posted by danasegarane
I trying this method.
vb Code:
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.m_activeDB = New FormAnimator(Me, _ FormAnimator.AnimationMethod.Blend, _ FormAnimator.AnimationDirection.Up, _ 1000) Dim mnumanger As New SystemMenuManager(Me, False, SystemMenuManager.MenuItemState.Disabled) End Sub Private Sub Form2_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing 'Close the form by sliding down. Me.m_activeDB.Direction = FormAnimator.AnimationMethod.Blend End Sub
This Gives a nice effect during the closing of the Form.But it not showing the
efffect during form load event.
Dana
1. I just tested the following code:and it worked fine for me.vb.net Code:
Public Class Form2 Private m_activeDB As FormAnimator Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.m_activeDB = New FormAnimator(Me, _ FormAnimator.AnimationMethod.Blend, _ FormAnimator.AnimationDirection.Up, _ 1000) End Sub End Class
2. You don't blend a form in any direction so there's no point using the FormAnimator constructor that takes a direction.
3. In your Closing event handler you're assigning an animation method to a property that is supposed to take an animation direction. Again, blending isn't done in any direction so setting one is pointless, but if you were going to set one you should at least use a value of the appropriate type. If that code doesn't throw a compilation error then you must have Option Strict turned Off. I suggest that you rectify that immediately.
nice work :afrog:
nice work jm...:thumb: :thumb: :thumb: :thumb:
[Basking in the glow of praise]Thank you, thank you.[/Basking in the glow of praise] ;)
Great work on the toastform class jmc! (1 more reason to bask in the glory of praise! :p )
But theres a little problem that i have encountered using this toastform.
I am using VBExpress 2005 (.NET 2.0).
All seems to be well till I try to declare and Show the form from a new thread. When I do that, the form is visible till the duration of the animation, but after that the form simply disappears. I even tried to debug it while setting a breakpoint at Me.Close() and lifeTimer.Tick, but the breakpoints are never hit! :rolleyes: . I have simply no idea where the form goes after it disappears. Two things I know for sure: The form never closes itself,and the lifeTimer.Tick event doesn't fire.
Some threading issue perhaps? or the Timer?
It seems that the Windows.Forms.Timer sticks to the UI thread only. So, the Timer.Tick event may not fire at all.
But on the other hand, the System.Timers.Timer is said to raise the Elapsed event on new threads from the ThreadPool every time it is raised. So, it throws an InvalidOperationException: "Cross-thread operation not valid: Control 'PopupNotifierForm' accessed from a thread other than the thread it was created on.", citing the (cross-thread) call to "Me.Close()" as invalid. Delegation didn't help either. That throws a NullReferenceException: "Object reference not set to an instance of an object".
This is the code I am trying to delegate the Me.Close method.
VB Code:
Public Delegate Sub FormCloseDelegate() Public Class ToastForm '... '... Public Sub FormClose() If Me.InvokeRequired Then Me.Invoke(New FormCloseDelegate(AddressOf FormClose)) 'Throws NullReferenceException: "Object reference not set to an instance of an object" Else Me.Close() End If End Sub End Class
Even Threading.Timer using the TimerCallback throws the same exception.
VB Code:
Private LifeTimerCallback as New TimerCallback(AddressOf lifeTimer_CallbackMethod) Private Sub ToastForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '... Me.lifetimer = New Threading.Timer(Me.lifeTimerCallback, Nothing, lifetime, 0) End Sub '... Private Sub lifeTimer_CallbackMethod(obj as Object) Me.FormClose() 'If I use Me.Close instead, it throws a InvalidOperationException: "Cross-thread operation not valid: Control 'PopupNotifierForm' accessed from a thread other than the thread it was created on." End Sub
Am I doing anything wrong or is it just the way these things work? Is there no way to make the form work normally if instantiated and called from new threads?
Any help will be truly appreciated. :)
And jmc, THANX ONCE AGAIN FOR THIS BEAUTIFUL SOLUTION!!! :thumb:
Thanks for your code Jim. It's really great! When using the FormAnimator class everything works great. The only problem is that when my date time picker is displayed it's viewed as sunk down in the form and it lost it's blue border like my combo box has. Do you have any idea on how to fix that problem? is it a property on my date time picker? I tried to look for the border property on the date time picker and realized that wasn't there. Any help will be appreciated.
If you don't use the FormAnimator does that not happen? It sounds like it's not getting drawn using visual styles for some reason. If you minimise the form and restore it does it get drawn properly then?Quote:
Originally Posted by Tim Hadley
Yes you are correct. If I don't use the Form Animator everything works fine. Also, when I minimize the form it goes back to the original state. I also have a drop down combo box right above the date time picker and once it is dropped over the date time picker and restored the date time picker goes back to the original state as well.
I can't tell you exactly why but the DTP is obviously not getting drawn using visual styles the first time. A workaround would be to handle the form's Shown event (assuming .NET 2.0+) and call the DTP's Refresh method to force an immediate repaint. I guess the DTP may not look right during the animation but that's the best I've got for you I'm afraid.Quote:
Originally Posted by Tim Hadley
Thanks! That seemed to work just fine after the form loads. I did the form' shown event and did a me.refresh and that took care of the date time picker being drawn right. Thanks for all your help!
You shouldn't call Me.Refresh. That will redraw the entire form, which is not needed. If you read my post again you'll see I said call the Refresh method of the DateTimePicker, not the form. If the DTP is all that needs to be repainted then that's all you should repaint.Quote:
Originally Posted by Tim Hadley
Has there been any updates/replacements to this code since 2006 and the advent of framework3.5 ?
The principles in this thread use the Windows API, which hasn't changed in XP at least. I don't know if there's anything new in Vista on this front. .NET 3.5 includes no new functionality that can replace the unmanaged code so everything would be exactly the same.Quote:
Originally Posted by Xancholy
Can you please tell me which posting number contains the most updated code ?
Whenever I update attached files in one of my CodeBank threads I always attach it to the first post and replace the old code, unless I have a specific reason to do otherwise.
Best practice. My only request would be to please include a sample image of toast in action... thanks
The whole point of this is the animation. A screen shot of an animation is just a little useless. Also, there's a fully working demo project attached for download. You just need to download, unzip, open and run. That's less than a minute's work to see a toast demo in all it's glory. If you'd like to take a screen of it you're welcome to, but I don't see it impressing too many people.Quote:
Originally Posted by Xancholy
I just ran this on Vista for the first time and the results were not especially inspiring. I guess it has something to do with Aero and the drop shadows around windows. Maybe there's a Vista replacement for the AnimateWindow API, or maybe the Slide animation just doesn't work properly on Vista. I must say, I can't recall any of my installed apps using that effect. The Blend effect works better but the drop shadow does disappear all of a sudden, making things less smooth than they ideally would be. When I have time I may investigate this further.
EDIT: Just did a quick search and saw several people asking about issues with AnimateWindow under Vista but no solutions. As such I can only recommend that you only use the Blend effect under Vista as the others produce unsatisfactory results.
Hey JM,
This is great, but it's not suiting my requirements exactly. I'm wondering if there's "easy" way to animate the window back to a particular point instead of just animating it as it's closed or opened?
Failing that I can set up my own functions to move the window with a timer and so on, but this is flawless so it's worth asking the silly question!
Cheers,
Scoota
This API is only for showing and hiding the window. You'll have to do as you suggested and use a Timer to move the form around while it's visible.Quote:
Originally Posted by scootabug
Too easy, I'm already on my way. Thanks for the quick response!
Are these classes compatible with VS2008? When I loaded the demo project there were a lot of errors to correct, mostly replacing the 'Me.' with the form names. But it did run...
Those are not errors, they're warnings.
jmcilhinney specifies that he created the project in VS2003 but there's no reason why it wouldnt work in 2008.
Why would you replace the 'Me' keyword with the form name? 'Me' already refers to the current class (the form in this case) that it needs to.Quote:
Originally Posted by nbrege
Well in this case the warnings refer to shared members of the class, which "should" be accessed through the class, not an instance of the class.
Those warnings were due to referring to constants via the current instance. When I wrote that code I didn't know that constants are inherently Shared and 2003 didn't flag it. I will be rewriting this code sometime soon. It will still work as is though.
I've removed the original attachments and added new ones. The solution attached to the first post was rewritten in VB 2005 with a few changes. The attached class file is from that solution, if you just want animation without the toast feature.Quote:
Originally Posted by jmcilhinney
This works great and almost perfectly for what I need to do.
Scenario:
I put a 15 second countdown timer on the initial form that activates the toast window. Works beautifully!
Same setup but now when I run the project I move focus to notepad and typing continuously through the timer and through the toast window, meaning it did not steal focus. Again, beautiful!
Same setup but now I minimize the application as soon as I run it, and the toast form doesn't show up. I did set the toast form to always be on top to solve one other problem, but I doubt that affects this.
That's a good point. All my original tests were conducted with the demo app being the active app. I tried using a Timer to spawn the Toast form and it did often get displayed behind another window. I just set the form's TopMost property to True and that fixed it.Quote:
Originally Posted by Minolwen
How can we ensure that the toast form appears within the bounds of the primary monitor in a multiple monitor setup ?
It already does that for itself, although you'll have to make sure that the StartPosition is set to Manual. I thought it was originally but I just downloaded the project and it's not, so either I forgot or that's a VS glitch.Quote:
Originally Posted by Xancholy
Code:Private Sub ToastForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Display the form just above the system tray.
Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width - 5, _
Screen.PrimaryScreen.WorkingArea.Height - Me.Height - 5)
'Move each open form upwards to make room for this one.
For Each openForm As ToastForm In ToastForm.openForms
openForm.Top -= Me.Height + 5
Next
'Add this form from the open form list.
ToastForm.openForms.Add(Me)
'Start counting down the form's liftime.
Me.lifeTimer.Start()
End Sub
First thanks for the awesome code.
Can you please tell me why my code is not working for loop? i have a list box. in which there are many items. and i use regular expression to match those values. and if there are match then the toast should pop up.. The thing is it does pops up but only for last item / match... even i used it in timer.. i want a popup for each match.. here is my code:
VB Code:
Dim myHTMLstring As String Dim mywebclient As New Net.WebClient myHTMLstring = mywebclient.DownloadString("www.somesite.com") TextBox18.Text = myHTMLstring Dim myMatches2 As MatchCollection Dim myRegex2 As New Regex("(?<=ON >> )[a-zA-Z0-9\. \$%?!&\#(|)_@^£’;+/:\,^=–]+") Dim t2 As String = _TextBox18.Text myMatches2 = myRegex2.Matches(t2) Dim successfulMatch2 As Match For Each successfulMatch2 In myMatches2 If ListBox4.Items.Contains(successfulMatch2.Value) Then TextBox19.Text = successfulMatch2.Value Timer6.Enabled = True ListBox4.Items.Remove(successfulMatch2.Value) Else End If Next
ANd the timer
VB Code:
If Timer6.Enabled = True Then Static sliceCount As Integer = 0 sliceCount += 1 Dim slice As New ToastForm(Me.rng.Next(2000, 4000), sliceCount & ": " & TextBox19.Text & " Is Online") slice.Height = Me.rng.Next(100, 100) slice.Show() End If Timer6.Enabled = False
And yes how to change the width of the popup? :D
If your UI thread is busy executing the loop then it can't execute the second code block. Each thread can only do one thing at a time, so the Timer's Tick event won't be handled until the loop is finished.Quote:
Originally Posted by webb315
I don't really understand why you're using a Timer at all but, regardless, your issue really has nothing to do with the topic of this thread. I suggest that you start a new thread in the VB.NET forum. Explain what you're trying to achieve and those with the time, knowledge and inclination can help you find the best way to achieve it.
Thanks for this. This is a great way to notify people. I used it to show that there is a new release on my codeplex project so users can get the latest and greatest.
Employee Scheduler
hi, jmcilhinney. you know I try to log in my account that I can't open long ago.
because I just start again with vb.net. and I want to say that you are make me smile. you are imagine :)
Thank for your smooth slide code :)
This is pure awesome! Exactly what I was looking for...stacked notifications.
This base saved me tons of time so for that, many thanks!
Since I first grabbed this I made a bunch of changes:
Support to pass two text messages fields
Support to pass an image resource (icon)
Due to Win7 I had to kill the glass as the effects were just odd, so I have a single little box then of course had to create my own close button
Added a mouse over function that stops the timers. Mousing out starts them again.
Added some click options to take me directly to the item in question.
So far my users absolutely love the upgrade as do I!
@JEmlay, glad to know that it's been put to good use. If your code is proprietary then I understand but, if possible, it might be nice to post your extensions here to help others.
It's proprietary but I'll update the test I created from your project once everything is done. That way myself and my team will always have it around to put in new projects.
As promised here's my changes. I removed the passing of the icon and opted to instead simply change the form background globally based on my needs. Those different small backgrounds include whatever image changes I need. This was easier since a couple notifications required a couple images.
In this change up:
Support to pass two text message fields.
Killed glass and opted for simple square-ish form due to Win7 (possibly Vista as well) goofing it all up. I also hard coded fade in and out as slide and roll were also goofed up by Win7. There might be some extra code to clean up that are roll and slide specific.
Added a mouse over function that stops the timers. Mousing out starts them again.
Added a click option to handle the notification item in question. Simply click the notification.
Added exit button for no other reason then to remain consistant with other pop up notifications out there (Outlook, Trillian.....).
Enjoy and again, a million thanks to the author!
I am having problems with the popup. I use JEmlays' version. But my problem has nothing to do with the feature he added, so I guess this is a problem concerning the original version as well.
Okay so when the form pops up in the bottom right corner, then let's say I am browing the web. I have to minimize the webbrowser, in order to see the form. Because the form is like behind the webbrowser, or whatever program I am running. Is it possible to make it stay on the top regardless what I am doing ?
Never mind, I fixed the problem.
Add this to Form_Load in FormAnimator.vb:
Me.Form.TopMost = True
After almost 10 years later, I could still say that this is such a great contribution.
However, I'm facing some issues. I can only generate something like 12-16 toasts, after that Toasts do not show up at all.
They are set to TopMost.
Any ideas?
Thanks!
Fantastic example! Really taught me a lot! I do have one question though. Is there a way to make it so that each instance of the ToastForm doesn't create an entry in the task bar?
EDIT: NEVERMIND! :) I found a property that I hadn't seen before. " Form.ShowInTaskbar " LOL How easy was that?
inputbox or msgbox disapear sometimes. for example add this to the code
Sub errTest()
Dim Notification As New frmNotification(5000, "This is a test message " & variable, "This is a second text message to pass")
Notification.Show()
variable += 1
End Sub
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
errTest()
errTest()
errTest()
MsgBox("test")
End Sub
good job btw
regards,