farbige Tooltipps



  • void ToolTipladen(BOOL i, HWND DLG, HWND TP, HWND KW, int str,int id,char* sstr)
    {
    	HINSTANCE hInst = (HINSTANCE)GetWindowLong(DLG,GWL_HINSTANCE);
    
    	char buf[255];
    	RECT rect;
    	TOOLINFO tt;
    	tt.cbSize		= sizeof(TOOLINFO);
    	tt.hwnd			= KW;
    	tt.hinst		= hInst;
    	tt.uFlags		= TTF_SUBCLASS|TTF_ABSOLUTE  ;
    	if(id)
    		tt.uId      = id;
    	LoadString(hInst,str,buf,sizeof(buf));
    	if(!sstr)
    	{
    		if(str)
    			tt.lpszText	= (LPSTR)buf;
    		else
    			tt.lpszText	= LPSTR_TEXTCALLBACK;
    	}
    	else
    		tt.lpszText = (LPSTR)sstr;
    	GetClientRect(KW,&rect);
    	tt.rect		= rect;
    	BOOL t = SendMessage( TP, TTM_ADDTOOL, 0, (LPARAM)&tt );
    
    	SendMessage(TP,TTM_SETMAXTIPWIDTH,0,(LPARAM)(INT)300);
    	if(i=1)
    	{
    		SendMessage(TP,TTM_SETTIPBKCOLOR,  RGB(255,255,255),0);	
    		SendMessage(TP,TTM_SETTIPTEXTCOLOR,RGB(255,0,0),0);
    
    	}
    
    }
    

    SendMessage(TP,TTM_SETTIPBKCOLOR, RGB(255,255,255),0); funktioniert, nur
    SendMessage(TP,TTM_SETTIPTEXTCOLOR,RGB(255,0,0),0); nicht die Textfarbe ist weiterhin schwarz statt rot.
    😕 😕 😕



  • Bei mir klappt es..

    HWND CreateToolTip(int toolID, HWND hDlg, PTSTR pszText)
    {
    INITCOMMONCONTROLSEX iccex;
    iccex.dwICC = ICC_WIN95_CLASSES; //ICC_PROGRESS_CLASS;
    iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    InitCommonControlsEx(&iccex);
    
        if (!toolID || !hDlg || !pszText)
        {
            return FALSE;
        }
        // Get the window of the tool.
        HWND hwndTool = GetDlgItem(hDlg, toolID);
    
        // Create the tooltip. g_hInst is the global instance handle.
        HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
                                  WS_POPUP |TTS_ALWAYSTIP,
                                  CW_USEDEFAULT, CW_USEDEFAULT,
                                  CW_USEDEFAULT, CW_USEDEFAULT,
                                  hDlg, NULL, 
                                  hInstGlobal,NULL);
    
       if (!hwndTool || !hwndTip)
       {
           return (HWND)NULL;
       }                              
    
        // Associate the tooltip with the tool.
        TOOLINFO toolInfo = { 0 };
        toolInfo.cbSize = sizeof(toolInfo);
        toolInfo.hwnd = hDlg;
        toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
        toolInfo.uId = (UINT_PTR)hwndTool;
        toolInfo.lpszText = pszText;
        SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
            SendMessage(hwndTip,TTM_SETTIPBKCOLOR,  RGB(255,255,255),0);    
            SendMessage(hwndTip,TTM_SETTIPTEXTCOLOR,RGB(255,0,0),0); 
        return hwndTip;
    }
    

    Es geht sogar einzeln an dieser Stelle:

    // Button erstellen
    hButton = CreateWindow("BUTTON","Button Text",  
    WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,
    100,100,120,20,  // pos x, pos y, breite, hoehe
    pHwnd,(HMENU)100, 
    hInstGlobal, NULL);
    
    // Tooltip mit Button verknüpfen
    hwndTool = CreateToolTip(100,pHwnd,"Tooltip Text bla bla..");
    SendMessage(hwndTool,TTM_SETTIPBKCOLOR,  RGB(255,255,255),0);    
    SendMessage(hwndTool,TTM_SETTIPTEXTCOLOR,RGB(255,0,0),0);
    

    Gruss,
    DC



  • Danke jetzt klappt es.

    Ich habe alle Tooltip in ein Tooltippcontrol gepackt.

    Solange die alle gleich aussehen war ja alles ok.

    Jetzt hat die Function für die farbigen Tooltipps ein eigenes Control.

    Jetzt futz die Sache.

    Was mir eigenartig vorkommt, dass der Hintergrund gefärbt werden konnte aber die Textfarbwe nicht.


Anmelden zum Antworten