OnCtlColor Färbt die Button nicht. Warum?



  • Hallo,

    ich verwende CtlColor und es wird auch alles in Farbe dargestellt ausser die Button.... Die bleiben in Orginalfarbe.

    Was ist da falsch?

    Mein Code

    HBRUSH CKontaktDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    
    	COLORREF colorRed  = RGB(253, 0, 0); 
    	switch (nCtlColor) 
    	{ 
    	case CTLCOLOR_STATIC: // Für alle Statics 
    		pDC->SetTextColor(RGB(253, 0, 0)); 
    		pDC->SetBkColor(RGB(255, 255,215)); 
    
    	case CTLCOLOR_DLG: // Für den Dialog 
    		pDC->SetTextColor(RGB(253, 0, 0)); 
    		pDC->SetBkColor(RGB(255, 255,215)); 
    
    	case CTLCOLOR_BTN: // Für die Button
    		pDC->SetTextColor(RGB(253, 0, 0)); 
    		pDC->SetBkColor(RGB(255, 255,215)); 
    
    	case CTLCOLOR_EDIT:	// Für die Edit
    		pDC->SetTextColor(RGB(0,0,0)); 
    		pDC->SetBkColor(RGB(255, 255,215)); 
    
                    return (HBRUSH)m_brush; 
    
    	default: 
    		return CDialog::OnCtlColor(pDC, pWnd, nCtlColor); 
    	}
    
    	return hbr;
    }
    

    Danke....

    mfg Uwe



  • Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or BS_PUSHLIKE styles do not use the returned brush. Buttons with these styles are always drawn with the default system colors. Drawing push buttons requires several different brushes-face, highlight and shadow-but the WM_CTLCOLORBTN message allows only one brush to be returned. To provide a custom appearance for push buttons, use an owner-drawn button.



  • Danke...!

    mfg Uwe



  • 😞

    ich finde leider die nachricht WM_CTLCOLORBTN nicht in der Nachrichten tabelle im klassen Assistenten ? (V6 C++)

    wie funktioniert diese Nachricht?
    ich würde gerne meine Buttons Färben..

    Ein kleines beispiel wie bei Uwe währe net.
    Oder ein Anhalts punkt. wie ich an die Nachricht WM_CTLCOLORBTN ran komme.

    Dankeeeee...

    Grüße Can



  • Hallo,

    schreib dir eine von CButton abgeleitete Klasse und benutze die WM_DRAWITEM, dort kannst du dann mit SetTextColor bzw. FillSolidRect den Button einfärben !

    Gruß
    :: NoName ::


Anmelden zum Antworten