Home > Software engineering >  ChartCtrl call addpoints uncertain times afxwin1. Ini 666 line error
ChartCtrl call addpoints uncertain times afxwin1. Ini 666 line error

Time:09-25

A project using the open source ChartCtrl draw graphs, I opened the EnableRefresh (false) to control automatically refresh, then when there are data call
 pLineSerie1 - & gt; ClearSerie (); 
PLineSerie1 - & gt; AddPoints (x, dYValue, DATA_COUNT);

Coordinate curve, run after a period of time will appear error, afxwin1. Ini 666 lines of error, the error code is:
 VERIFY (: : GetTextExtentPoint32 (m_hAttribDC lpszString, nCount, & amp; The size)); 

Baidu, I found there is a post and I like
 http://bbs.csdn.net/topics/270071437 

Probably reason is "working point thread calls to add the function of AddPoint (), AddPoint before () returns to call CWnd: : Invalidate () let ChartCtrl client area is Invalid, and generate a WM_PAINT message to the window of the message queue, not before the WM_PAINT message processing, such as Invalid () is returned, before drawing, should the CDC object may also be of the client area is Invalid,
But if at the same time, the worker threads to refresh window, using the CDC object of the client area of CChartCtrl may be rejected (in call Invalidate (), before the WM_PAINT message processing), so caused the GetTextPoint32 () function failure "
But how to solve this problem, drawing prohibit any home screen refresh, or main interface drawing ban drawing graph

CodePudding user response:

Multiple Threads in the User Interface of http://msdn.microsoft.com/zh-cn/library/ms810439.aspx

CodePudding user response:

In the thread interface is more troublesome thing,

PLineSerie1 - & gt; ClearSerie ();
PLineSerie1 - & gt; AddPoints (x, dYValue, DATA_COUNT);

These two lines of code is invoked in the thread?
If you can use a button to test? In the event of the button calls it, look to whether can appear error,

To control automatically refresh, in fact if your code is still in operation? Or completely by the control points to draw lines according to offer? If entirely control their picture, it should be to control their own problems, can consider to try a different version

CodePudding user response:

Try to add data before locking the refresh, add the unlocked

PCtrl - & gt; LockWindowUpdate ();
PCtrl - & gt; XXXXXXXX
PCtrl - & gt; UnlockWindowUpdate ();
PCtrl - & gt; Refresh

CodePudding user response:

Multithreaded MFC form control is very troublesome, prone to an estimated error, I am currently used method is to use STD: : condition_variable: : notify_one () + STD: : mutex waiting thread mechanism, avoid frequent, control object of duplicate messages

CodePudding user response:

reference zgl7903 reply: 3/f
try to add data before locking refresh, added the unlocked

PCtrl - & gt; LockWindowUpdate ();
PCtrl - & gt; XXXXXXXX
PCtrl - & gt; UnlockWindowUpdate ();
PCtrl - & gt; Refresh
thank you very much for your reply, I'll give it a try, I now is to cut down the Refresh rate
  • Related