flynn Posted March 23, 2006 Posted March 23, 2006 It is my understanding that in order to get an Icon to display in the system tray, I need to use the NotifyIcon. Using the code below, I can get my application to work similar to other tray apps. I say similar in that when I click the "Close" button, the app will minimize, but instead of minimizing to the tray (like MSN messenger with the animation), my app minimizes just above the "Start" button. Is there a way to get the animation to go to the system tray? To get around this, I hide the app first, then minimize so you don't even see the minimize animation. private void Form1_Resize(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) this.Hide(); } Quote
Jay1b Posted March 23, 2006 Posted March 23, 2006 From memory, (i havent done this for about 2 years). You need to hide it, which is was your doing. Quote
Cags Posted March 23, 2006 Posted March 23, 2006 (edited) I don't know exactly how Microsoft achieved this result in MSN Messenger, but if I was going to try and achieve this result myself I do try the following steps. 1. save size / location of the form 2. set the client size to 0,0 3. start a loop - move form slightly closer to toolbar - check if at toolbar - if not loop 4. hide form 5. reset size and location (so its right for when its restored) As I say this is completely theoretical, it is possible there is a built in feature for doing this, but without research, this is the approach i would take. EDIT:- Whilst I was looking on CodeProject for something completely unrelated, I came across an article on doing this. Its done in c++, but perhaps might give some pointers to help you. http://www.codeproject.com/shell/minimizetotray.asp Edited March 23, 2006 by Cags Quote Anybody looking for a graduate programmer (Midlands, England)?
Leaders snarfblam Posted March 23, 2006 Leaders Posted March 23, 2006 There is a Windows API function (DrawAnimatedRects) that will draw the minimize animation from anywhere you want to anywhere you want. Once you have that, you can do the animation, then call the Hide method on the form. I recommend checking the user's settings before you show the animation for the sake of those who have the window maximize/minimize animations turned off. Quote [sIGPIC]e[/sIGPIC]
Cags Posted March 23, 2006 Posted March 23, 2006 Just to clarify, the link I posted follows the method that Marble describes. As I mentioned previously the code is in c++, but it explains the method if not the exact code. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.