Home > Software engineering >  Double buffer display images, why not automatically updated in real time, need to switch to the mobi
Double buffer display images, why not automatically updated in real time, need to switch to the mobi

Time:11-18

For help, I want to realize such a function, the program start to read database data, memory generated in the two pictures, after on the interface circularly, now can generate and display images, but cannot be automatically move, need to switch out to switch back to the mobile, really don't know why, the code is as follows:
Public://to create a single cache to
//CDlgController dialog

The class CDlgController: public CDialog
{
The class CSingleQueuePic
{
Public:
Int nStartX;
Int nStartY;
Int nWidth;
Int nHeight;
The CDC MemDC;
CBitmap MemBitmap;
HBITMAP m_bitmap;
Int nPicNum;
Public:
CSingleQueuePic ()
{
NStartX=0;
NStartY=0;
NPicNum=0;
NWidth=0;
NHeight=0;
}
Virtual ~ CSingleQueuePic () {}
};
CSingleQueuePic * m_pSingleQueuePic;
COBList M_lstSingleQueuePic;
CSingleQueuePic * CreateSinglePage (COBList * m_SinglePageListQueue, CDC * pDC, int nNum);

};



//DlgController. CPP: implementation file

//to create a single bitmap, the program starts, perform a
CDlgController: : CSingleQueuePic * CDlgController: : CreateSinglePage (COBList * m_SinglePageListQueue, CDC * pDC, int nNum)
{
CSingleQueuePic * pSingleQueuePic=new CSingleQueuePic;
PSingleQueuePic - & gt; NStartX=0;
PSingleQueuePic - & gt; NStartY=0;
PSingleQueuePic - & gt; NPicNum=nNum;

//double cache refresh again when the splash screen solution 20181110
Int nWidth=m_recQueueCall. Width ();
Int nHeight=m_recQueueCall. Height ();

PSingleQueuePic - & gt; NWidth=nWidth;
PSingleQueuePic - & gt; NHeight=nHeight;

//the CDC MemDC;//define a first display device object
//CBitmap MemBitmap;//define a bitmap object

//then establish a compatible with screen display memory display device
PSingleQueuePic - & gt; MemDC. CreateCompatibleDC (NULL);
//below to create a compatible with screen display bitmap, the size of the bitmap, with the size of the window
PSingleQueuePic - & gt; MemBitmap. CreateCompatibleBitmap (pDC, nWidth, nHeight);
//will be chosen bitmap into memory display device in the
//only the memory for the bitmap display device is drawing, painting on the specified bitmap
CBitmap * pOldBit=pSingleQueuePic - & gt; MemDC. SelectObject (& amp; PSingleQueuePic - & gt; MemBitmap);

//use the background color first bitmap clean
//you can also use you should use the color of the
PSingleQueuePic - & gt; MemDC. FillSolidRect (0, 0, nWidth, nHeight, this - & gt; M_pController - & gt; M_clrControllerBackground);
CFont * pFont=pSingleQueuePic - & gt; MemDC. SelectObject (this - & gt; M_pFontQueueCall);
PDC - & gt; SetBkMode (TRANSPARENT);
Cstrings strBuffer=_T (" drawing test ");
CSize txtsize;
Txtsize=pSingleQueuePic - & gt; MemDC. GetTextExtent (strBuffer);

PSingleQueuePic - & gt; MemDC. TextOut (100, 100, strBuffer);
PSingleQueuePic - & gt; MemDC. SelectObject (pFont);

//copies a figure from a memory to the screen for display
//pDC - & gt; BitBlt (m_recQueueCall m_recQueueCall. Left, top, this - & gt; M_recQueueCall. Width (), and this - & gt; M_recQueueCall. Height (), & amp; PSingleQueuePic - & gt; MemDC, 0, 0, SRCCOPY);

HBITMAP HBITMAP=(HBITMAP) (pSingleQueuePic - & gt; MemBitmap);
This - & gt; SaveBmp (hBitMap, "D: \ \ tes1t BMP");

Return pSingleQueuePic;
}



//loop rolling images, OnTimer (), OnPaint () performed in the
BOOL CDlgController: : DrawQueueCall (pDC) CDC *
{
If (CRunTime: : GetGeneral () - & gt; M_bHideName)
This - & gt; M_bVideo=TRUE;
//
OBPOS POS=NULL;
LONG nLine=0;
//draw
For (CSingleQueuePic * pSingleQueuePic=this - & gt; M_lstSingleQueuePic. GetHead (POS); PSingleQueuePic!=NULL; PSingleQueuePic=this - & gt; M_lstSingleQueuePic. GetNext (POS), nLine++)
{
If (pSingleQueuePic!=NULL & amp; & PSingleQueuePic - & gt; NPicNum==0)
{
PSingleQueuePic - & gt; NStartY -=10;
If (pSingleQueuePic - & gt; NStartY<- m_recQueueCall. Height ())
{
PSingleQueuePic - & gt; NStartY=0;
}
PDC - & gt; BitBlt (m_recQueueCall. Left, m_recQueueCall. Top + pSingleQueuePic - & gt; NStartY, this - & gt; M_recQueueCall. Width (), and this - & gt; M_recQueueCall. Height (), & amp; PSingleQueuePic - & gt; MemDC, 0, 0, SRCCOPY);
}

//InvalidateRect (m_recQueueCall, TRUE);
}

Return TRUE;
}
Mr Using double buffer mechanism, into a bitmap, the rolling cycle, now the problem is mainly image need to change the program, is moving, a great god, please help to see, have two days,

CodePudding user response:

Where is the DrawQueueCall called?

CodePudding user response:

Ontimer and onpaint calls, switch can refresh the move, does not automatically move,

CodePudding user response:

reference 1st floor zgl7903 response:
where DrawQueueCall called?
Ontimer and Onpaint calls, please switch interface and then cut back can move images already, but the interface does not automatically move,

CodePudding user response:


 

BOOL CTestDlg: : OnInitDialog ()
{
CDialog: : OnInitDialog ();

//Set the icon for this dialog. The framework does this automatically
//when the application 's main window is not a dialog
SetIcon (m_hIcon, TRUE);//Set the big icon
SetIcon (m_hIcon, FALSE);//Set the small icon

//TODO: Add extra initialization here
The SetTimer (1, 2000, NULL);

Return TRUE;//return TRUE unless you set the focus to a control
}

Void CTestDlg: : OnTimer (UINT nIDEvent)
{
//TODO: Add your message handler code here and/or call the default
M_BitmpIndex=! M_BitmpIndex;
Invalidate ().

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related