How to update a Edit Control as fast as possible?

  • Thread starter Thread starter larry
  • Start date Start date
L

larry

In my program I tried to update a edit control's text very fast, but It
seems there's no time to update it.
Following is my code. IDC_EDIT1 is a edit control;

//***************************
CString strTest;
for(int i=0;i<10;i++)
{

strTest.Format("%d",i);
CWnd* pwnd=GetDlgItem(IDC_EDIT1);
pwnd->SetWindowText(strTest);
Sleep(200);
}
//*******************************

I tried to add pwnd->Invalidate(TRUE); before Sleep(200); but it doesn't
work. Would you like to help me? I really appreicate your time and
help.

Regards,

Larry


Larry
 
You need to pump the message queue. Calling Sleep() simply freezes your
application for the duration of its call.

Brian
 
larry said:
In my program I tried to update a edit control's text very fast, but It
seems there's no time to update it.
Following is my code. IDC_EDIT1 is a edit control;
...
I tried to add pwnd->Invalidate(TRUE); before Sleep(200); but it doesn't
work. Would you like to help me? I really appreicate your time and
help.

The Invalidate method just marks the client area as need an update.

As Brian implies, when your application removes and dispatched the paint
message ( a low priority message, btw), the job will be complete.
Alternatively you can call ::UpdateWindow() after invalidate which causes a
paint message to be processed if the update region is not empty.

Regards,
Will
 
Thank you very much for your help. UpdateWindow() works. I really
appreciate your help.

Have a good day.

Larry

Larry
 
Back
Top