Windows jaune infobulle multiligne?

Est-il possible de créer une infobulle jaune dans windows multiline?

http://img830.imageshack.us/img830/6117/tooltip.gif

J’ai essayé avec \n mais ça ne marche pas.

MODIFIER:

C’est la fonction que j’ai dans mon code. J’ai suivi les instructions de MSDN mais je ne pouvais pas le faire fonctionner (regardez le commentaire: // Multiline tooltip ).

 void CreateToolTipForRect(HWND hwndParent) { if (!bCanCreateToolTips) return; // Get list of areas we want tooltips on NSUI::TButton* tbt; tbt = gUserInterface->buttonList; HWND hwndTT; // Array to store all tooltip texts static char ssortingng[100][ RM_SCROLLTEXT_MAXLEN + 2 ]; // Go through the list while (tbt != NULL) { // Check id there is a tooltip text defined for this area int sid = GetResourceIdFromButtonId(tbt->id); if (sid == -1) { tbt = tbt->next; continue; } if (!ttwnd[tbt->id]) { // Create a ToolTip. hwndTT = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, (( QunicApp * )CQMainGetApp())->CQWinApp_GetHInst(),NULL); ttwnd[tbt->id] = hwndTT; SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // Get tooltip from resources int res = LoadSsortingng((( QunicApp * )CQMainGetApp())->CQWinApp_GetHInst(), sid, ssortingng[tbt->id], RM_SCROLLTEXT_MAXLEN ); } // Set up "tool" information. TOOLINFO ti = { 0 }; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndParent; ti.hinst = (( QunicApp * )CQMainGetApp())->CQWinApp_GetHInst(); ti.lpszText = ssortingng[tbt->id]; // Set area ti.rect.left = tbt->tx; ti.rect.right = tbt->bx; ti.rect.top = tbt->ty; ti.rect.bottom = tbt->by; // Associate the ToolTip with the "tool" window. SendMessage(ttwnd[tbt->id], TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); // Multiline tooltip - Ilija sortinged with this /*LPNMTTDISPINFO pInfo = (LPNMTTDISPINFO)tbt; SendMessage(pInfo->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 150);*/ tbt = tbt->next; } // Extra one, area or button is not known yet // Create a ToolTip. hwndTT = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, (( QunicApp * )CQMainGetApp())->CQWinApp_GetHInst(),NULL); SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // Set up "tool" information. TOOLINFO ti = { 0 }; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndParent; ti.hinst = (( QunicApp * )CQMainGetApp())->CQWinApp_GetHInst(); // Get tooltip from resources int res = LoadSsortingng( ti.hinst, IDS_PREVIEW, ssortingng[99], RM_SCROLLTEXT_MAXLEN ); ti.lpszText = ssortingng[99]; // Set area ti.rect.left = 7; ti.rect.right = 104; ti.rect.top = 131; ti.rect.bottom = 145; // Associate the ToolTip with the "tool" window. SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); } 

Merci,
Ilija

Il existe 3 types d’infos. Votre capture d’écran montre une info-bulle de suivi. Ensuite, il y a une info-bulle multiligne, envoyez TTM_SETMAXTIPWIDTH et répondez à TTN_GETDISPINFO. Et il y a des info-bulles de bulles, spécifiez l’indicateur de style de fenêtre TTS_BALLOON. Les deux derniers correspondent à votre facture.

Il y a de bons exemples de code dans l’ article du SDK pour eux.

Vous pouvez forcer le contrôle d’info-bulle standard à faire de la multiligne en utilisant l’astuce suivante:

Dans votre gestionnaire TTN_NEEDTEXT:

 // force multi-line tool tips ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, kToolTipWidth); 

Indépendamment, en définissant la largeur, je suis capable de dessiner des conseils de muiltiline:

 pToolTipText->lpszText = _T("blah blah blah\r\nmore blah blah\r\nline 3 of blah"); 

Où kToolTipWidth est une largeur maximale utile, disons 600-800.

Curieusement, je dois réémettre ce message dans le gestionnaire TTN_NEEDTEXT, et pas seulement à la création de la fenêtre. Cela est vrai pour notre application MFC, où MFC utilise un contrôle d’info-bulle global par thread, qui est probablement réinitialisé aux valeurs par défaut chaque fois qu’une nouvelle boîte de dialog est créée. Il est donc possible que pour une application non MFC, vous ne puissiez l’initialiser qu’une seule fois.

Prendre plaisir!

Windows utilise \r\n pour les sauts de ligne. Essayez-le plutôt, cela devrait fonctionner. Voir MSDN .

J’ai trouvé que \ n fonctionne pour les info-bulles normales, mais ni \ n ni \ r \ n ne fonctionne pour les info-bulles. Je n’utilise pas Unicode.