|
is that the only way i can do?
since i need to do calculation of the time, such as add and subtract...
for example
time is 001100123 (better way to see is 00:11:00:123)
if I need to subtract an hour from it, the new time is 23:11:00:123
|
|
|
|
|
sugarandcream wrote: is that the only way i can do?
There's more than one way to skin a cat.
sugarandcream wrote: since i need to do calculation of the time, such as add and subtract...
Once you get the time string into a common time structure/format, adding and subtracting is easy.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
In a C++ app I want to send a text message from the main thread to a client thread whose sole job will be to call MessageBox to display the text when it gets a message. Looks like some version of postmessage and getmessage might work, but reading about them seems more confusing than clarifying.
Initially this will be used for exception messages, so the rates would be very, very few, if any, on a given day.
Any suggestions would greatly be appreciated.
Thanks
ak
|
|
|
|
|
Alan Kurlansky wrote: ...client thread whose sole job will be to call MessageBox to display the text when it gets a message.
Not a good idea to do this from a secondary thread. What are you ultimately trying to do?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I want to send a text message from the primary thread to a secondary thread to popup to user, after which they hit ok and the popup text window will disappear. The goal is to not cause the primary thread to halt waiting for the user to click ok, because the primary thread is processing high speed, real time data.
|
|
|
|
|
Alan Kurlansky wrote: The goal is to not cause the primary thread to halt waiting for the user to click ok...
But that's exactly what will happen. The primary thread should handle all user interface items, while the secondary thread should handle all of the data processing stuff.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You may end with many messages opened in the secondary thread...
But to do that, you must:
Create a window in the secondary thread (to have a handle).
In the primary thread, call PostMessage (as send message blocks waiting for the result)
Pass the string (char *) as the LParam of the PostMessage.
And, of course, in the other thread, when the message arrives, you must cast the LParam to (char *).
That's all.
(ah, I am not sure, but I think there is a PostThreadMessage and some WaitMessage function, but I actually don't use C++ so I can't tell that for sure).
|
|
|
|
|
Alan Kurlansky wrote: because the primary thread is processing high speed, real time data.
That's precisely what worker threads are for! You shouldn't be putting such heavy processing on the primary thread. Your approach is flawed.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Hey Guys,
I have an intresting problem for everyone to consider. One of my software projects reads and writes files to the system directory. It automatically detects the location of the Windows system directory, and then uses fopen to either read or write a file depending on what is required.
So here is the conundrum. These techniques work like a charm on my projects that I programmed using Visual C++ v6.0. No problem what so ever. I recently ported this project to Visual Studio 2008 using C++ and MFC, and for XP business as usual. However for Vista, disaster. The nature of the problem is that when I use fopen it can't open the file in the windows system directory. Basically I get (fp = fopen( m_keyPath, "w" or "r" )) == NULL. Here's the twist in the tale. Any where else it's fine. It's just the windows system directory.
Any ideas??
Best Regards
Danny
|
|
|
|
|
Danny Nowlan wrote: These techniques work like a charm on my projects that I programmed using Visual C++ v6.0.
The problem has nothing to do with VS6.
Your program should not be writing/crearing files in the \Windows\System32 folder. That folder has been off limits for years, but since it has not been enforced, folks have continued to abuse it. Use SHGetFolderPath() to get the path of a folder that you can write to. For example, CSIDL_COMMON_APPDATA , CSIDL_LOCAL_APPDATA , CSIDL_COMMON_DOCUMENTS , CSIDL_PERSONAL .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
As normal user you will not get access to the system directory of vista.
On vista and above many security issues changed!
Try your to start your exe "as adminstrator" and you will see it will work.
Greetings
Covean
|
|
|
|
|
Could you explain why you need to read/write files in the System32 directory ?
There is a reason why Microsoft tries to protect its system directories.
|
|
|
|
|
Hey Snakefoot,
I use it as a convenient location to keep operating files without bothering with the registry. Let me give an assurance that I am not in the business of writing viruses or Malware. They may have the best of intentions, but people like this cause alot more harm than they do good.
Danny
|
|
|
|
|
When you mean operating file, then I guess you mean data files that belongs to your application. Such files should not be placed in the Windows-directory.
What if another application suddenly decides to also use this location, and by mistakes uses your filename-format ?
You should read this guide from Microsoft Data and Settings Management[^] (Though written for Win2k, then it also holds for Vista/Win7)
TCHAR szAppData[MAX_PATH];
...
hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szAppData);
PathAppend(szAppData, "Company\Product\File.txt")
- CSIDL_APPDATA - Per user, roaming [user profile]\Application data
- CSIDL_LOCAL_APPDATA - Per user, non-roaming [user profile]\Local Settings\Application data
- CSIDL_COMMON_APPDATA - Hidden folder for normal users. Per machine (non-user specific & non- roaming) All Users\Application data
- CSIDL_COMMON_DOCUMENTS - Visible folder for normal users. Default files in this folder is readonly for other users than the creator, the application must change the security permissions on its application-folder to change this behavior. Per machine (non-user specific & non- roaming) All Users\Documents
modified on Monday, December 14, 2009 10:39 AM
|
|
|
|
|
Hi all,
I am using '_UNICODE' rather '_MBCS' in my MFC single document app.
My problem code-
CString openFilePath;
CFileDialog fileOpen(true, NULL, NULL, NULL, L"Text file(.txt)||*.txt", NULL);
openFilePath = fileOpen.GetPathName(); //it returns CString
'GetPathName()' returns just a single charecter. When i use '_MBCS' it returns full file path.
I want unicode standard with full file path when i open a file using "CFileDialog".
Thanks
|
|
|
|
|
Shaheen.India wrote: 'GetPathName()' returns just a single charecter. When i use '_MBCS' it returns full file path.
How are you verifying this?
Shaheen.India wrote: I want unicode standard with full file path when i open a file using "CFileDialog".
CFileDialog does not open files. It merely allows you to select them.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Verifying in Debug mode. It sends a single character as a string. When i open a file, if it belongs like "e:\MyData\aa.txt", it returns just "e" as string
|
|
|
|
|
Which does not answer my question. If you are using the Watch window, then you'll need to use the ,su symbol to see Unicode strings. Otherwise, you're just going to see a single character.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Using object of CFileDialogIt sends a single character as a string. When i open a file, if it belongs like "e:\MyData\aa.txt", it returns just "e" as string.
OK. How can i get open file path?
modified on Wednesday, November 11, 2009 10:41 AM
|
|
|
|
|
Shaheen.India wrote: When i open a file, if it belongs like "e:\MyData\aa.txt", it returns just "e" as string
This makes no sense. You've shown no code that opens a file, only code that selects a file. What's the "it" that you are referring to?
You would receive more reliable help if you'd post the actual code that you are commenting on or asking a question about.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
OK. Can i get full file when i open a file using 'CFileDialog's constructor?
|
|
|
|
|
This is my simple code:
CString openFilePath;
CFileDialog fileOpen(true, NULL, NULL, NULL, L"Text file(.txt)||*.txt", NULL);
if(fileOpen.DoModal() == IDOK)
{
openFilePath = fileOpen.GetPathName();//Here is a break point. at this stage //value of openFilePath display like {"e"} only.
..
..
}
|
|
|
|
|
Shaheen.India wrote: openFilePath = fileOpen.GetPathName();//Here is a break point. at this stage //value of openFilePath display like {"e"} only.
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello guys,
Im new to this forum and this is my first post!!!
I am a beginner at this and need some help with my first project.
Basically i am looking to create a expert car system..which works as follows:
a user will be able to input natural english text into the system...for example 'i want a blue honda with a 1.6 engine'
the system should read the text and cleverly extract the key words such as 'blue' 'honda' '1.6'
as soon as the words are matched, c++ will add these values in my database in mysql
if there are any missing values then the system should ask the user.. so:
tables:
colour table - blue
car table - honda
model table - ?
engine table - 1.6
so becuase the model table is missing maybe the system can ask the user..'how about the model?'
and evetually one the tables are filed the sql wil run and find matching cars and the output will be shown in c++.
okay so this is my plan..what do you guys think??
stupid plan?
i just need help trying to design this program.
any ideas or suggestions will help. like how do i go about creating sets of colours in c++ so when the user types in the text i can match the colour from his text to my set and send it up to the sql database?
Thanks guys
|
|
|
|
|
akshay1741 wrote: any ideas or suggestions will help. like how do i go about creating sets of colours in c++ so when the user types in the text i can match the colour from his text to my set and send it up to the sql database?
You will need a list, array or table of some form with all the valid colours held as strings. Then when the user enters the deatails you need to parse the input and look for a word that matches any of your colours, not forgetting to allow for upper, lower or mixed case.
From your opening statement I would suggest you get comfortable with the basics of C++ before trying to create the project you describe above.
|
|
|
|