|
extern DWORD mainThreadId;
PostThreadMessage(mainThreadId,WM_MESSAGE_THREAD,0,0);
I used this code to post a message from running thread to the main thread.
The message gets "intercepted" in the application class
BOOL CFD2008App::PreTranslateMessage(MSG* pMsg)
I does not get intercepted using same PreTranslateMessage in CMainFrame.
Now I need to run a process in CFD2008View.
How do I get the message there? All this in MFC.
Any constructive help will be as always appreciated.
Thanks Vaclav
|
|
|
|
|
When creating[^] the thread pass the CView pointer using the pParam parameter to the thread. In the thread use this pointer to post messages to the view.
0100000101101110011001000111001011101001
|
|
|
|
|
Andre,
thank you for your suggestion.
I have passed the view pointer to the new thread and can use it to read edit box text directly, without sending message.
However, I need to control the cursor in this edit box, using SetSel, and it does not work right now.
I think I can figure it out.
It seem that posting messages using PostThreadMessage is an iffy proposition. The documentation said that if it does not work use Sleep and try again.
It seems to work in bebug / stepping thru the code mode.
I cannot do that since my goal is to move edit box cursor along when the characters are output. I am sending Morse code and however slow it is in comparison with other data, I cannot see using Sleep.
Anyway, you suggested to pass a pointer to view, however, all MFC Post/Send messages need a thread ID. Is that correct?
But since I am not going to use messages, it is irrelevant for now.
Thanks for you help.
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: however, all MFC Post/Send messages need a thread ID. Is that correct?
No, that is not correct. Usually all you need is the HWND handle of the window that is to recieve the message. See here[^] and here[^].
Independent ACN Business Owner- Check out the possibilities for your future!
- Financial independance
- Full time or Part time
- In more than 20 countries through North America, Europe, Asia and the Pacific
- Featuring the ACN IRIS 5000 video phone. See the person you are talking to.
Within you lies the power for good - Use it!
|
|
|
|
|
Do not directly interact with the GUI from your worker thread, you may get into deadlock situations. Although it is more work only interact by using PostMessage[^].
Read this article Using Worker Threads[^] for some detailed information.
0100000101101110011001000111001011101001
|
|
|
|
|
OK, you have convinced me that PostMessage to the main thread view is the way to handle this.
Now the MFC question
Which is preferred / proper way to intercept the message in MFC ?
Using ON_THREAD_MESSAGE ( probably not since this is PostMessage not PostThreadMessage ) or WindowsProc or PreTranslateMessage?
Actually I really would like to know what is the hierarchy/sequence of theses functions in the CView class.
Many thanks for all your inputs, I appreciate it.
|
|
|
|
|
You will be using user defined messages for your communication.
Have look at this article Message Management[^] on how to make your own messages.
0100000101101110011001000111001011101001
|
|
|
|
|
Typical - after I learn the rules (WM_USER) they change them!
Looks like registered messages and ON_ whatever in approprite
message queue is the ticket.
Thanks for all your help.
|
|
|
|
|
Your welcome.
0100000101101110011001000111001011101001
|
|
|
|
|
[Please remove thread...sorry]
modified 7-Oct-11 17:28pm.
|
|
|
|
|
This is not the proper forum for this. Please move to a forum more appropriate, such as Free Tools[^].
|
|
|
|
|
The key might be secure, but if the code that validate the key looks like this :
if ( checkKey(key) == false )
{
exit(0);
}
whatever the strength of the key it will be useless.
Watched code never compiles.
|
|
|
|
|
Exactly. A few NOP instuctions placed in the proper location using the binary editor in Visual Studio will allow anyone to skip right over that if statement. I had realized this a while back after spending a few months obfuscating and encrypting license keys in my programs executable to only find that single critical if/else could be easily bypassed with NOP instructions. No need to backward engineer the tons of code I had worked on.
Why people continue to pursue this is beyond me. I guess we all need to learn our lesson the hard way.
|
|
|
|
|
Oh great, you just published the keys used by my application. Gee, thanks.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
advertising and abuse
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Catalin Stavaru wrote: truly uncrackable product keys
There is no such thing. It's only a matter of time and effort before they are cracked.
And advertising all over the site will just get you banned.
|
|
|
|
|
I'm looking for suggestions for a Source Code Editor control, for quick & easy reuse.
I am not looking for an editor, I am looking for a control to embed in my application.
My environment is C++ - Win32/ATL/WTL; MFC might be OK.
The typical use case is small scripts (3rd party scripting language) to quickly try out something. I'm looking for basic features such as syntax coloring, Search&Replace, optional line numbers and whatever makes life handy. It does not need to be a fully fledged editor (we support external editors well enough already.)
Any suggestions?
modified 7-Oct-11 8:29am.
|
|
|
|
|
|
I'm looking for an embeddable control, not a standalone editor. I couldn't find anything on their site indicating that it's a reusable control.
|
|
|
|
|
|
Scintilla[^] is perfect for what you want
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
The one I posted about here[^] is just that.
"Scintilla is a free source code editing component. It comes with complete source code and a license that permits use in any free project or commercial product."
Here's the link again: Scintilla[^]
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
i have create the progress ctl in CwingSave class
and i have csave class for saving the data behind using another class Repair.
i have created the thread in Csave class .
the probles is that i am not able to update the progreass bar .
|
|
|
|
|
sarfaraznawaz wrote: the probles is that i am not able to update the progreass bar .
What progress bar? What thread owns it? If the primary thread owns the progress bar and the saving is being done in a secondary thread, then you simply need to post a message from the secondary thread to primary thread telling it to update the progress bar.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Pretty much sums it up... +5
|
|
|
|