Maximize and Restore bux fixed

Jun 18, 2009 at 3:39 PM
Edited Jun 18, 2009 at 3:40 PM

Hi, a fix a bug of change the type of RibbonCaptionButton that was no change bettwewn Maximize and Restore.

On RibbonCaptionButton.cs implements this methods:

internal override void SetOwner(Ribbon owner) {
       base.SetOwner(owner);

      
if (this.CaptionButtonType == CaptionButton.Restore || this.CaptionButtonType == CaptionButton.Maximize) {
           
if (owner != null && owner.FindForm() != null) owner.FindForm().SizeChanged += new EventHandler(OwnerForm_SizeChanged); 
       }
}

private void OwnerForm_SizeChanged(object sender, EventArgs e) {
      
switch ((sender as Form).WindowState) {
            
case FormWindowState.Maximized: SetCaptionButtonType(CaptionButton.Restore); break;
            
case FormWindowState.Normal: SetCaptionButtonType(CaptionButton.Maximize); break;
      }
}

And in Ribbon.cs move this section of code on constructor:

 _MinimizeButton.SetOwner(this);
_MaximizeRestoreButton.SetOwner(this);
_CloseButton.SetOwner(
this); 

 To a new override method of InitLayout(), like this:

protected override void InitLayout() {
    
base.InitLayout();
     _MinimizeButton.SetOwner(
this);
     _MaximizeRestoreButton.SetOwner(
this);
    
_CloseButton.SetOwner(this);
}

because on contructor the method FindForm() was returning null.

Cya

 

Developer
May 16, 2013 at 12:26 PM
Hi, a new version of Ribbon is released. Please visit the new site for latest fixes, releases, information and downloads.
New site: http://officeribbon.codeplex.com/