WinAPI - RichEditBox & MouseOver Event



  • Hallo,
    Ich habe einen MouseOver Funktion geschrieben, dass funktioniert auch soweit aber nur rechts nebem einem WindowHandle oder darunter.
    Code:

    bool MouseOver(HWND childhwnd)
    {
       POINT mousePos;
       RECT rect;
       GetCursorPos(&mousePos); 
       GetWindowRect(childhwnd, &rect);
       if(mousePos.x >= rect.left && mousePos.x <= rect.right && mousePos.y >=             rect.top && mousePos.y <= rect.bottom)
       {
          return true;
       }
       return false;
    }
    

    Die Funktion rufe ich in der WindowProzedur mit dem Event WM_MOUSEMOVE auf.
    So, nun zu der RichEdit Box.
    Wie bezwecke ich wenn ich etwas hinein schreibe und nicht der Ganze Text z.B.:
    Unterstrichen ist? Bis jetzt habe ich diese Funktion verwendet:

    void SendText(HWND whereto, HWND htwnd, LPCSTR text, DWORD chrformat = CFM_COLOR, COLORREF farbe = RGB(0,0,0)) 
    { 
        int length=GetWindowTextLength(htwnd);
        SendMessage(htwnd, EM_SETSEL, length, length);
        SendMessage(htwnd, EM_REPLACESEL, NULL, (LPARAM)text);
        CHARFORMAT cf;
        cf.cbSize=sizeof(cf); 
        cf.dwMask    = chrformat;//CFM_COLOR | CFM_UNDERLINE | CFM_BOLD
        cf.dwEffects = CFE_BOLD;
        cf.dwEffects &= ~(1<<1);
        cf.dwEffects|= ((1<<2)|(1<<3)); 
        cf.crTextColor = farbe;
        int l=GetWindowTextLength(whereto);
        SendMessage(htwnd, EM_SETSEL, l, l); 
        SendMessage(htwnd, EM_SETCHARFORMAT, (WPARAM)(UINT)SCF_SELECTION, (LPARAM)&cf);
    	UpdateWindow(htwnd);
    	UpdateWindow(whereto);
    }
    

    Vielen Dank für Hilfe.


Anmelden zum Antworten