locked
Fading a form out is not working RRS feed

  • Question

  • Not sure what is going on im running invoke. I have a database insert and upon save I want the form to fade out while I fade in another form.

    public partial class frmSimpleDataEntry : Telerik.WinControls.UI.RadForm
        {
    
            delegate void IncreaseOpacity();
            IncreaseOpacity iod;
    
            public frmSimpleDataEntry(Juvenile_Information_System_2._0.frmMDIRibbon parent)
            {
                InitializeComponent();
                this.MdiParent = parent;
                this.timer1.Interval = 005;
    
                this.Opacity = 1.0;
                
                
                
                iod = new IncreaseOpacity(DecreaseOpacity);
            }
    
            void DecreaseOpacity()
            {
                this.Opacity = this.Opacity - .01;
                if (this.Opacity < .05)
                {
                    this.Close();
                }
            }
    
     private void btnSaveMain_Click(object sender, EventArgs e)
            {
                CompleteSave();
            }
    
     void CompleteSave()
            {
                OJuvenile J = new OJuvenile();
                J.FirstName = txtFirstName.Text;
                J.MiddleName = txtMiddleName.Text;
                J.LastName = txtLastName.Text;
                J.Alias = txtAlias.Text;
                StringBuilder b = new StringBuilder();
                b.Append(txtFirstName.Text.Substring(0, 1).ToUpper());
                try
                {
                    b.Append(txtMiddleName.Text.Substring(0, 1).ToUpper());
                }
                catch
                {
                }
                b.Append(txtLastName.Text.Substring(0, 1).ToUpper());
                J.Initials = b.ToString();
                J.Address = txtAddress.Text;
                J.Age = (int)spnAge.SpinElement.Value;
                J.Eyes = cmbEyeColor.Text;
                J.Grade = cmbGrade.Text;
                J.Hair = cmbHairColor.Text;
                J.Height = txtHeight.Text;
                J.Phone = txtPhoneNumber.Text;
                J.Race = cmbRace.Text;
                J.Religion = cmbReligion.Text;
                J.School = txtSchool.Text;
                J.Sex = cmbGender.Text;
                J.Sisters = (int)spnSisters.SpinElement.Value;
                J.State = cmbState.Text;
                J.Weight = txtWeight.Text;
                J.Birthdate = dteBirthdate.Value;
                J.BirthPlace = txtBirthplace.Text;
                J.Brothers = (int)spnBrothers.SpinElement.Value;
                J.Build = cmbBuild.Text;
                J.City = cmbCity.Text;
                J.Complexion = txtComplexion.Text;
    
                csSimpleInsertQueries.CacheFirstProfile(J);
                timer1.Start();
    
    }
    
    private void timer1_Tick(object sender, EventArgs e)
            {
                this.Invoke(this.iod, null);
            }
    
    
        }

    Sunday, May 13, 2012 2:29 AM

Answers

All replies

  • Hi,

    in your timer_Tick method, simply call DecreaseOpacity(), so the opacity gets decreased every time the timer ticks. check also the interval of the timer. (But it also should work like you did it with the delegate, put a breakpoint to the timer tick event and check, if it gets excuted...)

    Regards,

      Thorsten


    Sunday, May 13, 2012 2:48 AM
  • ... I think the problem is, that the form is a MDIChild. For that, it will not work (because opacity only works for Top-level windows -> http://msdn.microsoft.com/en-us/library/aa984329(v=vs.71).aspx)...

    Sunday, May 13, 2012 3:02 AM
  • I see. So there is no way to fade out an mdi child form?
    Monday, May 14, 2012 2:15 PM
  • I see. So there is no way to fade out an mdi child form?

    I'm afraid so.


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Bob Wu-MT Tuesday, May 15, 2012 6:10 AM
    Tuesday, May 15, 2012 2:36 AM
  • Hi,

    you could, of course, remove the MdiParent object before fading, but this will cause a significant flicker issue when the form is repainted now as top level form.

    If the form is displayed just for a short time, you maybe could load it always at toplevel and take care of its position relatively to the Mdi Form (especially while resizing and moving the MdiForm). This way, you could fade it out...

    But you could maybe use a different animation like moving out and in the forms.

    Regards,

      Thorsten

    Tuesday, May 15, 2012 10:36 AM