|
Hey all I need some "C++ 101" help,
I am working on a function that reads in a string and converts it into a CTime, using atoi( ) . The function declaration is
bool ConvertTimeStr(const CString& TimeStr, CTime& Dest)
any suggestions on how I can convert a string such as "12:00:00" into 12:00:00
|
|
|
|
|
GRAMI04 wrote:
any suggestions on how I can convert a string such as "12:00:00" into 12:00:00
Read this: Date and Time in C++[^]
-Nick Parker
|
|
|
|
|
The quoted article will help I'm sure, but I have found the following 2 approaches to be useful, alone or in combination.
1) The MFC COleDateTime class provides some string parsing capabilities, and you can then check the GetStatus() return code.
2) Alternatively, you could try something like:
bool ConvertTimeStr(const CString& TimeStr, CTime& Dest)
{
int hh, mi, ss;
char ch;
// ch catches junk beyond end of string
if (sscanf(TimeStr, "%d:%d:%d%c", &hh, &mi, &ss, &ch) != 3)
return false
// now check for valid days of month etc.
// The MFC classes can be used to do this.
return whatever!!
}
|
|
|
|
|
I am confused ...
I have a Visual C++ 6 application.
When I run this application in the Visual C++ IDE
and I end the application I will get an "Unhandled Exception in server.exe (NTDLL.DLL): 0xC0000008: Invalid Handle." error.
But when I am running only the exe without the IDE there is no error!
What's the reason?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
You need to be more specific about the problem, without this you will not be able to get help.
Reproduce your problem in a few lines of code. In doing so you may solve the problem yourself, but if not you will be able to be more specific and others can help you.
Cheers,
Rob.
|
|
|
|
|
I think that's not a problem of my application (of my source code), because this error is only displayed when I run the application in the Visual C++ 6 IDE.
When I run the simple exe (without Visual C++ 6 IDE) or in the Visual .NET 2003 IDE there is no problem, all works fine!
The problem is only when I run the application in the Visual C++ 6 IDE!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Right now my project title when the app runs is Str - Str1...its an MFC mDI project. I had named my project Str for brevity. But I really want the application to have a formal title like "My Project" and I dont want the Str1 part that seems to tag along. How do you set this?
Appreciate your help,
ns
|
|
|
|
|
Look for the string table entries IDR_MAINFRAME and IDR_xxxTYPE - the main window title is stored in these entries (note that the type string table entry has multiple values separated by newlines).
Dave
|
|
|
|
|
Thanks!
Appreciate your help,
ns
|
|
|
|
|
Hi,
A newbie question:
Nowadays, I am using ADO to access to my mdb file, when i first runs my app the harddrive is getting busy for a few(6-7) seconds to read the data. I want to know that if i use xml for data handling how my app will behave??? Is it fast or slow or what???
Thanx...
|
|
|
|
|
X!M!L! .... X!M!L! .... X!M!L!...
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
It will depend on your needs:
XML is fast, clean and very interesting if you have only to ask for tree structured data, but if you need to use different queries on your database, you'd prefer to use a database because the work of create the different queries based on the different tables... will be done easier...
hope this helps...
|
|
|
|
|
can anybody advise me, what do I have to do for providing steady connection, right receiving data, if server is written for Linux? can you tell me all the needed details for making this right. thank you.
|
|
|
|
|
Do you want to learn network programming?
Learn Winsock, how you create and connect to a server can you find here on CP. Look in the Network & Internet section.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
What do you mean "right?" Data is the same through a socket no matter where it originated.
Kuphryn
|
|
|
|
|
I am talking about such things like "htoln" and "ntohl" and it's usage
|
|
|
|
|
Hello,
let's say we gave window A and in that window I process a WM_TIMER message.
The timer message arises from another window (SendMessage(WM_TIMER...)) each 10 ms...
I want to know if it is possible to destroy the window while the WM_TIMER handler is being processed.
PS:
I'm searching for a memory leak:
during the WM_TIMER message I allocate and deallocate some memory, and in one hand if I enter and exit the window continuously, the memory gets leaked. In the other hand if I do it slowly the memory gets freed as it should be...
Thank you in advance
|
|
|
|
|
One problem here is that you are misusing the WM_TIMER message. It would be better to have the second window to send a user-defined message (based on WM_USER or WM_APP ).
Secondly, since you are using SendMessage , the second Window is blocked until the first Window processes the message. WM_TIMER messages receive special handling by Windows. Essentially, WM_TIMER messages are only processed by a window when it has no other messages in its queue. They are the least priority messages of all. Without seeing your code, this may be the source of your problem, in that the WM_TIMER handler isn't being called as many times are you are issuing it.
Software Zen: delete this;
|
|
|
|
|
Hello,
Gary R. Wheeler wrote:
this may be the source of your problem, in that the WM_TIMER handler isn't being called as many times are you are issuing it
Could you explain it again? sorry, but I do not understand this very well:
You are telling me that the sending of the message is what occupies memory?
I like the fact of the WM_TIMER message has the least priority, because I'm using it in order to refresh some values:
NOTE:
I have an external programming language that allows me to read from sensors and to send signals to actuators (moving machines), and I need to get info. from that program, as it don't have callback functions that would allow me to do that I use timer events, and each 10ms I spread the WM_TIMER message from my main window to all their visible childs. Once the WM_TIMER message is received I process those variables.
I have tried to place a for( ;; ) before the portions of code that could generate memory leaks, but I've seen using the task administrator and other tools from Microsoft and I've noticed that the memory remains OK.
The fact is that if I enter the dialog (the one that seems to leak memory) and wait a little bit, and then I exit it seems that the memory is not being occupied, but in the other hand, if I enter and exit the same dialog fast and continuously then the memory seems to be leaked...
I'm very stuck by now, and this is part of a project that is already working, but after some hours the PC gets down, I need to solve this, could you try to find out something using the info I've given to you?
Thank you in advance.
|
|
|
|
|
Hello, I'm posting this here in order to avoid you working for nothing:
I'm sure that the problem is not in my timer (I've deleted it) and the problem is still here (moreover this method of working has been used by me for a long time 3 years at least and this has never happened...).
I've noticed that some DLL's related to the internet explorer, fails and generate an exception the first time that the dialog is shown, I'll post another question in the forum in order to try to get help, but after all, thank you for your reply.
|
|
|
|
|
hit an exit(0)
it does wonders !
//be cool
I am the mighty keeper of the book on knowledge . Contact me to get your copy .
|
|
|
|
|
Hi there,
When i was using VC++ 6 i was using Depends 2.x for looking for dlls and other external files that my project uses. Now i had to transfer my projects to VS.NET and i couldn't find Depends 2.x in the package series so if anybody knows how can i look the dlls that my releases are using plz reply to this post... Thanx...
|
|
|
|
|
It is in:
...\Microsoft Visual Studio .NET\Common7\Tools\Bin
but I think you may have had to specify that you wanted the tools installed as part of your studio installation.
If you don't have it maybe someone knows where you can download it from Microsoft. It is a great little tool.
Art
|
|
|
|
|
I have it... Thanx for your help...
|
|
|
|
|