|
what does your call(&a) function do. Does it take a lot of time to get the processing done. May be it would be too fast for you to see the change from "in progress" to "success". Won't be a good idea, but try putting some Sleep(/*timeinterval in msec (may be 10000)*/) and notice the change. The sleep should be placed beween the two SetPaneText [just before s="success"]. if it doesn't show "in progress" you need to check elsewhere
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
It is because you only have one thread: the message queue of your application is processed in the same thread as the rest of your application code. It means that if you do a lenghty process in one of your function, you won't be able to process messages anymore, which means your GUI seems frozen and is not updated (thus, you won't be able to see your text on the status bar). The solution is to start a new thread and put your lenghty process there. Once finished, you can send a message to your main window so that it can change the text of the status bar.
|
|
|
|
|
i have the same problem even after implementing that long call(); operation in a thread!!!!
Raja
|
|
|
|
|
Because you are immedaitely calling second SetPaneText(..)
If you just wanna check try commenting second call.
Regards,
Sandip.
|
|
|
|
|
I think you are not able to see the chane from "In Progress" to "Success".Try to add sleep for some seconds between both.
-@SuDhIrKuMaR@-
|
|
|
|
|
And how will be your messages processed ?
You can put as much Sleep as you want, if you block the main thread, your UI will be frozen and no messages will be processed (so, your text won't be updated neither).
|
|
|
|
|
CString s="in progress";
m_wndStatusBar.SetPaneText(0,s);
Sleep(3000);
s="success";
m_wndStatusBar.SetPaneText(0,s);
This code will display first "InProgress" then after 3 seconds "sucess" will be displayed.
-@SuDhIrKuMaR@-
|
|
|
|
|
Yes you are right, I tested it.
Anyway, it still isn't good practice to do so: your UI will be totally frozen (with the button pressed) the time it takes for the processing. If it takes really a long time, then it is better to put that processing in a separate thread so the the UI is not affected.
|
|
|
|
|
i tried both sleep and thread methods...both doesn't work!!!!!!
Raja
|
|
|
|
|
How long do you Sleep ? And how much time is your operation taking ?
|
|
|
|
|
sleep is for 4000...and my operation is less than that..iam sure abt that...as print statements given before that prints the sring...but the status bar updates is not shown
Raja
|
|
|
|
|
Could you describe exactly what's happening and what you expect ?
The code that was given to you as example should print "in progress" in the status bar for 5 seconds (depends of the Sleep time) and then it will be replaced by "sucess".
What happens if you just take the code that was given to you and remove your call (just keep the SetPaneText calls and the Sleep) ?
|
|
|
|
|
i have done the following in my code...and i have my progress bar too in my status bar in the second pane....i need "inprogress" to be displayed first and then the " complete" text...but inprogress doesn't get displayed...what should be done
void test::OnLbnSelchangeList1()
{
void (*ptr)(void )=function;
thread_data td;
while(1)
{
if(Complete == 1)
{
indx=list.GetCurSel();
s="in progress";
m_bar.SetPaneText(0,s);
td.threadentry=(LPTHREAD_START_ROUTINE)ptr;
td.hdArg=NULL;
td.udiCreationFlags=0;
CreateThread(NULL, 0, td.threadentry, td.hdArg, (unsigned long) td.udiCreationFlags, (td.udiThreadId));
pPrgCtrl->SetPos(0);
while(1)
{
if(Complete==1)
{
pPrgCtrl->StepIt();
break;
}
}
break;
}
}
Sleep(200000);
pPrgCtrl->SetPos(100);
printf(" complete\n");
s=" complete";
m_bar.SetPaneText(0,s);
}
Raja
|
|
|
|
|
Mohanraj D wrote: ...the s="in progress" doesn't get displayed and only "sucess" is displayed finally,what's wrong with the code.
What is the value of i ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i don't have an i in my code
Raja
|
|
|
|
|
Sure you do. Check again.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
What happens if you comment out the second SetPaneText() statement? Does "in progress" remain in the status bar?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
sorry...if i comment the secondsettext the first one is getting displayed ie in progress is displayed
Raja
|
|
|
|
|
Could it be that the code in between the two calls to SetPaneText() is just happening too fast?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
no,its a long process...it takes 3 to 4 mins
Raja
|
|
|
|
|
It sounds as though your long process is taking up all of the CPU such that the first SetPaneText() does not get a chance to paint (i.e., the WM_PAINT message has not been processed).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
so ...what should be done to slove this problem???i need the gui updates to be shown along with the process
Raja
|
|
|
|
|
Mohanraj D wrote: so ...what should be done to slove this problem
I would use a secondary (worker) thread to do the work. That way the primary thread can remain responsive and handle painting.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi Friends,
Can I do something like this ? Is it portable across all platforms ?
<br />
int* ptr = new int();<br />
int& tmp = *ptr;<br />
delete &tmp;<br />
|
|
|
|