Wie setzt man die DialogFarben ?



  • Hallo,

    ich muss die Dialogfarbe von den Systemfarben abweichen lassen
    und möchte sie fest auf z.B. FFFFF0 setzen.
    Wo muss ich das ändern ? Nachdem das alles ja die GUI macht, denk ich
    mir, das es irgendwo in den .rc Dateien möglich sein müsste?

    Oder wie ändert Ihr den Dialoghintergrund auf eine feste Farbe ?

    Gruß
    TheNoName



  • Du mußt die WM_CTLCOLOR überladen.

    in *.h
        CBrush m_BackBrush;
    in *.cpp
    Cxxxx::InitDialog()
    {
    ....
        m_BackBrush.CreateSolidBrush(0xFFFFF0);
    }
    Cxxxx::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
    {
        if(nCtlColor == CTLCOLOR_DLG)
            return m_BackBrush;
    
        retrun CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    }
    

    Gruß



  • Eher so:

    HBRUSH Cxxx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
        if(nCtlColor & CTLCOLOR_STATIC)
        {
               // Set the static text to black on lightblue.
               pDC->SetTextColor(RGB(0, 0, 0));
               pDC->SetBkColor(0xFFFFF0);
               // Drop through to return the background brush.
        }
        if(nCtlColor & CTLCOLOR_DLG){return m_BackBrush;}
    
        return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    }
    

    Aber sonst TOP !!
    Ob man darüber auch ein Hintergrundbild setzen kann ?

    cu



  • Warum machst Du ein Bitlogisches Und mit nCtlColor?

    Zitat MSDN aus CWnd::OnCtlColor:

    nCtlColor

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

    Ende Zitat

    Also ist doch hier eine switch besser, da nCtlColor ja nur EINEN Wert haben kann (keine Bitmaske ist).

    Ein Hintergrundbild kannst Du über OnPaint oder OnEraseBkgnd Blitten (BitBlt oder über GDI+)

    Gruß Matthias



  • Ja, ein swtich wäre besser.

    Den Bitmap Hintergrund lässt sich einfacher gestallten, wenn man den Brush
    auf ein Bitmap setzt. Hab ich schon probiert, klappt tadellos und ist wesentlich
    Resourcenschonender !



  • Auch ein Bild mit 1024x768 Pixel und das in der Größe des Dialoges angepasst? Also Verkleinern? Glaub ich doch eher nicht!

    Gruß


Anmelden zum Antworten