Home > Software engineering >  Everyone a great god for guidance! Using MFC to do a interface, a machine under every two seconds vi
Everyone a great god for guidance! Using MFC to do a interface, a machine under every two seconds vi

Time:09-24

Everyone a great god for guidance! Using MFC to do a interface, a machine under every two seconds via a serial port pass data to the PC, now receives data from the serial port, to rectangular, according to the data real-time onpaint function called how ah, or how to use these data to draw ah, now I am in the heart of the class in the serial data to the onpaint, then set a timer, every two seconds to invalidate and updatewindow, but can't window display graphics, please everyone a great god some directions, I is based on the MFC dialog application

CodePudding user response:

Assuming that the received data is a rectangular coordinate points, two kind of situations:
1, updated in real time, the UI is only above a rectangular display don't erase the last time, that this kind of situation, only need to set a member/global variables, a serial port receives the data changes of the variables, and then call the CDC painting, rather than using the timer!!!!!
2, live more analysis, UI shown above multiple rectangular, don't erase the last time, then use the vector or a queue to store, a serial port receives the rectangular coordinates push_back, every time the timer callback CDC draw this list or queue

CodePudding user response:

Play against the above, 1 kind is showing only one, the second is multiple

CodePudding user response:

reference 1st floor wangningyu response:
assumes that the received data is a rectangular coordinate points, two kind of situations:
1, updated in real time, the UI is only above a rectangular display don't erase the last time, that this kind of situation, only need to set a member/global variables, a serial port receives the data changes of the variables, and then call the CDC painting, rather than using the timer!!!!!
2, live more analysis, UI shown above multiple rectangular, don't erase the last time, then use the vector or a queue to store, a serial port receives the rectangular coordinates push_back, every time the timer callback CDC draw this list or queue data can

That's what I did I was in the class defined in a variable and then draw the rectangle in the onpaint also use the same variable data changes still can't display graphical ah thank QQ1361055847 can explain a private conversation

CodePudding user response:

The CWnd: : OnEraseBkgnd
Afx_msg BOOL OnEraseBkgnd * pDC (CDC);

The Return Value

Nonzero if the it erases the background; Otherwise 0.

The Parameters

PDC

Specifies the device - the context object.

Few

The framework calls this member function when The CWnd object background needs erasing (for example, when resized). It is called to prepare an invalidated region for painting.

The default implementation erases The background using The window class background brush specified by The hbrBackground member of The window class structure.

If the hbrBackground member is NULL, the your overridden version of OnEraseBkgnd should erase the background color. Your version should also align the origin of the intended brush with the CWnd coordinates by first callingUnrealizeObject for the brush, and then selecting the brush.

The An overridden OnEraseBkgnd should return nonzero in response to WM_ERASEBKGND if it the processes the message and erases the background; This are that no further erasing is required. If it returns to zero, the window will remain marked as needing to be erased. (Typically, this means that the fErase member of the PAINTSTRUCT structure will be TRUE.)

Windows assumes the background is computed with the MM_TEXT mapping mode. If the device context is using any other mapping mode, the area erased may not be within the visible part of the client area.

Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to the function reflect the parameters received by the framework when the message was received. If you call the base - class implementation of This function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.

CWnd Overview | Class Members | Hierarchy Chart

See Also WM_ICONERASEBKGND CGdiObject: : UnrealizeObject, WM_ERASEBKGND
  • Related