Home > Software engineering >  MFC brush brush to run after a long time will fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MFC brush brush to run after a long time will fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Time:10-11


The above is normal, different colors of the brush, according to the normal
The image below is running after a period of time, it turned out to be the same color!!!!!!!!!!
What the devil

CodePudding user response:

Have the person ah ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

CodePudding user response:

The code is as follows:
Unsigned int color [4]={255255 * 255255 * 255 * 255255 * 255 * 255 * 100};
Long int num_to_change=point_num - disp_num;
CPen tPen2;
If (num_to_change & lt;=0)
Num_to_change=0;
For (unsigned char j=0; j<4. J++)
{
TPen2. CreatePen (0, 1, color [j]);
PDC - & gt; SelectObject (& amp; TPen2);

For (long unsigned int I=1; i{
PDC - & gt; MoveTo (X_basic + (I) * 50/XDispScale Y_basic buff_out - [(num_to_change) * scoll_position/100 + I - 1) [j] * 40/YDispScale);
PDC - & gt; LineTo (X_basic + (I + 1) * 50/XDispScale Y_basic buff_out - [(num_to_change) 100 + * scoll_position/I] [j] * 40/YDispScale);
}

}
//draw distance detection point
The CBrush tBrush2;
For (j=0; j<4. J++)
{
TPen2. CreatePen (0, 1, color [j]);//rxh1.9 brush decided to round the outside of the
PDC - & gt; SelectObject (& amp; TPen2);
TBrush2. CreateSolidBrush (color [j]);//rxh1.9 brush decided to round the inside of the
PDC - & gt; SelectObject (& amp; TBrush2);
for (i=0; i{
Int TmpCtDispX=X_basic + (I + 1) * 50/XDispScale;
Int TmpCtDispY=Y_basic - buff_out [(num_to_change) 100 + * scoll_position/I] [j] * 40/YDispScale;
PDC - & gt; The Ellipse (TmpCtDispX - 3, TmpCtDispY - 3, TmpCtDispX + 3, TmpCtDispY + 3);
}
}

CodePudding user response:

Mainly is the color of the thread with variable to see if changed

CodePudding user response:

PDC - & gt; SelectObject (elected to GDI resources need to restore

CPen * pOldPen=pDC - & gt; SelectObject (& amp; NewPen);
.

PDC - & gt; SelectObject (pOldPen)

CodePudding user response:

Check for leaks

CodePudding user response:

Search "GDI leak detection"
  • Related