I. waveform effect during program running
2. in signal processing, the Real-Time Waveform of the collected signal is usually displayed. If you directly draw a dynamic graph on the screen, it will flash. To overcome this problem, we will first draw the graph in the memory and then copy it to the screen, so as to achieve dynamic drawing without flashing. The details are as follows:
2.1 first define the following private variables in the header file and place a picture control in the dialog box resource
PRIVATE:
CDC * PDC; // screen plotting Device
CDC memdc; // memory Drawing Device
Int m_high; // Drawing start point
Int m_low; // drawing end point
Int m_lcount [1024]; // data storage array
Int m_now; // record the current waveform point
2.2 initialize the variable in the implementation file and set the timer
Bool cdrawtest: oninitdialog ()?
{
Cdialog: oninitdialog ();
// Todo: add extra initialization here
M_low = 0;
M_high = 1024;
M_now = 0;
Settimer (1,100, null );
Return true; // return true unless you set the focus to a control
// Exception: OCX property pages shold return false
}
2.3 create a memory drawing device in the timer and call the drawing function to draw the device in the memory. After the drawing is completed, copy the image in the memory device to the screen.
Void cdrawtest: ontimer (uint nidevent)
{
// Todo: add your message handler code here and/or call default
Crect rect;
// Retrieve the text box for drawing coordinates
Cwnd * pwnd = getdlgitem (idc_coord );
// Obtain the picture window handle in the dialog box
Pwnd-> getclientrect (& rect );
// Pointer
PDC = pwnd-> getdc ();
Pwnd-> invalidate ();
Pwnd-> updatewindow ();
// Memory plotting
Cbitmap membitmap;
Cbitmap * poldbmp = NULL;
// Create a memory Drawing Device
Memdc. createcompatibledc (PDC );
Membitmap. createcompatiblebitmap (PDC, rect. Right, rect. Bottom );
Poldbmp = memdc. SelectObject (& membitmap );
Memdc. bitblt (rect. Left, rect. Top, rect. Right, rect. Bottom, PDC, 0, srccopy );
// Customize the plotting function. For details, see the source program.
Drawwave (& memdc );
// Copy the memory drawing to the screen
PDC-> bitblt (rect. Left, rect. Top, rect. Right, rect. Bottom, & memdc, 0, srccopy );
Memdc. SelectObject (poldbmp );
Memdc. deletedc ();
Membitmap. deleteobject ();
Cdialog: ontimer (nidevent );
}
From http://c.chinaitlab.com/vc/917462.html