Ribbon is slowing down application

Jan 20, 2010 at 4:45 PM

Hello.

The control is awesome, but I'm having some issues.

 

I have a multithreading WCF application that become extremely slow after I set the ribbon control in the main interface.

If I try to select some rows on my DataGridView, I notice the selection is made slower than my mouse can move, even if I move the mouse slow (just as a single example).

Also, if an exception occurs or if I just set a breakpoint in the IDE, all the system freeze (keyboard and mouse) for about 5 seconds and only after that I can go to the IDE to see the code.

More, if I minimize the program and go work on another applications, I can notice something wrong is running, because of milisseconds of mouse-freezing.

As a test, I removed the ribbon from the form, and everything run quickly again.

Do you know what can be happening?

 

 

Feb 7, 2010 at 12:20 PM

Hello,

I have exactly the same problem as you.

Have you found a solution?

Sincerely.

D. Detrain

Feb 7, 2010 at 1:32 PM

Not yet, unfortunately. I had to remove the Ribbon from my application, while this problem is running around.

May 6, 2011 at 2:37 AM

Anyone solve this yet?

Jul 13, 2011 at 6:51 AM

Seriously guys, this is like the best free Ribbon control in the market, but the performance issue was driving me NUTS. I wanted so badly to have that problem solved and I refused to give up such good component. So, I seemed to have found what was causing the problem. Yet, I'm not totally sure about the consequences of doing this, everything seems to be fine.

What happens is that this component installs a windows hook. If that doesn't ring a bell to you, remember that a windows hook tells Windows to tell your application everytime a keyboard or mouse event occurs, but Windows keeps waiting for a response. So, if your application is running some kind of process, Windows keeps waiting for the control to respond and the mouse freezes.

If you want to try to solve this problem you just have to download the source code and add one line:

- Find GlobalHook.cs

- Find private void InstallHook()

- Add a return statement at the beggining of the method so nothing is done

That's it, just try it. It solved the problem for me and now the control works perfect for me.

Like I said before, I didn't bother to even check what's missing, I'm happy enough with the results and lazy enough to ignore it ;)

Further check is up to you guys!

Dec 13, 2011 at 8:52 AM
Edited Dec 13, 2011 at 8:52 AM

Hello everybody,

i had a similar problem, but only moving mouse on the caption bar of a ribbon form...

I solved it by removing a little portion of code.

Fix for slow mouse on the caption bar:

In Ribbon.cs find "protected override void WndProc(ref Message m)"

then remove this portion of code:

if (RectangleToScreen(caption).Contains(screenPoint) && !onCaptionButtons)               

{

Point p = PointToScreen(screenPoint);

WinApi.SendMessage(f.Handle, WinApi.WM_NCHITTEST, m.WParam, WinApi.MakeLParam(p.X, p.Y));

m.Result = new IntPtr(-1);

bypassed = true;

}

the only limitation is that the system do not recognizes the double click event on the caption bar and do not resizes the form when this event is raised.

Dec 15, 2011 at 11:40 AM

Solution found for bugs in previou solution :D

 
In Ribbon.cs find

protected override void WndProc(ref Message m)

 
then sobstitute the proc with this one including the variable declaration

private bool MouseOnCaption = false;

It allow Dobule Click on caption bar and drag the from when in normal mode;
 

private bool MouseOnCaption = false;
      protected override void WndProc(ref Message m)
      {
         //These are constant to send Drag instruction to base.WndProc;
         const int HT_CAPTION = 0x2; const int WM_NCLBUTTONDOWN = 0xa1;
         bool bypassed = false;
 
         if (WinApi.IsWindows && (ActualBorderMode == RibbonWindowMode.NonClientAreaGlass || ActualBorderMode == RibbonWindowMode.NonClientAreaCustomDrawn))
         {
            if (m.Msg == WinApi.WM_NCHITTEST)
            {
               Form f = FindForm();
               Rectangle caption;
               if (RightToLeft == RightToLeft.No)
               {
                  int captionLeft = QuickAcessToolbar.Visible ? QuickAcessToolbar.Bounds.Right : OrbBounds.Right;
                  if (QuickAcessToolbar.Visible && QuickAcessToolbar.DropDownButtonVisible) captionLeft = QuickAcessToolbar.DropDownButton.Bounds.Right;
                  caption = Rectangle.FromLTRB(captionLeft, 0, Width, CaptionBarSize);
               }
               else
               {
                  int captionRight = QuickAcessToolbar.Visible ? QuickAcessToolbar.Bounds.Left : OrbBounds.Left;
                  if (QuickAcessToolbar.Visible && QuickAcessToolbar.DropDownButtonVisible) captionRight = QuickAcessToolbar.DropDownButton.Bounds.Left;
                  caption = Rectangle.FromLTRB(0, 0, captionRight, CaptionBarSize);
               }
 
               Point screenPoint = new Point(WinApi.LoWord((int)m.LParam), WinApi.HiWord((int)m.LParam));
               Point ribbonPoint = PointToClient(screenPoint);
               bool onCaptionButtons = false;
 
               if (CaptionButtonsVisible)
               {
                  onCaptionButtons = CloseButton.Bounds.Contains(ribbonPoint) ||
                  MinimizeButton.Bounds.Contains(ribbonPoint) ||
                  MaximizeRestoreButton.Bounds.Contains(ribbonPoint);
               }
               //Detect if mouse is on caption andalso not on CaptionButtons
               MouseOnCaption = (!onCaptionButtons && RectangleToScreen(caption).Contains(screenPoint));
            }
            if (MouseOnCaption)
            {
                if (m.Msg == WinApi.WM_LBUTTONDBLCLK)
                {
                    //If Double Click on caption change FormWindowsState
                    Form f = FindForm();
                    f.WindowState = f.WindowState == FormWindowState.Normal ? FormWindowState.Maximized : FormWindowState.Normal;
                    bypassed = true;
                }
                if (m.Msg == WinApi.WM_LBUTTONDOWN)
                {
                    //If mouse left button is down on caption create and send message to start drag.
                    Form f = FindForm();
                    Message mDrag = new Message();
                    mDrag.HWnd = f.Handle;
                    mDrag.Msg = WM_NCLBUTTONDOWN;
                    mDrag.WParam = new IntPtr(HT_CAPTION);
                    mDrag.LParam = IntPtr.Zero;
                    base.WndProc(ref mDrag);
                }
            }
 
         }
 
         if (!bypassed)
         {
            base.WndProc(ref m);
         }
      }
Developer
Apr 11, 2012 at 8:23 AM

the solutions provided by javierdd and giague have been added into Documentation

Developer
May 16, 2013 at 1:29 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/