je met un peu de code ici, je ne comprend pas pourquoi ca marche pas avec le cas 1.
j'au un bouton sur le dialogue qui fait un RedrawWindow().
si qq'un pouvais essayer ca ?
(il faut un groupe de radio et un bouton qui fait RedrawWindow() )
BOOL CDialog::OnEraseBkgnd(CDC* pDC)
{
if (m_radio_fond == 0)
{
// COULEUR DU FOND
// Fixe une brosse avec la couleur de fond choisie
CBrush BkClrBrush(RGB(coul_fond_r, coul_fond_v, coul_fond_b));
// Sauvegarde lancienne brosse.
CBrush* pOldBrush = pDC->SelectObject(&BkClrBrush);
CRect rect;
pDC->GetClipBox(&rect); // récupère la zone a effacer.
pDC->PatBlt(rect.left, rect.top, rect.Width(),rect.Height(), PATCOPY);
pDC->SelectObject(pOldBrush);// restitue lancienne brosse.
return true;
}
else if (m_radio_fond == 1)
{
// CHARGE IMAGE FICHIER
CPaintDC hdc(this);
HBITMAP bit;
BITMAP bitmap;
CRect rect;
GetClientRect(&rect);
bit= (HBITMAP) LoadImage(NULL, fic_img_abs, IMAGE_BITMAP,0,0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
GetObject(bit, sizeof(BITMAP), &bitmap);
HDC bit_dc = CreateCompatibleDC(hdc);
SelectObject(bit_dc, bit);
StretchBlt(hdc,0,0,rect.Width(),rect.Height(),bit_dc,0,0,bitmap.bmWidth,bitmap.bmHeight, SRCCOPY );
DeleteObject(bit);
DeleteDC(bit_dc);
return true;
}
CBitmap bmp;
CBitmap *ptrBmpOld;
CDC dcMemory;
BITMAP bm;
CRect rect;
int nHor,nVer;
bmp.LoadBitmap(IDB_BITMAP_CONF);
bmp.GetBitmap(&bm);
GetClientRect(rect);
nHor = rect.Width()/bm.bmWidth+1;
nVer = rect.Height()/bm.bmHeight+1;
dcMemory.CreateCompatibleDC(pDC);
ptrBmpOld=dcMemory.SelectObject(&bmp);
// etirer l'image (contrairement à bitblt)
pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcMemory,0,0,bm.bmWidth,bm.bmHeight, SRCCOPY );
dcMemory.SelectObject(ptrBmpOld);
return TRUE;
}
gege