Réponse acceptée !
Qu'est-ce qui ne marche pas exactement ?
J'utilise cette fonction sans problème. Par contre la couleur des boutons ne change pas. Si tu veux changer leur aspect tu peux les affecter à un bitmap.
Pour changer la couleur des textes (CEdit, CStatic...) tu peux surcharger la fonction OnCtrlColor().
HBRUSH CCitationDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_EDIT) { pDC->SetTextColor(RGB(0, 0, 255)); pDC->SetBkMode(OPAQUE);
} return hbr; }
Si tu veux faire des effets sur ta fenètre il faut surcharger la fonction OnEraseBkgnd(); CBitmap ArrierePlan; BOOL CMaµFenetre::OnEraseBkgnd(CDC* pDC) { CDC fdc; CRect RectClient; fdc.CreateCompatibleDC(pDC); CBitmap* pOldBitmap = fdc.SelectObject(&ArrierePlan); int iBitmapWidth, iBitmapHeight ; int ixOrg, iyOrg; GetParent()->GetWindowRect(&RectClient); BITMAP bm; ArrierePlan.GetObject(sizeof(BITMAP),&bm); iBitmapWidth = bm.bmWidth; iBitmapHeight = bm.bmHeight;
if (iBitmapWidth >= RectClient.Width() && iBitmapHeight >= RectClient.Height() ) { pDC->BitBlt (RectClient.left, RectClient.top, RectClient.Width(), RectClient.Height(), &fdc, 0, 0, SRCCOPY );// SRCCOPY } else { for (iyOrg = 0; iyOrg < RectClient.Height(); iyOrg += iBitmapHeight) { for (ixOrg = 0; ixOrg < RectClient.Width(); ixOrg += iBitmapWidth) { pDC->BitBlt (ixOrg, iyOrg, RectClient.Width(), RectClient.Height(), &fdc, 0, 0, SRCCOPY );
} } } fdc.SelectObject(pOldBitmap); return TRUE; }
et aussi OnDraw(); pour un dégrader sympa :
void CMaFenetre::OnDraw(CDC* pDC) {
//////////////////////////////////////// Default();
CWindowDC dc(this); CBrush Brosse; CRect Rec; this->GetWindowRect(&Rec); Brosse.Attach( (HBRUSH)GetStockObject(LTGRAY_BRUSH)); CRect BarreRc(0,0,Rec.Width(),10); pDC->FillRect(BarreRc,&Brosse);
float gradient=0; float CouleurDuDebut=10; float CouleurDeFin=195; gradient=(CouleurDeFin-CouleurDuDebut)/Rec.Width();
// DESSINE LE DEGRADE
for(int I=0;I<Rec.Width();I++) { int Rouge,Vert,Bleu; float fRouge,fVert,fBleu; CPen *pAncienPen;
fRouge=gradient*(float)I-CouleurDuDebut; fVert =gradient*(float)I-CouleurDuDebut; fBleu =gradient*(float)I-CouleurDuDebut;
Rouge=(int)fRouge+10; Vert=(int)fVert+10; Bleu=(int)fBleu+60;
CPen pen(PS_SOLID,1,RGB(Rouge,Vert,Bleu)); pDC->MoveTo(I,0); pAncienPen=pDC->SelectObject(&pen); pDC->LineTo(I,30); pDC->SelectObject(pAncienPen);
} CString st("NOM DE MA FENETRE"); pDC->SetTextAlign(TA_BASELINE | TA_CENTER); pDC->SetTextColor(RGB(255,255,255)); pDC->SetBkMode(TRANSPARENT);
pDC->TextOut((BarreRc.right - 100 ), (BarreRc.bottom +10), st);
}
@+
|