|
Please post code of your PreTranslateMessage().
|
|
|
|
|
Hi all
i am new to the c++.In my project I need to pass the xml file using c++.This xml parsing already i done in the php.for Example
File Name : Language.xml
<languages>
<language id="english">
<Name>kumar</Name>
<Sex>Male</Sex>
<language>
<language id="french">
<Name>french_kumar</Name>
<Sex>french_male</Sex>
</language>
</languages>
In this file how to get the particular node(language id="english") value..ouput look likes
Name : kumar
Sex: Male
Please send me the articles or send me a link for sample programme ..
Help me..
Thanks and regards
Sumitra.E
|
|
|
|
|
kumarsumitra wrote: Please send me the articles or send me a link for sample programme ..
oh come on !! google it - there's plenty of articles out there
|
|
|
|
|
|
Check this article[^] about how to parse XML file by using msxml. Its so simple.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
I've been using TElemW[^]-- I find this helper class to be fantastic at parsing XML -- easy to write simple code with it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
|
AT
modified on Saturday, November 29, 2008 6:04 AM
|
|
|
|
|
1.when a thread complete its execution ,can we restart its execution using same handle ?
2.when a thread complete its execution is it cosuming resources?
3.I need to do multiple tasks at the same time ,so I need to work in threads.as i have to repeate these tasks at regular interval so i have to start same threads ,time is critical so i m using multimedia timer to start threads at regular interval .
problem is I have to create a new thread after a regular interval.I think it will consume resources . How could I use same threads to run at regular interval ????????????????
|
|
|
|
|
anilaabc wrote: 1.when a thread complete its execution ,can we restart its execution using same handle ?
I don't think so. Once a thread is finished, it's handle should become invalid.
anilaabc wrote: 2.when a thread complete its execution is it cosuming resources?
Yes. Also when it starts its execution. It has to allocate/deallocate its stack, at least.
anilaabc wrote: 3.I need to do multiple tasks at the same time ,so I need to work in threads.as i have to repeate these tasks at regular interval so i have to start same threads ,time is critical so i m using multimedia timer to start threads at regular interval .
problem is I have to create a new thread after a regular interval.I think it will consume resources . How could I use same threads to run at regular interval ????????????????
AFAIK there's no simple way to do that. You can create a thread that waits for a message or an event, and then executes a task in response to that message (or event). But you have to take care of the communication mechanism yourself.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
1. AFAIK no
2. After it terminated -unless it leaks memory or GDI resources- no.
3. I think what you could do is to use 1 or 2 events do control your thread (or threads), so your thread routine would look something like this:
HANDLE Events[] = {TerminateEvent, RepeatEvent};
BOOL Continue = TRUE;
while (Continue)
{
switch (WaitForMultipleObjects(2, Events, FALSE, INFINITE))
{
case WAIT_OBJECT_0:
Continue = FALSE;
break;
case WAIT_OBJECT_0 + 1:
continue;
default:
Continue = FALSE;
break;
}
}
The TherminateEvent and RepeatEvent you would create using the CreateEvent API call and signal them from another thread. You would probably need to add some more synchronization too. Does this help?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
anilaabc wrote: 1.when a thread complete its execution ,can we restart its execution using same handle ?
No.
anilaabc wrote: 2.when a thread complete its execution is it cosuming resources?
Yes. From the docs:
"The thread object remains in the system until the thread has terminated
and all handles to it have been closed through a call to CloseHandle"
anilaabc wrote: i m using multimedia timer to start threads at regular interval
Is there a reason you can't just use the timer thread?
You may want to look into creating a pool of threads so you don't have to create
and destroy them rapidly.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I could n't understan ...IS timer not execute in the main thread?
|
|
|
|
|
Multimedia timers execute on their own thread.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I want to do two to three tasks at the same time at regular interval ,time is important so i m using multimedia timer .
problem is ....timer run the thread only once .code is below
when I click button thread is created and multimedia timer is set.
count is an integer initialized with 0.
I suspend thread to resume at regular interval .
void CTimerDlg::Onbtnstart()
{
Thread=AfxBeginThread(ThreadDisplay, this, THREAD_PRIORITY_TIME_CRITICAL,0 ,CREATE_SUSPENDED);
handle=Thread->m_hThread;
Thread->m_bAutoDelete=false;
timeSetEvent(100, 0, TimeProcVideo, (DWORD)this, TIME_PERIODIC);
}
//thread analyzing data
UINT ThreadDisplay(LPVOID lParam)
{
CTimerDlg *obj=(CTimerDlg*) lParam;
obj->abc();
return 1;
}
void CTimerDlg::abc()
{
count++;
char a[20];
GetDlgItem(IDC_STATIC)->SetWindowText("");
CString s=itoa(count,a,10);
GetDlgItem(IDC_STATIC)->SetWindowText(s);
SuspendThread(handle);
}
void CALLBACK TimeProcVideo(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
CTimerDlg* timer=(CTimerDlg*) dwUser;
timer->ControlThreads();
}
void CTimerDlg::ControlThreads()
{
ResumeThread(handle);
}
|
|
|
|
|
you were given an answer by Roger the first time you asked this question (some 21 hrs ago as I see it). If you cant be bothered answering him/explaining what you're trying to do, dont post the same question again !!!
'g'
|
|
|
|
|
I think you didn't noticed.I modified the question and explained ...
|
|
|
|
|
CStringList *ListData,SetOfList;
ListData = new CStringList;
ListData->AddTail(str1);
ListData->AddTail(str2);
SetOfList.AddTail(ListData1);
ListData = new CStringList;
ListData->AddTail(str1);
ListData->AddTail(str2);
SetOfList.AddTail(ListData2);
ListData = new CStringList;
ListData->AddTail(str1);
ListData->AddTail(str2);
SetOfList.AddTail(ListData3);
...
from code above when finish the program
how can I write the code for delete all allocation memory.
please advise
|
|
|
|
|
Max++ wrote: how can I write the code for delete all allocation memory.
Allocated as shown, you can't.
All your "new"s need to be matched with a "delete". You can't possibly do that
because you overwrite the existing pointers with newly allocated values.
As far as the contents of the lists, the CStringList destuctor will take care of that.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello folks!
I have a DLL that is loaded into a process, in its DLLMain it starts a thread which does some initialization, creates a window and runs a message loop. This works fine. But when the DLL is unloaded i want to stop the thread cleanly, so what i do is post a certain message using PostThreadMessage (or simply PostMessage to the window) to which the thread is suposed to break the message loop, do cleanup and exit. I (try to) post the message when DLLMain is called with DLL_PROCESS_DETACH and then wait for the thread to terminate. The problem is, by the time DLL_PROCESS_DETACH runs the thread has already been terminated and never got the chanche to do any cleanup by "someone else".
So my question is, how could i terminate the thread cleanly when (before) the DLL is unloaded?
Thanks for any replies in advance.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
You really shouldn't be doing that stuff in DLLMain.
It's much safer to add exported initialize and cleanup functions to
the DLL.
More info: DllMain Callback Function[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yeah, i know, but the problem is, i have no control over the loading process, so i can't make it call any exported functions in my DLL, all i get is a call to DLLMain upon load and unload. Thanks for the reply, any other ideas maybe?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Maybe you could hook FreeLibrary[^] and if hModule is equal to your DLL post your thread message and then call the original.
Best Wishes,
-David Delaune
|
|
|
|
|
I have thought of that, but that seems a bit overkill to do, but i will keep it in mind, thank you.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|