|
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
|
|
|
|
|
Here is the bug report of the error.
main thread ($12e8):<br />
00508898 +010 accountant.exe Controls 4164 +1 TControl.SetVisible<br />
00410046 +05a accountant.exe firmatanimlari.cpp 42 +6 TForm3.Button2Click<br />
0050a87d +335 accountant.exe Controls 5143 +83 TControl.WndProc<br />
0050ae3a +086 accountant.exe Controls 5226 +9 TControl.Click<br />
004b5019 +031 accountant.exe StdCtrls 3574 +3 TButton.Click<br />
00414b4e +0b6 accountant.exe firmatanimlari.cpp 297 +9 TForm3.FormShow<br />
004e88bd +021 accountant.exe Forms 2994 +1 TCustomForm.DoShow<br />
004ed498 +0ac accountant.exe Forms 5002 +11 TCustomForm.CMShowingChanged<br />
0050a87d +335 accountant.exe Controls 5143 +83 TControl.WndProc<br />
0050f585 +49d accountant.exe Controls 7242 +101 TWinControl.WndProc<br />
004e9345 +551 accountant.exe Forms 3284 +125 TCustomForm.WndProc<br />
00717cb9 +059 accountant.exe DBAdvGrid 7730 +13 TDBAdvGrid.WndProc<br />
0050a42a +036 accountant.exe Controls 5018 +5 TControl.Perform<br />
0050eab4 +100 accountant.exe Controls 6970 +17 TWinControl.UpdateShowing<br />
0050eb41 +059 accountant.exe Controls 6989 +8 TWinControl.UpdateControlState<br />
00511a61 +03d accountant.exe Controls 8269 +3 TWinControl.CMVisibleChanged<br />
0050a87d +335 accountant.exe Controls 5143 +83 TControl.WndProc<br />
0050f585 +49d accountant.exe Controls 7242 +101 TWinControl.WndProc<br />
004e9345 +551 accountant.exe Forms 3284 +125 TCustomForm.WndProc<br />
0050a42a +036 accountant.exe Controls 5018 +5 TControl.Perform<br />
005088c4 +03c accountant.exe Controls 4168 +5 TControl.SetVisible<br />
004e8c39 +055 accountant.exe Forms 3099 +8 TCustomForm.SetVisible<br />
004eddbc +00c accountant.exe Forms 5331 +1 TCustomForm.Show<br />
0040544c +074 accountant.exe anamenu.cpp 124 +8 TForm2.FirmaTanmlar1Click<br />
0050ae3a +086 accountant.exe Controls 5226 +9 TControl.Click<br />
008c5615 +051 accountant.exe AdvGlowButton 2563 +5 TAdvCustomGlowButton.Click<br />
0050b3c4 +078 accountant.exe Controls 5362 +6 TControl.WMLButtonUp<br />
008c6214 +308 accountant.exe AdvGlowButton 2985 +102 TAdvCustomGlowButton.WMLButtonUp<br />
0050a87d +335 accountant.exe Controls 5143 +83 TControl.WndProc<br />
0050f585 +49d accountant.exe Controls 7242 +101 TWinControl.WndProc<br />
0050ec74 +034 accountant.exe Controls 7021 +3 TWinControl.MainWndProc<br />
0055f54c +014 accountant.exe classes 11572 +8 StdWndProc<br />
77762e3c +00a USER32.dll DispatchMessageA<br />
004f29ce +136 accountant.exe Forms 7651 +23 TApplication.ProcessMessage<br />
004f2a13 +00f accountant.exe Forms 7670 +1 TApplication.HandleMessage<br />
004f2cae +0a6 accountant.exe Forms 7754 +16 TApplication.Run<br />
004028b1 +111 accountant.exe accountant.cpp 99 +20 WinMain<br />
00a61918 +14c accountant.exe __startup<br />
7615ed6a +010 kernel32.dll BaseThreadInitThunk
cpu registers:
eax = 00000000
ebx = 03c64d80
ecx = 03cc0e10
edx = 00000000
esi = 004e889c
edi = 0012fdfc
eip = 00508898
esp = 0012f48c
ebp = 0012f498
stack dump:
0012f48c 9c 88 4e 00 06 00 00 00 - 00 00 00 00 b8 f5 12 00 ..N.............
0012f49c 4b 00 41 00 07 00 00 00 - 22 01 00 00 10 fb 4c 00 K.A.....".....L.
0012f4ac a0 58 c2 03 00 00 00 00 - 16 00 00 00 80 4d c6 03 .X...........M..
0012f4bc 10 0e cc 03 fc f5 12 00 - db 89 a5 00 f8 03 ad 00 ................
0012f4cc a0 f4 12 00 00 00 00 00 - 00 00 00 00 60 fb 4c 00 ............`.L.
0012f4dc 00 00 00 00 a0 58 c2 03 - a0 58 c2 00 f8 f4 12 00 .....X...X......
0012f4ec 53 11 4d 00 64 f8 12 00 - a0 58 c2 03 28 f6 12 00 S.M.d....X..(...
0012f4fc 80 a8 50 00 44 8c 4e 00 - a0 58 c2 03 d6 0b 01 00 ..P.D.N..X......
0012f50c 5f 18 00 00 6c f5 12 00 - d9 1f a2 74 00 00 00 00 _...l......t....
0012f51c 90 f6 12 00 47 00 00 00 - 90 f6 12 00 cc f5 12 00 ....G...........
0012f52c 01 00 00 00 90 f6 12 00 - 47 00 00 00 00 00 00 00 ........G.......
0012f53c 90 f6 12 00 00 00 00 00 - 70 f5 12 00 e7 c4 76 77 ........p.....vw
0012f54c d6 0b 01 00 47 00 00 00 - 00 00 00 00 90 f6 12 00 ....G...........
0012f55c 47 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 G...............
0012f56c e8 f5 12 00 80 f5 12 00 - 9c f5 12 00 d8 98 7b 77 ..............{w
0012f57c ef 61 76 77 e8 f5 12 00 - 54 f6 12 00 6e 12 58 00 .avw....T...n.X.
0012f58c 31 3e 58 00 10 00 00 00 - 06 00 00 00 a3 2f 58 00 1>X........../X.
0012f59c 9c 88 4e 00 e8 4f 4b 00 - 4a 59 4e 00 10 0e cc 03 ..N..OK.JYN.....
0012f5ac 10 0e cc 01 00 00 00 00 - 80 4d c6 03 c8 f5 12 00 .........M......
0012f5bc 40 ae 50 00 e8 4f 4b 00 - 80 4d c6 03 d8 f5 12 00 @.P..OK..M......
disassembling:
[...]
0050888b add esp, -8
0050888e push esi
0050888f mov [ebp-5], dl
00508892 mov [ebp-4], eax
00508895 4164 mov eax, [ebp-4]
00508898 > mov al, [eax+$57]
0050889b cmp al, [ebp-5]
0050889e jz loc_5088d1
005088a0 4166 mov eax, [ebp-4]
005088a3 mov si, $ffcd
005088a7 call +$7a754 ($583000) ; system.@CallDynaInst
[...]
The problem occurs while setting visible of Button6 I guess it says I try to use Button6 before it's created. While compiling the application there is no problem.This is a runtime error. Here is the surprise, if I change the header C++ Builder recogizes that the header is changed and if compile again after changing the headers the error goes away. There are a few VCL forms in my application which have changed recently. Every time I started the IDE I need to make a fake editing on their header files to get a problemless exe file. I guess there is bug but how do I get saved from this.
|
|
|
|