|
Thanks a lot for the suggestion Roger,
I am wondering where I should close the thread's handle (CloseHandle(hThread) ) if I do not check for its actual completion. Receiving the message handler's call does not mean the thread's already returned I think? Another problem is that my task may contain multiple thread creations at the same time, the window would need to know when they all terminated too, which then I will get their exit codes for processing(GetExitCodeThread ) as well as retrieve a timestamp at the time.
Some sort of "wait-until-all-done" is still needed for my case I think? And obviously that shouldn't be done in the main window. That's why I thought about creating a thread or a timer which creates and does my thread tasks.
Thanks again,
Best Regards,
Johnny
|
|
|
|
|
In short, here's what you should do when the thread has finished its work:
1. Post a user defined message with ::PostMessage(...) to the main thread to inform it that the worker thread is terminating.
2. In the message handler you wait on the thread handle to know when the thread has terminated.
3. [Optional] Get the exit code of the thread with ::GetExitCodeThread(...) .
4. Close the thread handle with ::CloseHandle(...) .
Read this[^] excellent article for more info about how to use worker threads.
Regarding your problem with multiple worker threads I suggest that you post the thread ID from the worker threads with the user defined message.
You should have a mapping between thread IDs and their handles. In the message handler you get the thread ID, look up the thread handle in the map and continue from #2 above. Don't forget to remove the thread ID and its handle from the map when you're done with it in the message handler.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks again Roger,
for very informative reply and link. They helped greatly.
Best Regards,
Johnny
|
|
|
|
|
J.B. wrote: Thanks again Roger,
for very informative reply and link. They helped greatly.
You're most welcome Johnny.
I'm pleased to hear that I was able to help you, so thanks for telling me.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
It sounds like you’re after the MsgWaitForMultipleObjects[^] function.
On a side note, you probably should be using _beginthreadex[^].
Here’s a quote from MSDN on the CreateThread function:
A thread in an executable that calls the C run-time library (CRT) should use the _beginthreadex and _endthreadex functions for thread management rather than CreateThread and ExitThread; this requires the use of the multi-threaded version of the CRT. If a thread created using CreateThread calls the CRT, the CRT may terminate the process in low-memory conditions.
Steve
|
|
|
|
|
Hi
How we differenciate between
1) send one New Mail
2) Reply a existing mail
in webdav method
i find some forum subject property have him "Re: " keyword in prefix
but the User may change the subject line of the reply mail.
Thanks
Arunkumar S
|
|
|
|
|
Hi
If i have received a Mail Named : X
and I reply that mail namely : Re: X
How can i find relationship between " X " and " Re: X "
in inbox and sent Items folder
which property is used to identify the relationship
Please anybody help me.
Thanks
Arunkumar S
|
|
|
|
|
Hi
We are using webdav method,
When reply a one mail, How to set the conversationIndex Property
through webdav method.
because we want track the conversation Mails History
Thanks
Arunkumar S
|
|
|
|
|
Hi,
How can i get the handle of the window which was having input focus just before my Application window got the focus?
Please help.
|
|
|
|
|
try
GetLastActivePopup
--
======
Arman
|
|
|
|
|
Look up 'SetFocus', which returns the handle to that window. Also look up WM_SETFOCUS message, the WPARAM contains that handle.
How you actually implement depends on how your code is written, which you did not give.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
John R. Shaw wrote: Look up 'SetFocus', which returns the handle to that window.
Unless it's in another thread's message queue (which is the case with the OP), then it will just return NULL .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks David,I did not considered that.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Actually i want to create a floating Application, which can send text on selection of a particular option to the window which was having input focus before my app. Getfocus won't work as the window, of which i want the handle, doesn't belong to my app.
|
|
|
|
|
This[^] is not what you are looking for but it is a start.
Also check out WM_ACTIVATEAPP, your application receives this message when it is being activated or deactivated, along with the thread identifier.
If I was designing both applications I would be looking at using COM to handle the communications between them, by exposing an interface. In the old days I would have been looking at DDE, but that is obsolete.
I am still looking, because now I want to know the answer. But I will be limiting my time, so I may give up before I find an answer.
Good Luck!
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
K Gupta wrote: Actually i want to create a floating Application,
Have you written that APP?
K Gupta wrote: which can send text on selection of a particular option to the window which was having input focus before my app.
Sending text means? Do you need to send key strokes? In that case, I would suggest you install a global hook via a DLL and then let it send key strokes. This may not be applicable if only you want your executable to be visible too. Can you elaborate a little more on your problem?
Nobody can give you wiser advice than yourself. - Cicero
brahmma
|
|
|
|
|
I want to create an app like windows on screen keyboard. The window to which i will be sending characters can be any application like notepad, msword etc.
I want a particular sequence of characters to get typed on target window if the user selects a particular option. I have made the app, but right now i am passing the handle of target window through commandline argument when my app gets spawned. I want to make it independent of that commandline arg. I think i have made my problem clear now. Please help.
|
|
|
|
|
K Gupta wrote: have made the app, but right now i am passing the handle of target window through commandline argument when my app gets spawned.
Who is the rocket scientist that gave you this idea of sending the window handle as a command line argument? Your appplication will be able to work with only one window, currently. How do you get the window handle of the window to which you want to send key strokes? Who sends your application the window handle while spawning? If the *thing* that sends your application has the code to get the window handle, then why should it not be in your application itself so that it can work with any window? What have you achieved so far? I am not on my development machine now, and I shall send you something helpful shortly.
Nobody can give you wiser advice than yourself. - Cicero
brahmma
|
|
|
|
|
Just a stupid question. If an on-screen Keyboard is what you want, then have you tried using MSKLC?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I think i am more stupid Whats MSKLC?
|
|
|
|
|
K Gupta wrote: I think i am more stupid
Let us not argue on it
MSKLC is Microsoft Keyboard Layout Creator. I still do not understand what exactly your requirement is, but if it has to be an onscreen keyboard utility, use MSKLC to create a keyboard layout and use MS onscreen keyboard to type with the layout. Google for MSKLC. Let me know if the problem was solved.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I have a CToolbar ctrl on a CDialog. Can someone tell me how I can capture the messages for the ON_UPDATE_COMMAND_UI for the buttons on the CToolbar, so that I can then enable/diable etc?
|
|
|
|
|
|
How can i make buttons on toolbar of different sizes?
I mean, the size of first button should be different from second button on toolbar.
Is it possible?
|
|
|
|
|
toolbar buttons are created based on the bitmap that they show, and a regular toolbar cannot do what you want. But still there is a way of dowing it by creating custom buttons on a toolbar.
--
======
Arman
|
|
|
|