Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Force UpdateData()

Status
Not open for further replies.

nbgoku

Programmer
May 25, 2004
108
0
0
US
how do i force UpdateData(0) to update when its requested to update, instead of waiting for it to update when all the looping is done in my program?
 
for example, lets say i got a edit box that i want to give the value "hi",

n = "hi"
UpdateData(0);
MessageBox("hi");
for
{
.... // alot of crap here
}

now the problem is, if i didnt put the message box, the program would first comlete all the damn for looping and then update the edit box to say hi, is there a way for force the program to show hi in the edit box before it starts all its longgggg for loop coding, instead of using MessageBox() to freeze the program allowing it to update (forcing it)

 
The problem is the UpdateData puts messages in the application's message queue that are not processed until the function returns back to the message loop, or you run an embedded message loop. The MessageBox function runs an embedded message loop. You can also run an embedded message loop yourself. There is an example on this MSDN page.
 
I had similar problem and could solve with following

n = "hi"
UpdateData(0);
........


while ( bDoingBackgroundProcessing )
{
MSG message;

if :):peekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
::TranslateMessage(&message);
::DispatchMessage(&message);
}

// Perform some background processing here
// ..............


}
 
...and there is of course always the option of using multi-threading. See faq116-5162

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top