Hintergrundfarbe von CButton
-
Hallo,
wie kann ich für CButton mit Einstellung Bitmap die Hintergrundfarbe zur Laufzeit setzen?
Ich habe es unter OnCtlColor mit der Abfrageif (pWnd == &m_but_bt1) { pDC->SetBkColor(GELB); pDC->SetBkMode(TRANSPARENT ); return m_hFarbe_Weiss; }Der Button färbt sich aber nicht, habe auch schon die If-Abfrage raus genommen, ohne Erfolg.
Der HBRUSH ist richtig erstellt.Oli_1977
-
Müsstest du den BkMode nicht auf OPAQUE stellen?
-
CButton ableiten und Funktionen überschreiben.
Gibt genug Bsp. bei Codeuru, Codeproject
-
Danke.
Habe ein Klasse abgeleitet und es funktioniert.
-
Grundsätzlich: Buttons verwenden niemals den Brush den man bei WM_CTLCOLORBTN zurückgibt.
WM_CTLCOLORBTN
http://msdn.microsoft.com/en-us/library/bb761849(VS.85).aspxBy default, the DefWindowProc function selects the default system colors for the button. 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.