|
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?
Really appreciate your help.
|
|
|
|
|
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.
L u n a t i c F r i n g e
|
|
|
|
|
|
That sounds like just what you're looking for.
L u n a t i c F r i n g e
|
|
|
|
|
#include <iostream><br />
#include <fstream><br />
using namespace std;<br />
<br />
int main() {<br />
<br />
char data[5];
fstream file("c:\\test.txt",ios::in | ios::binary);<br />
if(file.is_open())<br />
{<br />
while(!file.eof())<br />
{<br />
file.read(data,sizeof(data));<br />
cout<<data;<br />
}<br />
file.close();<br />
}<br />
else<br />
{<br />
cout<<"Error";<br />
}<br />
<br />
return 0;<br />
}
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.
|
|
|
|
|
This works for me (error handling left to the reader)
#include <iostream>
#include <fstream>
using namespace std;
int main() {
fstream file("C:\\test.txt", ios::out | ios::binary);
char out[]="hello";
file.write(out, sizeof(out));
file.close();
file.open("C:\\test.txt", ios::in | ios::binary);
char in[sizeof(out)];
file.read(in, sizeof(in));
cout << out << ", " << in << endl;
file.close();
return 0;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
What's wrong with just using std::string and using the library provided operators, like here?
fstream file("c:\\test.txt",ios::in | ios::binary);
if(file.is_open())
{
std::string s;
file >> s;
std::cout << s << std::endl;
file.close();
}
else
{
cout<<"Error";
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
modified on Wednesday, February 3, 2010 8:27 AM
|
|
|
|
|
The format...
On the serious side, while there is, of course, nothing wrong in your approach, there is, as well, nothing wrong in his one.
Disclaimer: this is going on my...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I always like using idiomatic C++ rather than not
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
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(file.is_open())
{
//file.write(data,sizeof(data));
while(!file.eof())
{
file.read(data,sizeof(data));
if(file.gcount())
cout<<data;
}
file.close();
}
..................
|
|
|
|
|
Hai,
Can Anyone tell me how to create a setup project.I want to add an licensing page also.
Thanks
Jannath Ali
|
|
|
|
|
|
I want to add a Licencing page in the deployment.this article does not explain about adding the licensce page
|
|
|
|
|
If you have already created the Setup and Deployment project, then you can take Solution Explorer (View->Solution Explorer).
You can find few small icons on the top of Solution Explorer window. One of those icons is 'User Interface Editor' (Fifth icon from the left in VS 2005).
Click on that icon to open the User Interface Editor. Now you can see a Tree of dialogs on the right side pane.
Now right click on the 'Start' node to see a popup menu with 'Add Dialog' option. 'Add Dialog' brings you a list of dialog (including relicense page)
|
|
|
|
|
I have changed the caption of third party exe through FindWindow and SetWindowtext but this application changes its caption on Atl+Ctrl, How can I set my own caption instead of pressing atl+ctrl.
|
|
|
|
|
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.
MVP 2010 - are they mad?
|
|
|
|
|
You may hack the executable file.
Of course, I never told you about
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
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.
/M
|
|
|
|
|
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
Чесноков
|
|
|
|
|
|
Thanks I've seen that before.
I have libs with pdbs and ones without. I need to run debug build but I'd like to supress 4099 for those without pdbs.
Ot seem that it is not possible.
Does VS2010 solve that problem?
Чесноков
|
|
|
|
|
|
HI all,
I want to check any process that is run in process tab of task manager is run by admin or by any other user.
please tell me how can i chk this.
please provide me help and guidance for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
You can use the GetOwner method of the WMI class Win32_Process .
|
|
|
|
|
May be you can try GetProcessToken() and GetTokenInformation() APIs.
|
|
|
|