Home > Software engineering >  Interface double-buffering flickering problem and the configuration of the vc
Interface double-buffering flickering problem and the configuration of the vc

Time:09-21

Use vs2017 enterprise 2017 wrote a program
Question 1
Double buffer drawing, but found that the content changes of interface will blink
Shouldn't normal in memdc drawing then bitblt SRCCOPY program will finish painting the unified interface to submit to memory and display, there should be no flash,
Don't know where there is a problem,

Question 2
How feeling vs project properties changed no matter use, one is changed the unicode/multibyte attributes of the project, the results showed that the default or unicode characters inside, also rebuild, compile the project configuration debug/x86 and compiled version is the same, I don't know why
With other jsoncpp parsing json, add the project source code to the project, and put the json this directory under the project directory
Json - & gt; 1. SRC 2. Json (include) put this header file directory is in the include path in the project properties, how also doesn't work as a result, the include & lt; Json/xx. H> Compile prompt can not find a file, yao vs va can identify the file path, eventually to include "json/json/xx. H" just that, in the normal to the include directory Settings can be directly after & lt;> Contains, strange question, arguably, not that ah, vc also used a lot of version, should also not didn't understand it,

Beginning the code below OnPaint scintillation
 
CRect rc;
GetClientRect (& amp; Rc);

CPaintDC dc (this);//screen DC
The CDC memDC;//memory DC, construct a DC
CBitmap memBitmap;//constructs a BMP object
MemDC. CreateCompatibleDC (& amp; Dc);//a memory dc compatible with, it is double buffer drawing method, to draw to a memory dc
MemBitmap. CreateCompatibleBitmap (& amp; Dc, rc. Width (), the rc Height ());//create a BMP object, m_nWidth m_nHeight is size
MemDC. SelectObject (& amp; MemBitmap);//put the BMP in the memory dc, cannot use dc screen
MemDC. SetBkMode (TRANSPARENT);//let the text background is transparent
HDC HDC=memDC. M_hDC;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
If (: : GetProp (m_hWnd, _T (" SERVER_STATUS_DC "))) {//remove CacheDC
: : SelectObject (m_hCacheDC m_hOldCacheBitmap);
: : DeleteObject ((HGDIOBJ) m_hCacheBitmap);
}
The else {
: : SetProp (m_hWnd, _T (" SERVER_STATUS_DC "), (HANDLE) m_hCacheDC);//the main window has added a attribute cacheDC
}
M_hCacheBitmap=CreateCompatibleBitmap (dc m_hDC, rc. The Width (), rc, Height ());
M_hOldCacheBitmap=(HBITMAP) : : SelectObject (m_hCacheDC m_hCacheBitmap);

//move to onerasebackground
MemDC. FillSolidRect (& amp; Rc, m_bgcolor);

int i;
for (i=0; I & lt; M_regions. The size (); I++)
{
PaintRegion (rc, memDC m_regions [I]);
}


: : BitBlt (m_hCacheDC, 0, 0, rc. The Width (), rc, Height (), hDC, 0, 0, SRCCOPY);
Dc. BitBlt (0, 0, rc. Width (), rc, Height (), & amp; MemDC, 0, 0, SRCCOPY);

CodePudding user response:

1 BOOL Cxxxx: : OnEraseBkgnd (pDC) CDC *
{
return TRUE;
}

CodePudding user response:

Seems less, there is a static text will flash,
Other custom painting part seems to be better.

CodePudding user response:

OnPaint draw their own Invalidate the child window at the same time,
1 all draw child window code will be invalid on OnPaint,
2 all drawing must be drawn to a child window memDC

CodePudding user response:

@ schlafenhamster
Didn't quite understand if the interface is part of the figure is drawn, part is to use the existing controls, need what to do
Custom painting must be paint memdc existing controls to memdc need how to draw and paint?
A theory is combined with WS_CLIPCHILDREN properties, feasible?

CodePudding user response:

Void CxxxxDlg: : CopyPictures (HWND HWND, CPoint point)
{//TODO: Add your message handler code here
UINT ID=: : GetDlgCtrlID (hWnd);
//afxDump & lt; //the size
CRect rc;
If (hWnd==0)
{
ID=0;
GetWindowRect (& amp; Rc);//the dialog
}
The else
{
: : GetWindowRect (hWnd, & amp; Rc);
}
//create dc
CClientDC dc (this);
The CDC dcMem.
DcMem. CreateCompatibleDC (& amp; Dc);
//create the empty BMP
HBITMAP BMP=CreateCompatibleBitmap (dc/* not */dcMem, rc. The Width (), rc, Height ());
DcMem. SelectObject (BMP);
//
Cstrings prompt;
The switch (ID)
{
Case IDOK://"Exit"
M_Ok. SendMessage (WM_PAINT, (WPARAM) dcMem. M_hDC, 0).
Prompt="" Exit \ "button has had copied to clipbroad!" ;
break;
Case IDC_SCROLLBAR1://"H bar
"M_hBar. SendMessage (WM_PAINT, (WPARAM) dcMem. M_hDC, 0).
Prompt="" Horizontal \ "scrollbar has had copied to clipbroad!" ;
break;
Case IDC_SCROLLBAR2://"V bar"
M_vBar. SendMessage (WM_PAINT, (WPARAM) dcMem. M_hDC, 0).
Prompt="" Vertical \ "scrollbar has had copied to clipbroad!" ;
break;
Case IDC_SHOW://"Open"
M_Open. SendMessage (WM_PAINT, (WPARAM) dcMem. M_hDC, 0).
Prompt="" Open \ "button has had copied to clipbroad!" ;
break;
Case IDC_PICTURE://m_Pic
OnMyPaint ((WPARAM) dcMem. M_hDC, 0).
Prompt="" CStatic Picture \ "has had copied to clipbroad!" ;
break;
Case 0://the dialog
This - & gt; SendMessage (WM_PRINT, (WPARAM) dcMem. M_hDC,
(LPARAM) (PRF_NONCLIENT | PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_OWNED));
Prompt="" The whole dialog \ "has had copied to clipbroad!" ;
break;
}
//move BMP to clipboard
CBitmap * PBMP=dcMem. GetCurrentBitmap ();
OpenClipboard ();
EmptyClipboard ();
SetClipboardData (CF_BITMAP PBMP - & gt; GetSafeHandle ());
CloseClipboard ();
//
DeleteObject (BMP);
//
AfxMessageBox (prompt);
}

Usually OnPaint no parameters, so use
M_Ok. SendMessage (WM_PAINT, (WPARAM) dcMem. M_hDC, 0).

CodePudding user response:

Controls in the dialog box to draw
 
CDialog: : OnPaint (); Hair to Invalidate child window, the child window is invalid
//CStatic m_Pic2;
M_Pic2. UpdateWindow (); The child window and effectively!
The CDC * picDC=m_Pic2. GetDC (); Take child window dc
CRect rc;
M_Pic2. GetClientRect (rc); Take the child window client area
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related