Visual C++ / controles et pDC

BarthOlivier Messages postés 132 Date d'inscription mercredi 6 mars 2002 Statut Membre Dernière intervention 27 novembre 2012 - 16 juin 2005 à 13:31
BarthOlivier Messages postés 132 Date d'inscription mercredi 6 mars 2002 Statut Membre Dernière intervention 27 novembre 2012 - 17 juin 2005 à 22:55
salut à tous

j'ai deux petits soucis en MFC avec des controles CheckBox et les cntextes de periph.

Je me demande si cen n'est pas lié alors j'en parle ensemble

Il m'arrive dans mon application que les controles ChexkBox disparaissent complétement et ne soient plus visibles. Ils sont pourtant fonctionnels !

Dans mon apllication il arrive parfois (surtout sur XP) que le contexte de peripherique change d'adresse ( rigolez pas !) . soit le dessin s'affiche donc ailleur, soit mon logiciel plante car le dessin ne se rafraichit plus...

une idée ?

MisterMok

4 réponses

vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
16 juin 2005 à 13:36
Ton DC change d'adresse, c'est normal, rien n'indique que tu dois
otenir toujours le même DC avec GetDC. Tu parle du DC de quelle fenêtre
exactement? Est-ce que tu libères bien tes DC? Ce serait un petit peu
plus clair si tu mettais un peu de code, car pour l'instant je
comprends pas trop ton problème.
0
djibasaran Messages postés 1 Date d'inscription dimanche 5 juin 2005 Statut Membre Dernière intervention 17 juin 2005
17 juin 2005 à 15:24
je veux un algorithme sur le jeux des allumettes
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
17 juin 2005 à 16:12
Voila qui risque de bien m'aider à t'aider
0
BarthOlivier Messages postés 132 Date d'inscription mercredi 6 mars 2002 Statut Membre Dernière intervention 27 novembre 2012 1
17 juin 2005 à 22:55
Je voie que la moquerie est de mise ... ( salut à toi djibasaran )

difficile de mettre un bout de code car tout est imbriqué.

peut-etre ca ? c'est ce que je fais normalement partout ...

void COscilloUSBDlg::OnPaint()
{
if(!Refresh)
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);


// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;


// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}


CRect rectAff;
CDC *pDC1 =m_color_CH1.GetDC();
m_color_CH1.GetClientRect(rectAff); PaintPDC(pDC1,rectAff,Systeme.Color.CH1);


CDC *pDC2 =m_color_CH2.GetDC();
m_color_CH2.GetClientRect(rectAff); PaintPDC(pDC2,rectAff,Systeme.Color.CH2);

CDC *pDC3 =m_color_CH3.GetDC();
m_color_CH3.GetClientRect(rectAff); PaintPDC(pDC3,rectAff,Systeme.Color.CH1);


CDC *pDC4 =m_color_CH4.GetDC();
m_color_CH4.GetClientRect(rectAff); PaintPDC(pDC4,rectAff,Systeme.Color.CH2);

CDC *pDC5 =m_color_CH5.GetDC();
m_color_CH5.GetClientRect(rectAff); PaintPDC(pDC5,rectAff,Systeme.Color.XY);

CDC *pDC6 =m_color_Curseur.GetDC();
m_color_Curseur.GetClientRect(rectAff); PaintPDC(pDC6,rectAff,Systeme.Color.CURSEUR);


RefreshGraph(this,true);
}

void RefreshGraph(PVOID para,bool All)
{
COscilloUSBDlg *Dlg=(COscilloUSBDlg*)para;
CDC *pDC1=Dlg->m_Picture1.GetDC();
CDC *pDC2=Dlg->m_Picture2.GetDC();


Dlg->m_Picture1.GetClientRect(rectAff1);
Dlg->m_Picture2.GetClientRect(rectAff2);


if(Systeme.LanceAcqui)
Redraw(pDC1,rectAff1,pDC2,rectAff2,Systeme.GraphTypeLine,Oscillo,All);
else
Redraw(pDC1,rectAff1,pDC2,rectAff2,Systeme.GraphTypeLine,SaveOscillo,All);


Dlg->ReleaseDC(pDC1);
Dlg->ReleaseDC(pDC2);


}

void Redraw(CDC *pDC1,CRect rectAff1,CDC *pDC2,CRect rectAff2,byte Mode,_OSCILLO pOscillo,bool All)
{
/************************************************************/
/************************************************************/
long lOscilloMaxData,Xea,Yea,i;
CRect MiniRect;
CBrush brush,*oldbrush;
double tempo;
/*--------------------------------------------------------*/
/* Recupere le context de peripherique et Affiche l'ecran */
/*--------------------------------------------------------*/
brush.CreateSolidBrush(RGB(192,192,192));

if(All) pDC2->Rectangle(rectAff2);
MiniRect=rectAff2;

AfficheEcran(pDC1,rectAff1,All);
/*--------------------------------------------------------*/
/* Boucle Tant que l'on a pas tout affiché */
/*--------------------------------------------------------*/
if(Acqui.Redraw.Enable)
{
//----------------------------------------------------------------------------//
if(!Systeme.LanceAcqui && All)
{
tempo = (double)MiniRect.right/8000*Acqui.Redraw.AdressStart;
MiniRect.left= (int) tempo;
tempo = (double)MiniRect.right/8000 * (Acqui.Redraw.AdressStart+Acqui.Redraw.NbEchantillons);
MiniRect.right=(int) tempo;


oldbrush=pDC2->SelectObject(&brush);
pDC2->Rectangle(MiniRect);
pDC2->SelectObject(oldbrush);

i=0;
lOscilloMaxData = 8000;
Yea = rectAff2.Height();
Xea = rectAff2.Width() / lOscilloMaxData;
Xea=0;
do
{
if(pOscillo.paraCANAL[0].On)AffichePoint(pDC2,rectAff2,Xea,Acqui.Buffer1[i],Systeme.Color.CH1);
if(pOscillo.paraCANAL[1].On)AffichePoint(pDC2,rectAff2,Xea,Acqui.Buffer2[i],Systeme.Color.CH2);
Xea = i++ * rectAff2.right/lOscilloMaxData;
}
while(i<Acqui.Redraw.AdressMax);
}
//----------------------------------------------------------------------------//
i=0;
lOscilloMaxData = 10*pOscillo.paraBASETEMPS.PointDiv;
Yea = rectAff1.Height();
Xea = rectAff1.Width() / lOscilloMaxData;
Xea=0;
if(Acqui.Redraw.AdressStart) Systeme.RedrawMemory=true;
do
{
Affichage(pDC1,rectAff1,Acqui.Redraw.AdressStart+i,Xea,Mode,pOscillo.paraCANAL[0].On,pOscillo.paraCANAL[1].On);
Xea = i++ * rectAff1.right/lOscilloMaxData;
}
while(i<Acqui.Redraw.NbEchantillons);
//----------------------------------------------------------------------------//
}
}

voilà je veux bien t'envoyer le code mais c'est barbare car tout imbriqué ... si tu peux m'aider Vecchio je suis preneur

sinon pour mon probleme de CheckBox qui disparait ? pas d'idée.... ?

MisterMok
0
Rejoignez-nous