|
Try code like this (instead of the AfxMessageBox call - since a message pump seems to be required):
UINT TimerId = SetTimer(NULL, 0, 5000, NULL);
MSG m;
BOOL bOk;
while ( (bOk=GetMessage(&m, NULL, 0, 0)) && bOk!=-1 )
{
DispatchMessage(&m);
if ( m.message==WM_TIMER && m.wParam==TimerId )
{
break;
}
}
KillTimer(NULL, TimerId);
Caveat:
I don't really know what's going on or what you’re trying to do or the over all structure of your program so this is just a guess. I have hard coded a 5 second delay. You will be able to use the UI of the app during this time - You may want to simulate modality by putting a call to disable the main app window before and another to re-enable it after. 9 times out of 10, when you put a hard coded delay in a program your doing the wrong thing: How long do you wait? Will this be long enough on a slower machine? If you wait long enough for a slow machine are you "cheating" users with fast machines?
Steve
|
|
|
|
|
these codes are to be put into a function in a class which is derived from a MFC class CDialog.
so when I copy the codes you provided, following errors occur:
error C2660: 'SetTimer' : function does not take 4 parameters<br />
error C2660: 'KillTimer' : function does not take 2 parameters
and I don't know how to call the two functions SetTimer and KillTimer of API version while there exists CWnd::SetTimer and CWnd::KillTimer
I don't much about these functions, so could you please tell me how do it?
Thank you very much!!!
-------------------
I am learning C++ and English
|
|
|
|
|
Put a "::" (two colons) in front of the effected functions. This will tell the compiler to use the global versions and not the member functions of the same name.
ie.
::SetTimer and ::KillTimer
Steve
|
|
|
|
|
thank you, Stephen Hewitt, I appreciate your help so much.
it works finally with your help!
in fact, it dosen't matter how long the time delay is set to be. I set it one milisecond, it works too
thanks a lot to all the other guys.
-------------------
I am learning C++ and English
-- modified at 2:09 Tuesday 10th January, 2006
|
|
|
|
|
ewighell wrote: in fact, it dosen't matter how long the time delay is set to be. I set it one milisecond, it works too
In that case you could try code like the following:
MSG m;
while ( PeekMessage(&m, NULL, 0, 0, PM_REMOVE) )
{
DispatchMessage(&m);
}
This is simpler. It dispatches all the messages in the message que then continues on - And no time delay.
Steve
-- modified at 2:48 Tuesday 10th January, 2006
|
|
|
|
|
EXTEIDE is freeware. Anyone can download now.
Please visit http://www.exteide.com
Thanks.
|
|
|
|
|
Please read #7 here.
About all you've managed to do with your post is keep folks here at CP from downloading it.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Please read #7 here.
Hm, at least "EXTEIDE is freeware". It's an announcement rather than advertising or soliciting.
|
|
|
|
|
Roland Pibinger wrote: Hm, at least "EXTEIDE is freeware". It's an announcement rather than advertising or soliciting.
not in VC++ forum.
-Prakash
|
|
|
|
|
This forum is for posting C++ questions, not advertising software.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
And you have made sure people don't trust that site with the way you have acted.
The tigress is here 
|
|
|
|
|
For some reason, I cant get any simple program, using
the new visual studio 2005, to compile if it has a CString
as a variable or if I use #include <fstream>.
I am extremely perplexed. I know that CString is equivalent
to const char * and I guess I could use that, but I really
liked being able to use CString and am hoping I still can
somehow. Also, if I want to open an ascii file and close
it, I use the #include <fstream> header, but I keep getting
an error with that line.
Any ideas?? Please, any response any one can give me will
be greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
DanYELL wrote: For some reason, I cant get any simple program...to compile...
DanYELL wrote: ...but I keep getting
an error with that line.
Why? What errors are you receiving?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Here is a common error I get using CString:
error C2664: 'strcpy' : cannot convert parameter 2 from
'CString' to 'const char *'
I use to pass a CString, but it doesnt recognize CString
anymore. If I pass const char *, it works?
If I type #include <fstream.h>, I get:
fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory
If I type #include <fstream>, I get more errors.
So Im stumped. Its a very simple program that compiles in
Visual C++ 6.0, but using Visual Studio 2005, I get errors that
I cant seem to get past.
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
DanYELL wrote: If I type #include , I get:
fatal error C1083: Cannot open include file: 'fstream.h': No such file or directory
Does the file exist on your machine? Are your paths (environment variables and IDE) set up correctly? One way to check is to right-click on the #include statement and select the "Open Document..." option.
DanYELL wrote: Here is a common error I get using CString:
error C2664: 'strcpy' : cannot convert parameter 2 from
'CString' to 'const char *'
What does the statement look like?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
> Does the file exist on your machine? Are your paths (environment
> variables and IDE) set up correctly? One way to check is to right-
> click on the #include statement and select the "Open Document..."
> option.
Shockingly, when I right-click on the include statement, it doesnt
seem to exist. Do I have to copy and paste that file in? It doesnt
make sense. Under the older compiler, it just existed. I didnt
have to add that class to the project.
Please, any response you can give me will be greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Here are 2-snippets of code that generate errors with CString:
if(strlen(ps->Text)==0)
return 2 * ps->PointSize;
Here I get:
'strlen' : cannot convert parameter 2 from 'CString' to 'const char *'
It doesnt recognize the CString.
And here:
LPCSTR CPage::SetFont(LPCSTR FontName)
{
static char buff[40];
strcpy(buff,m_PrtDesc.FontName);
if(FontName != NULL)
m_PrtDesc.FontName=FontName;
return buff;
}
I get:
'strcpy' : cannot convert parameter 2 from 'CString' to 'const char *'
|
|
|
|
|
DanYELL wrote: if(strlen(ps->Text)==0)
return 2 * ps->PointSize;
Why are you not using CString::GetLength() here?
In any case, if you must use strcpy() and strlen() , you'll need to use the Unicode version, or the macros defined in tchar.h :
_tcscpy()<br />
_tcslen()
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
1. I guess you are trying to include fstream, using "#include <fstream.h>". fstream.h is not a C++ header, but fstream is. Use it like this, "#include <fstream>"
2. Visual Studio 2005 C++ projects defaults to UNICODE. So CString in that build will convert to wchar_t not to char. Either change your project settings or use wchar_t version of strcpy.
Orhun Birsoy
|
|
|
|
|
DanYELL wrote: Cannot open include file: 'fstream.h':
The C++ std library headers ending in ".h" are very old, and apparently VC8 finally removed them. You should be using the STL version of any header file ("fstream", no extension).
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Michael Dunn wrote: The C++ std library headers ending in ".h" are very old, and apparently VC8 finally removed them
I'm surprised to hear that (I'm still using VC6). If true I'm sure we'll here some moaning from people when they upgrade to VC8.
Steve
|
|
|
|
|
I understand that I should try to write some codes that I know them firstly.
I understand that I should write my message carefully(there are people for check spelling)
I use search engine webpages like google instead of codeproject(there are people for making decision)
But because in IRAN students don't have anything that you have.
But because in IRAN students don't have technology.
But because in IRAN students don't have open sources document.
But because in IRAN students don't have original books.
and lablablab...
Please if you have a time to make a contact with me, here it's: vatanpoor@gmail.com
vatanpour@msn.com
Best Regards,
Pouya
|
|
|
|
|
You're programming. You said you have a book. So you have technology and a book.
Lucky you; I could not afford books during college, I've never opened a computer science book in my life. And I had to use crappy old lab computers to program at 2am during the rare moments that some computers were actually free. You have plenty of the things that we have.
Just try to do your homework next time before asking other people how to do it, that's all. You'll learn more that way, anyway, so it will benefit you more in the end. Nobody likes to see reliance on others for help when an attempt hasn't been made by the reliant individual to solve the problem in the first place.
If you did try to do the assignment and you were not able to, then great job. Good luck and if you have any specific questions please feel free to email them to me.
Kelly Ryan
|
|
|
|
|
Lucky you; I could not afford books during college, I've never opened a computer science book in my life. And I had to use crappy old lab computers to program at 2am during the rare moments that some computers were actually free. You have plenty of the things that we have.
From these words of Mr Kelly Ryan ,it has flared me up to work harder and committed to my work.Finally I am thankful to god for facilties he has provided me.
never say die
-- modified at 3:23 Saturday 7th January, 2006
|
|
|
|
|