|
hi
i have a newbie question
how to pause execution of a code block
without sleep effect
for example :
void somefunc()<br />
{<br />
SetWindowText(hWnd,"hello");<br />
WaitFor(5000); <br />
SetWindowText(hWnd,"good bye");<br />
}
when WaitFor() called, application must continue
execution other functions and application must response to other function calls
finally i don't want to sleep complete application when waiting
thans
|
|
|
|
|
Use a timer for that. This will be different than your code snippet because the two calls to SetWindowText will be located in two different parts: the second one will be in response of a timer event.
You can't "wait" in a function a still continue to process messages from the UI (which is in the same thread), unless you pump the message loop, but it is quite ugly in your situation.
|
|
|
|
|
thanks for your quick reply
but it is a Dll how can i use a timer in a dll
is there any idea for that
when i call , a wait function from dll
i want to call another function from dll at a time
but first call freezes main application already
and dll is not responding
thanks
|
|
|
|
|
You can also use a multimedia timer. The timer callback will occur on
a different thread so you don't have to worry about your UI going dead
or pumping messages.
Multimedia Timer Reference[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
One technique that sometimes works is simply pumping the message que while waiting.
void YourClass::somefunc()
{
SetWindowText(hWnd,"hello");
SleepWithEvents(5000);
SetWindowText(hWnd,"good bye");
}
VOID YourClass::SleepWithEvents(int Millisecs)
{
ULONG Ticks = GetTickCount();
while(GetTickCount() < Ticks + Millisecs)
DoEvents();
}
VOID YourClass::DoEvents()
{
MSG oMSG;
while(::PeekMessage(&oMSG, NULL, 0, 0, PM_NOREMOVE))
{
if(::GetMessage(&oMSG, NULL, 0, 0))
{
::TranslateMessage(&oMSG);
::DispatchMessage(&oMSG);
}
else
{
break;
}
}
}
Best Wishes,
-David Delaune
|
|
|
|
|
OPen a thread, wait for n number of second there and initimate the windows to print setwindow again!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
ThatsAlok wrote: OPen a thread, wait for n number of second there and initimate the windows to print setwindow again!
i tried it,but i could not figure it out,and not successed
but success one of my attempts, taken a sleep effect
can you show me a working example
|
|
|
|
|
i have a modeless dialog box. and in my first dialog box i have some values. the same values needs to be shown in the modeless dialog box also. i am getting an exception. not being able o figure out what it is.
i have created a member variable for the class and i can also access the members of the class. but i am not being able to pass the value.
in the second dialog box i have an edit control which is of type CString.
|
|
|
|
|
Chandrasekharanp wrote: i am getting an exception.
Did you try to debug your program to pinpoint where the problem occurs exactly ? Use the callstack to locate the problem in your code when the crash occurs.
Without having more information, we can't really help you. We need some relevant piece of code (don't paste the complete source files ). If you can't fix the problem using your debugger, provide also the info you gathered with it.
|
|
|
|
|
i had added DoModal() which i should not have done.. now i am not getting that exception. but the value is not being updated on dialog2. but when i debug in the watch list the value is updating.
|
|
|
|
|
Please read my previous answer and provide the required information. I'm still not able to read what's written on your screen (although I'm trying hard, it's probably because of the distance...)
|
|
|
|
|
Hey man, you're a CP 's MVP : charge your CPMRU 's (Code Project Mind Reader Unit) battery pack and start helping that guy!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
It seems broken, I probably tried to use it too much recently
|
|
|
|
|
Looks like these days we need to boot up the CPMRU for answering almost 90% of the posts.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Unfortunately soooo true
|
|
|
|
|
And:
(1) "First Google about" (8%)
(2) "Please don't use CString::GetBuffer for such things" (1.5%)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Tough being a man.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
We live in hard times.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
are you calling updatedata() to reflect the changes on dialog box.
|
|
|
|
|
When you are opening modeless dialog?
You add same type of variable to modeless dialog class, before creating it assign first dialog value to modeless dialog variable, after creating it, show the value.
Chandrasekharanp wrote: in the second dialog box i have an edit control which is of type CString.
Hi Edit controls are of type CEdit. Did you mean you have control variable for edit control?
Thanks,
Suman
|
|
|
|
|
Hi,
I am using the MFC doc/view framework to do the printing in my application but it isnt clear what I need to do to print multiple copies (as entered by the user in the print dialog). I can retrieve the number of copies but where do I use it? I figured that Windows print manager or the framework would do all the work involved but it doesnt seem to work so maybe I need to do something.
Any ideas?
Tony
|
|
|
|
|
I'm a little surprised that the basic MFC framework doesn't handle that for you.
But printing is harder than it looks! MFC glosses over some details, but the moment you deviate a little, you're on your own.
I strongly recommend Roger Allen[^]'s articles for reading. Many of them are involving printing, and all are good.
I vaguely remember him buying me a pint once...
Iain.
Iain Clarke appears because CPallini still cares.
|
|
|
|
|
Hello All
i need a DirectX tutorial using MFC.
|
|
|
|
|
You should know there's a wonderful thing called CP article search engine [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
How to cast a float expression into int safely without data loss?
Is there any standard function for this other than just casting like(int) ?
Best Regards,
Suman
|
|
|
|