And don't use the clipboard to pass data internally in your program. It's very bad style; suppose, for instance, the user had text already on the clipboard that he'd copied from a browser window with the intention of pasting it later into a Word document. Don't you think that user is going to be a little irritated to find the text he'd placed there is overwritten with something your program did internally, without user consent?
In my application, we can assume that user won't be doing Copy-Paste.
Let me briefly describe my applcation
My program will be running in background with a icon residing in notification area. Based on user signal, I need to process some information without prompting user for it and paste it in word document. The information required has already been pre-processed. User should press a short cut key and pre-processed information should get pasted at the current cursor position of MS word.
I tried sending WM_PASTE to notepad first because it seemed much simpler than operating with MS word.
Can you please suggest some alternate routes for pasting information to word document from win32 program?
Word can be automated; that is, it can be programatically started, it's document contents manipulated, etc. Data could be inserted without resorting to clipboard functions.
I've done this sort of thing from C# before, but not C++. That being said, if you really want to do it from C++, it should be possible. You can either use managed C++ and .NET classes to interact with Word, or I think it can also be done from native C++ via COM. (You'll have to check on that.) The COM thing is probably moot anyway; managed C++ would be a lot easier, although it would involve .NET dependencies...
Not a very definitive answer - hopefully someone else can give more direction.
I've written "abcf" to text.txt file in binary mode. i'm reading back the data into the variable "data". why the heck the output is "abcfabcf". I should be "abcf" but what happened to this one. and another question do anybody knows how to write and read string data-type in binary mode. please help.
fstream::eof() - returns true if the 'eofbit' has been set by a previous i/o operation.
fstream::read(s, n) - sets 'eofbit' if the End-of-File is reached before n characters have been read.
The file has only 5 characters and the while loop will execute twice. In the first pass you try to read 5 bytes and it will be success. In the second pass read will fail and sets the 'eofbit'. Since you are not checking how many bytes read, you cout the old buffer contents again.
This is the reason why you got "abcfabcf".
The code can be changed to print "abcf" once, by checking the bytes read using fstream::gcount() as
If the program changes its own caption internally using SetWindowText() then there is nothing you can do directly. However, I believe there is a function that allows you to set a hook process which can monitor all messages, so you could intercept the WM_SETTEXT and act appropriately. But it sounds like a lot of hard work for no discernible benefit.
And the third possibility (after API hooking and editing the executable in a hex editor) would be:
Contact the author and ask for it, for example with a special build or a new runtime setting. If the application is open source you could even do it yourself, otherwise check what the author/vendor thinks about it. Some are happy to help, especially when you can explain why this feature would improve the end user experience for (one of) their customers.
In VS2008 neither /IGNORE nor #pragma warning(disable:4099) work for that message.
I'd like to compile debug build and I'm using a lot of libs they garbage the output window too much with those 4099 warning