NiceTry
NiceTry

Reputation: 26

Change mouse cursor when hovering over image resize handles in IRichEdit control

I have very limited experience in win32 API, so please excuse me if the question is dumb. I have inserted an image in a windowless rich edit control. When selecting the image, the eight resize handles appear on it as expected. However, I do not know how to change the mouse cursor when one of those handles is hovered over.

How can I figure out if a resize handle is being hovered over or not? Does a rich edit control allow that automatically or do I have to do it manually? Doing it manually would be no problem, but I also don't know how to get the position and dimensions of the selected image in a windowless rich edit control.

So to sum it all up, I need either a way to automatically change the mouse pointer when one of the image resize handles is hovered over, or a way to find the position and dimensions of the selected image in a windowless rich edit control. Any help in form of documentation or code snippets would be very helpful!

Upvotes: 0

Views: 229

Answers (1)

Junjie Zhu - MSFT
Junjie Zhu - MSFT

Reputation: 2979

You can handle the control's WM_SETCURSOR message. In response to this message, to change the cursor style, you can use LoadCursorFromFile or LoadCursor to load resources or and SetCursor to set the cursor.

case WM_SETCURSOR:
{
    if (static_cast<HWND>(wParam) == GetDlgItem(hWnd, IDC_YOURCONTROL))
    {
        SetCursor(LoadCursor(NULL,IDC_HAND));
        SetWindowLongPtr(hWnd, DWLP_MSGRESULT, TRUE);
        return TRUE;  
    }
    return FALSE; 
}

Upvotes: 0

Related Questions