1
votes

ParentSadly I didn’t find an answer with google by searching for "laggy/slow mouse wheel-scrolling in Rich Edit control" and similar sentence.

I created a rich edit control (5.0) as a child, added the styles WS_VISIBLE, WS_CHILD, WS_VSCROLL, ES_READONLY, ES_MULTILINE, ES_NOHIDESEL, ES_AUTOVSCROLL and subclassed the messagehandler callback. After appending ~200 text lines the VScroll moves very laggy if I use the mouse wheel. With laggy I mean that the thumb of the rich edit Vscrollbar is still scrolling while I already stopped scrolling with my mouse wheel. Scrolling by clicking the thumb and move it around works fine.

Currently I have no idea why this happens. Someone maybe know why the mouse wheel scrolling is so laggy and how to fix this crazy issue?

Edit: I tested it now also without subclassing directly new project with only a parent window. It has still the same issue there if i write ~ 200 lines. This is the code i use to creat the rich edit control:

     ATOM MyRegisterClass(HINSTANCE hInstance){
        WNDCLASSEX wcex;

        wcex.cbSize = sizeof(WNDCLASSEX);

        wcex.style          = CS_HREDRAW | CS_VREDRAW;
        wcex.lpfnWndProc    = WndProc;
        wcex.cbClsExtra     = 0;
        wcex.cbWndExtra     = 0;
        wcex.hInstance      = hInstance;
        wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_BUGTEST));
        wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
        wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
        wcex.lpszMenuName   = MAKEINTRESOURCE(IDC_BUGTEST);
        wcex.lpszClassName  = szWindowClass;
        wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

        return RegisterClassEx(&wcex);
    }



     BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){
           HWND hWnd;
           hInst = hInstance; 
           hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
              CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

           if (!hWnd)
           {
              return FALSE;
           }

           ShowWindow(hWnd, nCmdShow);

           LoadLibraryA("Msftedit.dll");                    
           wstring w_classname = wstring(MSFTEDIT_CLASS);
           string classname = string(w_classname.begin(), w_classname.end());

HWND richedit = CreateWindowExA(
               WS_EX_CLIENTEDGE,                                                
               classname.c_str(),
               "richedit",                                                                  
               WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_NOHIDESEL | ES_MULTILINE | ES_AUTOVSCROLL | ES_LEFT,     
               200, 300,                                                    
               400, 500,                                                
               hWnd,                                                
               NULL,                                                        
               hInstance,                                               
               NULL
               );
           UpdateWindow(hWnd);

           return TRUE;
        }
1
Since you subclassed the control that's exposing undesired behavior, it would be helpful to see this code, ideally an SSCCE.IInspectable
K added the code aboveBluefire
OT: use the unicode versions, if you use the non unicode versions it has to translate internally and that will slow things down. Also the ansi versions are tombstoned and won't receive patches.Mgetz
Did you change the code when you posted it? It looks like hProgrammInstance is the wrong module handle. The control implementation is in Msftedit.dll, not your in your application module.IInspectable
I created now a new clear project and changed the code above again...sry. OK yea im not using instance from dll so seems its this.. have to look how to use the instance from this dll now. Im new in the winapi and c++ stuff^^ So thx or this advice :)Bluefire

1 Answers

2
votes

K so after spending again some hours in this issue I found now some advice that the rich edit control uses the SMOOTH VSCROLL.Even Wordpad use this Smoothscroll and has threfore the same "laggy" issue. (http://simonscodes.blogspot.de/2014/12/hello.html) So sadly I can’t get the example code from this page which maybe solve the problem but after reading this post -> Disabling Smooth Scrolling on Richtextbox I created now an own solution. The way I’m using now is to subclass the rich edit control and block the WM_MOUSEWHEEL message and handle it by my own by sending the WM_VSCROLL message. This avoids the SMOOTH VSCROLL and stops this crazy laggy scrolling issue.

Here the code in my subclassed messagehandler callback:

case WM_MOUSEWHEEL:{
                    if (GET_WHEEL_DELTA_WPARAM(wParam) > 0) // A positive value indicates that the wheel was rotated forward, away from the user; 
                        SendMessageA(hRichEdit, WM_VSCROLL, SB_LINEUP, NULL);
                    else if (GET_WHEEL_DELTA_WPARAM(wParam) < 0) //A negative value indicates that the wheel was rotated backward, toward the user.
                        SendMessageA(hRichEdit, WM_VSCROLL, SB_LINEDOWN, NULL);
                    return TRUE;  //block the message
                }

For more info how parts of this code works or about the WM_MOUSEWHEEL message read here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms645617%28v=vs.85%29.aspx