RICHEDIT - automatischer vertikaler scroll



  • hi.
    ich mache so eine art chat... und da sollte natürlich das richedit control, in welchem die nachrichten angezeigt werden, automatisch runterscrollen! ich habe dem richedit control einen style zugewiesen (AUTOVSCROLL) aber das richedit scrollt immer erst dann automatisch, wenn man es erstmal manuell einmal runtergescrollt hat. wie kann ich es gleich zunterscrollen lassen?



  • Ist von mir:

    // function to add a text
    void utilAppendTextToWindow(HWND hWnd, char *szText, COLORREF crTextColor)
    {
        // private
        int tl;
        CHARFORMAT cf;
    
        tl = GetWindowTextLength(hWnd);
    
        // add new text
        SendMessage(hWnd, EM_SETSEL, tl, tl);
        SendMessage(hWnd, EM_REPLACESEL, FALSE, (LPARAM)szText);
    
        // fill struct
        memset( &cf, 0, sizeof(CHARFORMAT) );
    
        cf.cbSize = sizeof(CHARFORMAT);
        cf.dwMask = CFM_COLOR;
        cf.crTextColor = crTextColor;
    
        // select last text inserted
        tl = GetWindowTextLength(hWnd);
        SetFocus(hWnd);
        SendMessage(hWnd, EM_SETSEL, (WPARAM)(tl-strlen(szText)), (LPARAM)tl);
    
        // set color
        SendMessage(hWnd, EM_SETCHARFORMAT ,SCF_SELECTION, (LPARAM)&cf);
    
        // set cusor to end of text
        SendMessage(hWnd, EM_SCROLL, SB_PAGEDOWN, 0); 
    }
    

    cu para
    😃

    Die letzte Zeile wird es sein...



  • danke! war sehr hilfreich!!
    chris


Anmelden zum Antworten