Cómo crear una información sobre herramientas para un área rectangular

En el ejemplo siguiente se muestra cómo crear un control de información sobre herramientas estándar para todo el área de cliente de una ventana.

En la ilustración siguiente se muestra la información sobre herramientas que se muestra cuando el puntero del mouse está dentro de la ventana cliente de un cuadro de diálogo. El identificador del cuadro de diálogo se pasó a la función que se muestra en el ejemplo anterior.

screen shot of a dialog box; the mouse pointer is within the client window, and a tooltip is visible

Lo que necesita saber

Tecnologías

Requisitos previos

  • C/C++
  • Programación de la interfaz de usuario de Windows

Instructions

Crear una información sobre herramientas para un área rectangular

En el ejemplo siguiente se muestra cómo crear un control de información sobre herramientas estándar para todo el área de cliente de una ventana.

void CreateToolTipForRect(HWND hwndParent)
{
    // Create a tooltip.
    HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, 
                                 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, 
                                 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
                                 hwndParent, NULL, g_hInst,NULL);

    SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, 
                 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

    // Set up "tool" information. In this case, the "tool" is the entire parent window.
    
    TOOLINFO ti = { 0 };
    ti.cbSize   = sizeof(TOOLINFO);
    ti.uFlags   = TTF_SUBCLASS;
    ti.hwnd     = hwndParent;
    ti.hinst    = g_hInst;
    ti.lpszText = TEXT("This is your tooltip string.");
    
    GetClientRect (hwndParent, &ti.rect);

    // Associate the tooltip with the "tool" window.
    SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); 
} 

Usar controles de información sobre herramientas