Home > Software engineering >  MFC in how to make the EDIT CONTROL does not flicker problems
MFC in how to make the EDIT CONTROL does not flicker problems

Time:10-08

All the way to use the Internet, or not, here is the code I wrote, do you have miss place?

OnPaint code:
 CPaintDC dc (this); 
If (_font==nullptr)
{
_font=new CFont ();
_font - & gt; CreateFont (15,//nHeight
0,//nWidth
0,//nEscapement
0,//nOrientation
0,//nWeight
FALSE,//bItalic
FALSE,//bUnderline
0,//cStrikeOut
ANSI_CHARSET,//nCharSet
OUT_DEFAULT_PRECIS,//nOutPrecision
CLIP_DEFAULT_PRECIS,//nClipPrecision
DEFAULT_QUALITY,//nQuality
0,//nPitchAndFamily
_T (" Arial "));
}
If (_blackBrush==nullptr) {
_blackBrush=new CBrush ();
_blackBrush - & gt; CreateSolidBrush (RGB (0, 0, 0));
}

The CDC memDC;
MemDC. CreateCompatibleDC (& amp; Dc);

CRect rect;
GetClientRect (the rect);
CBitmap bitmap.
Bitmap. CreateCompatibleBitmap (& amp; Dc, the rect. Width (), the rect. Height ());
MemDC. SelectObject (bitmap);
MemDC. FillSolidRect (the rect, RGB (0, 0, 0));

Cstrings text;
GetWindowText (text);
MemDC. SetTextColor (RGB (255, 255, 255));
MemDC. SelectObject (_font);
MemDC. DrawText (text, 1, the rect, DT_VCENTER);

Dc. BitBlt (0, 0, the rect. Width (), the rect. Height (), & amp; MemDC, the rect. Left, the rect. Top SRCCOPY);
Bitmap. DeleteObject ();
MemDC. DeleteDC ();


OnEraseBkgnd code:
 BOOL LogOutEdit: : OnEraseBkgnd (pDC) CDC * 
{
Return TRUE;
}


OnCtlColor code:
 HBRUSH CmediaServerGuiDlg: : OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor) 
{
If (pWnd - & gt; GetSafeHwnd ()==_logOutEdit. GetSafeHwnd ()) {
PDC - & gt; SetBkMode (TRANSPARENT);
PDC - & gt; SetTextColor (RGB (255, 255, 255));
Return _blackBrush;
}
Return CDialogEx: : OnCtlColor (pDC, pWnd, nCtlColor);
}


Refresh the Edit code:
 int I=_logOutEdit. GetWindowTextLength (); 
If (Message=="\ \ \ \ \ b b b b b \ \ \ \ \ b b b b b"
"\ \ \ \ \ b b b b b \ \ \ \ \ b b b b b"
"\ \ \ \ \ b b b b b \ \ \ \ \ b b b b b"
"\ \ \ b b b) {
_logOutEdit. SetSel (I - 33, I);
}
The else
_logOutEdit. ReplaceSel (Message);
_logOutEdit. Invalidate (TRUE);

CodePudding user response:

I remember the UpdateData (FALSE); Can the

CodePudding user response:

If you refresh fast, every time I refresh the content does not repeat there must be a flickering effect,
In addition, I don't like to use the Edit to redraw; I'm suggesting you use ListBox to redraw, effect is better than the Edit

CodePudding user response:

refer to the second floor u011330815 response:
if you refresh fast, every time I refresh the content does not repeat there must be a flickering effect,
In addition, I don't like to use the Edit to redraw; I'm suggesting you use ListBox to redraw, effect is better than the Edit


The Log frame Microsoft visual studio is what's it made of? It's no refresh flickering problem

CodePudding user response:

New classes are derived directly from CWnd to draw
Refer to previous CSplashWnd class

CodePudding user response:

Int I=_logOutEdit. GetWindowTextLength ();
If (Message=="\ \ \ \ \ b b b b b \ \ \ \ \ b b b b b"
"\ \ \ \ \ b b b b b \ \ \ \ \ b b b b b"
"\ \ \ \ \ b b b b b \ \ \ \ \ b b b b b"
"\ \ \ b b b) {
_logOutEdit. SetSel (I - 33, I);
}
The else
_logOutEdit. ReplaceSel (Message);
_logOutEdit. Invalidate (TRUE);

The problem _logOutEdit. Invalidate (TRUE); You put your Edit the contents of the assigned to cstrings type then the UpdateData (false);

CodePudding user response:

Give you add the Edit controls a cstrings type string variable with the UpdateData (false);

CodePudding user response:

Don't understand "refresh Edit code:"?

CodePudding user response:

_logOutEdit. ReplaceSel (Message);//edit control is not the UpdateData
_logOutEdit. Invalidate (TRUE);//replace controls should refresh automatically, don't this

CodePudding user response:

Window to create a style to join WS_CLIPCHILD

CodePudding user response:

MemDC. FillSolidRect (the rect, RGB (0, 0, 0));
This sentence is brush edit all black, will, of course, flashing, should only really become part of the map such as
First "Ha Ha Ha Ha" later entered the Xixi, that can only draw Xixi, haha keep don't Fill it in black,
Is not very easy to get,

CodePudding user response:

The
references to the tenth floor schlafenhamster response:
memDC. FillSolidRect (the rect, RGB (0, 0, 0));
This sentence is brush edit all black, will, of course, flashing, should only really become part of the map such as
First "Ha Ha Ha Ha" later entered the Xixi, that can only draw Xixi, haha keep don't Fill it in black,
Is not very easy to get,

MemDC does not display, isn't it?
  • Related