I have a problem. I'm trying to create an application, which shows a rectangle on a grid. The position of the rectangle is subject to coordinates given from GPS simulator. The application is based on a single dialog window which involves a Picture Control. I set a type of that as Owner Draw. Then I created a class CPict, based on CStatic. CPict involves the OnPaint() method. Then I created a control variable of Picture Control. It's a CPict type variable named m_pict. In the class CGPSDlg there is the OnRead() method. To invoke that method, the user have to click a button. My question is: how to refresh the content of the Picture Control in OnRead() method. Here's some code:
You can use Invalidate to force a window to redraw itself.
Some notes on your code.
In the OnRead...
CComPort* pComPort = new CComPort(g_sComPort);
This is never freed, so you have a memory leak.
In the OnPaint...
You are creating a new window in the OnPaint. This will slow down your paint, because creating a new window is relatively a intensive job, and the OnPaint can be triggered a lot of times without you knowing it. Also, the class is new, so the m_nLatitude has it's default value, not the value you put in there during the OnRead function.
void SomeFunction ()
MyA->MyVariable = 10;
int main ()
varB.MyA = &varA; // set the pointer of varA
varB.SomeFunction (); // this function uses the varA-pointer to set MyVariable
Last edited by Skizmo; July 28th, 2010 at 06:29 AM.