Hintergrundfarbe eines Editcontrols ändern



  • Hallo !

    Wie ist es möglich die Hintergrundfarbe eine Editcontrols zu ändern, welches auf einer CPropertyPageEx liegt ?



  • CWnd::OnCtlColor
    afx_msg HBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );

    Return Value

    OnCtlColor must return a handle to the brush that is to be used for painting the control background.

    Parameters

    pDC

    Contains a pointer to the display context for the child window. May be temporary.

    pWnd

    Contains a pointer to the control asking for the color. May be temporary.

    nCtlColor

    Contains one of the following values, specifying the type of control:

    CTLCOLOR_BTN Button control

    CTLCOLOR_DLG Dialog box

    CTLCOLOR_EDIT Edit control

    CTLCOLOR_LISTBOX List-box control

    CTLCOLOR_MSGBOX Message box

    CTLCOLOR_SCROLLBAR Scroll-bar control

    CTLCOLOR_STATIC Static control
    ....



  • Es klappt irgendwie nicht. Es wird noch nicht einmal die Funktion OnCtlColor aufgerufen.

    Mein Header Datei des Dialogs sieht wie folgt aus (dialogbasierende App):

    // Implementierung
    protected:
    	//{{AFX_MSG(CMyDialog)
    	afx_msg HBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );
    	//}}AFX_MSG
    	DECLARE_MESSAGE_MAP()
    

    Die CPP Datei so ...

    HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    { 
        MessageBox("Jetzt werde ich aufgerufen !");
        return CDialog::OnCtlColor(pDC, pWnd, nCtlColor); 
    }
    

    Tja, leider wird die Funktion nicht aufgerufen. Woran liegt das ? 😕



  • ein ON_WM_CTLCOLOR() gibts in deiner message map?



  • CMatt schrieb:

    ein ON_WM_CTLCOLOR() gibts in deiner message map?

    Nein natürlich nicht. 🙄

    Aller herzlichsten Dank. 🙂

    P.S.: Noch eine Frage zu Wizards mit PropertySheets. Es gibt doch oben diese "Topbar" (weiße Leiste bei Windowsassistenten). Weiß du/jemand zufällig wie ich davon die Schriftart ändern kann ? Dialogschriftart ist schon erfolgreich geändert, aber die "Topbar"-Schriftart ändern sich nicht.

    MfG Michael


Anmelden zum Antworten