|
Hi
Thank you,I will try it
Regards
www.logicsims.ir
|
|
|
|
|
hello guys... I have got a project online. Now this project contains a function whose return type is LRESULT. Function's prototype and body are given as under.
afx_msg LRESULT FunctionName(WPARAM wParam, LPARAM lParam);
LRESULT ClassName::FunctionName(WPARAM wParam, LPARAM lParam)
{
}
But the problem is, I dont know how to add these sort of functions in application? Thanx for any help.
modified 8-Oct-11 2:42am.
|
|
|
|
|
overloaded Name wrote: I dont know how to add these sort of functions in application?
Just add the code into one of your source files where you need to use it. In the case of class functions you would add the prototype to the class definition in the header file and the body to the class source file. The sample code from any Visual C++ project will show you how to do it.
|
|
|
|
|
Hi all,
I want to make a priviewer in my application. i have also found a article on code project to preview files but it only priview files which have priview handler installed in registry, so it only preview word, excel files(i.e office Files). i want to priview all other files which are able to generate their priviews in windows priviewer pane. How can i do it.
Thanks in advance
|
|
|
|
|
If the files do not have an attached/attachable previewer then you will have to write your own, by creating some sort of view of the file content and rendering it to a bitmap which you can then display at whatever scaling you wish.
|
|
|
|
|
Actually i am not getting how to do it, so can you please tell me, how can i do this...
|
|
|
|
|
I thought I did! If there is no built in preview for a type of file then you will have to create one for yourself. This would involve writing handlers for every type of file that you encounter and rendering a view of their content as some sort of image.
|
|
|
|
|
VCProgrammer wrote: I want to make a priviewer in my application.
Is it an MFC application?
"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
|
|
|
|
|
yes it is a MFC application.
|
|
|
|
|
If it was an SDI or MDI application, you had the option of Print/Print Preview when you created it. If you opted out of that, it can easily be added back in. Create another "test" application and make sure the Print/Print Preview option is checked. Once the application is created, look at the code that is specific to Print/Print Preview. That's what you'll need to add to your application.
"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
|
|
|
|
|
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
|
|
|
|