Click here to Skip to main content
15,885,194 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey every one!
I have a rich edit (only show paragraph text)
When i select a text by move mouse, i want to show this selected text by using message box ass following code:
C++
case WM_KEYDOWN:
    if (wParam == VK_RETURN) 
    {
        wchar_t *wcWordSelect = new wchar_t[200];
	SendMessage(hWnd, EM_GETSELTEXT, SCF_SELECTION, (LPARAM)wcWordSelect);
	MessageBox(NULL, wcWordSelect, L"MSG", NULL);
    }
    break ;


But my task is show selected by using tooltip
Please help me show this text using tooltip
I known how to make tooltips for button, ballon toolbar but i dont known how to do my task
Thank for your help!!
Posted

A MessageBox is not very useful as it requires action from the user to close it. Take a look at the MSDN documentation[^] on tooltips.
 
Share this answer
 
Yes, i can show tooltip for a button such as:
C++
case WM_NOTIFY:
{
    switch (((LPNMHDR) lParam)->code)
    {
        case TTN_NEEDTEXT:
        {
            LPTOOLTIPTEXT lptttext;
            lptttext = (LPTOOLTIPTEXT) lParam;
            lptttext->hinst = g_hInst;
            switch(lptttext->hdr.idFrom)
            {
            case ID_BUTTON1:
                {
                    lptttext->lpszText = L"Tooltip button 1";
                }break;
            }
        }
    }
}
break;



And the code below here show the selected text using message box (I create a procedure for rich edit controll)
C++
LRESULT FAR PASCAL RichEditProc(HWND hWnd,
                                UINT Message,
                                WPARAM wParam,
                                LPARAM lParam)
{
    wchar_t *wcWordSelect = new wchar_t[MAX_LENG_WORD];
    switch(Message)
    {
    case WM_CHAR:
        //Process this message to avoid message beeps.
        if ((wParam == VK_RETURN) || (wParam == VK_TAB))
        {
            //Do Something
            return 0;
        }
        break;
    case  WM_RBUTTONDOWN:
        {
            SendMessage(hWnd, EM_GETSELTEXT, SCF_SELECTION, (LPARAM)wcWordSelect);
            MessageBox(NULL, wcWordSelect, L"MSG", NULL);
            CreateToolTipForRect(hWnd);
        }
        break;
    case WM_KEYDOWN:
        if (wParam == VK_RETURN)
        {
            SendMessage(hWnd, EM_GETSELTEXT, SCF_SELECTION, (LPARAM)wcWordSelect);
            MessageBox(NULL, wcWordSelect, L"MSG", NULL);
            return 0;
        }
        break ;

    default:
        break;
    }
    return CallWindowProc((WNDPROC)lpfnOldWndProc, hWnd, Message, wParam, lParam);
}


My QUESTION is: how can i use tooltip insted of using message box to show 'wcWordSelect' variable?
Thank for your help!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900