flareback Report post Posted November 9, 2006 I have a form that I'm make using Visual Studio with c#. I wanted to have a fade out effect, but it flashes when it starts and makes it look bad. Anyone know of a way around this? I've tried searching and everything I've read is people have a problem when fading in but not out. The program is for a tablet pc so i don't think many of you will be able to use the whole thing but the part dealing with the fade is below. and the whole thing can be found in a zip file here or I have created a smaller part with just the annoying part that flashes and doesn't require a tablet pc to run but does require visual studio 2005 here * Note to use the first version you must create a circle by drawing a circle which creates a nice pretty circle. Then do a ChevronDown gesture inside the circle. Then hit save to see it fade out. * Note to use the second version simply hit the save button to see it fade out. The methods for fading in and out are at the bottom. The top is setup for the form. I doubt just copying and pasting this into something will work as visual studio likes to add a bunch of other things, this is just what I wrote. /* * Author: Clay Johnson * Date: 07 Nov 2006 * Revised 09 Nov 2006 * * This Class allows the user to input text into the shape objects * code field. This is done by hitting the save button which then * hides() the form. */ using System; using System.Windows.Forms; using System.Drawing; namespace testFlash { partial class Form1 : Form { // ------------------------------------------------------------ private Button btnSubm; private TextBox txtbx; private Label lblText; // ------------------------------------------------------------ private Timer tmrOpac; private Double opacFact; // ============================================================ public Form1() { SuspendLayout(); // Textbox txtbx txtbx = new TextBox(); txtbx.Location = new Point(5, 350); txtbx.Size = new Size(445, 100); txtbx.Multiline = true; txtbx.WordWrap = true; txtbx.Anchor = ((System.Windows.Forms.AnchorStyles)( ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); // Label - Text lblText = new Label(); lblText.Location = new Point(0, 330); lblText.Size = new Size(455, 20); lblText.Text = "Write text above or type below"; lblText.Anchor = ((System.Windows.Forms.AnchorStyles)( (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom))); // Button - Subm btnSubm = new Button(); btnSubm.Location = new Point(380, 301); btnSubm.Size = new Size(75, 23); btnSubm.Text = "Save"; btnSubm.Click += new System.EventHandler(btnSubmClick); btnSubm.Anchor = ((System.Windows.Forms.AnchorStyles)( (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Bottom))); // Timer - Opac tmrOpac = new Timer(); tmrOpac.Interval = 40; tmrOpac.Tick += new EventHandler(tmrOpacTick); tmrOpac.Enabled = true; this.Opacity = 0; opacFact = .15; // Client Window ClientSize = new Size(455, 450); Controls.AddRange(new Control[] { btnSubm, txtbx, lblText }); Text = "PenFC - insert text"; MaximizeBox = false; ResumeLayout(false); }// end InsertText /* ------------------------------------------------------------ * Button Save * Takes whatever is in the text box and enters it into the * shapes text field and closes the window */ private void btnSubmClick(object sender, EventArgs e) { opacFact = -0.15; this.Opacity = 1; tmrOpac.Enabled = true; } /* ------------------------------------------------------------ * Timer Tick for Opacity * This function makes the window fade in and out of view */ private void tmrOpacTick(object sender, EventArgs e) { this.Opacity += opacFact; if ((opacFact > 0 && this.Opacity >= 1)) { tmrOpac.Enabled = false; } else if (opacFact < 0 && this.Opacity <= 0) { Application.Exit(); } }// end tmrOpacTick /* ------------------------------------------------------------ * */ }// end class TextInsert }// end namespace Share this post Link to post Share on other sites
romeo55 Report post Posted November 9, 2006 /bump for the almighty coding god, markie Share this post Link to post Share on other sites