|
DevMentor.org wrote: I have never has any issues with doing things in OnDestroy( )
I'm not sure. I think it would be safer to use DestroyWindow. As an example consider the following scenario:
I have a dialog class in which I create a worker thread and give a pointer to the dialog to that thread to post it's messages back to the dialog. I forget to use a safe message posting and write pWnd->PostMessage instead of ::PostMessage(pWnd->GetSafeHwnd(),... inside the thread.
I think here I'll have a problematic exit. The window is destroyed before the thread being stopped. So if the thread manages to send another message, the problem arise.
Please correct me if I'm wrong. Thank you so much in advanced.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Is there a way for the main thread to tell the worker thread to exit?
You need to get this setup first. If you got this setup then it's a simple matter of the main thread waiting on the worker thread to exit.
Look at the WaitForSingleObject( ) API
Basically you need to make this call from the main thread and pass the API the handle to the worker thread....the main thread will block until the worker thread dies and then you do the clean up with the main thread when it resumes.
Does that make sense?
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Thank you very much for your help. Beacause of the first help you provided, I don't have any other question.
I was just thinking about how each function might make trouble.
In our scenario of course we terminate threads truly and use waiting mechanisms. The problem here is that if we stop threads in Cleanup function and call this function after main window is destroyed, and inside the thread (before cleanup is called) we try to access the window, the call will fail with an error because the main window already destroyed in DestroyWindow but cleanup has not been called yet. Before we call cleanup and attempt to stop thread, in OnDestroy, the thread might need to send a message to the already destroyed window.
This is a really rare situation, but I think I encountered a simmilar problem already and now found what was wrong.
I hope it is clearer now. I'm sorry English is not my native language and I, some times, encounter problems describing what I mean.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
You're welcome,
I am just trying to help you think things out as you best understand your code.
I hope you manage to solve the problem! Your English is fine
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
DevMentor.org wrote: I am just trying to help you think things out as you best understand your code.
Thanks. Your help is really appreciated.
DevMentor.org wrote: Your English is fine
Thank you so much. I have more confidence now
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Cool!
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Hello everyone!
Is there a way to mess with other application's controls? I need to capture input from a text box from a specific program.
Thanks in advance!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Yes, it's called subclassing. Basically you can steal any messages from the other window, modify it it, eat it, pass it on, or do whatever you want with it.
Been awhile since I've done it, but you can replace an existing windows WndProc with your own, using SetWindowLong and GWL_WNDPROC.
There are a ton of articles on CP, but can't seem to locate the one I was thinking of...
[edit] Look at CWnd::SubclassWindow or CWindowImpl::SubclassWindow if using ATL/WTL. [/edit]
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
You can also use hooking to do the same.
Search for PasswordSpy by Brian Friese in codeproject for an example.
|
|
|
|
|
Lord Kixdemp wrote:
Is there a way to mess with other application's controls? I need to capture input from a text box from a specific program.
WM_GETTEXT and WM_GETTEXTLENGTh will help!, and for reteriving Window Handle of particular Control! use FindWindow Api
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Long time no see! Been busy with work?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
brahmma wrote: Long time no see! Been busy with work?
Changed my job. so busy learning new stuff!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
Lord Kixdemp wrote: Windows Calculator told me I will die at 28.
how to calculate that??
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Since everyone keeps asking this, I'll answer it.
Year of birth - 1337: convert to hex: remove letters
1989 - 1337 = 652: 28C: 28
Windows Calculator told me I will die at 28.
|
|
|
|
|
Lord Kixdemp wrote: Year of birth - 1337: convert to hex: remove letters
1989 - 1337 = 652: 28C: 28
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am such a skilled mathematician.
Windows Calculator told me I will die at 28.
|
|
|
|
|
typedef struct node{char name[20];struct node *link;}stud;
stud * creat(int n)
who can explain it for me?the more amply the better
|
|
|
|
|
What are the boxes for? xD
Windows Calculator told me I will die at 28.
|
|
|
|
|
youbo wrote: who can explain it...
What?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
node is a structure that looks like a link list node.
typedef is used to give it a new name, that is stud.
Creat is a function and it's return type is a pointer to stud.
This is all, I or anyone else can tell you by looking code above.
Please be specific while asking questions.
|
|
|
|
|
This is C code and the typedef tells you that you can declare a variable of type “struct node” by simply typing “stud” instead of “struct node”. The “creat” function allocates, and initializes a new “stud”, which will need to be freed latter. Why an “int” is passed to it I have no idea, because it has nothing to do with the “node”, unless “creat” is doing more than just creating a new node.
Oh, by the way, the name of the function should be “create” or something similar, because “creat” is an East Indian herb.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hello all
I looked at the tutorials about using app.config for VC++ (i think) but they give me errors...like system is not declared or something like that(sorry i'm in a hurry)
I've been googling for like 8 hours total now and still won't work
Can anyone explain how to link to app.config in VC++ Pro 2005? I know how to create the xml in proper format.
Thanks.
|
|
|
|
|
can you tell me what you are trying to do? i am not sure what you mean by ap.config?
---
Yours Truly, The One and Only!
devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
app.config is application configuration file based on xml
i'm trying to set variables from that file but the codes i tried don't work, i need the codes that'll work :P
|
|
|
|