|
How to get the control property 'Handle' and 'Name' from another .NET application window?
|
|
|
|
|
Why do you need this?? As it stands, your questions just screams "bad design". Controlling another applciation through window messages is not the best way to go about it.
|
|
|
|
|
Hello,
I am in searchof a method that converts my HTML input into RTF. I don't want to have any 3rd party tools to do it.
Can anyone help me to achieve this?
Thanks in advance.
Sebastian
|
|
|
|
|
Sebastian T Xavier wrote: don't want to have any 3rd party tools to do it.
OK, then you need to set aside a good amount of time to write the code to do it yourself. When you're done, you could probably sell it as a third party component.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Here's one way:
1. Display the HTML to be converted in a browser.
2. Press Ctrl-PrtScn to get a screen shot.
3. Start WordPad.
4. Press Ctrl-V to paste the screen shot.
5. Select File | Save As in WordPad.
6. Save as a .rtf file.
And you have the HTML converted to rtf without any 3rd party tools.
|
|
|
|
|
Alan take a bow! You deserve MVP for that one answer!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I never thought it as a hard task as that...... I don't have months to spare for this....
|
|
|
|
|
Any conversion between two formats can be problematic. In most cases the 'owners'of the formats generally provide the API's to convert. IF you are using MS Orifice, you can open HTML files and then save them to rtf; this can be done programatically.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Thats a great input for me.... I will go ahead with this....
Thanks a lot
Sebastian
|
|
|
|
|
If you don't mind a few shortcomings, why don't you just try using Word: let it open the HTML document and save as RTF.
Warning: make sure not to have it save any HTML, Word's idea of HTML is a bit fundamentalist.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: Word's idea of HTML is a bit fundamentalist.
Fundamentalist?? That's too "warm and fuzzy" a description for what Word considers HTML. No, I think "Jihad", "Shock and Awe", "GBU-43/B Massive Ordnance Air Blast bomb", ... those are a bit more accurate.
|
|
|
|
|
I plead guilty.
My preference for understatement goes pale next to your highly accurate politico-military jargon.
BTW: I'm beginning to worry about your long-term MS MVP status now. I wouldn't want to see another one go down and switch to Mac misery.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I'm not an MS MVP anymore. I'm spending way too much time with my 15 month old son to keep up on MS's and CodeProject's stuff at the moment.
|
|
|
|
|
Good choice.
And yeah, your sig tricked me.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
try to put it in a Richtextbox and start from there.
You'll probably have to manually escape the tags and replace them by rtf codes. (Readme's via google).
|
|
|
|
|
Hi
I am trying to read from somewhere in the middle of the file with Binaryreader but I can't.
BinaryReader br = new BinaryReader(MyFileStream);
br.BaseStream.Position = locationtostartreading;
byte[] context = new byte[br.BaseStream.Length - locationtostartreading];
br.Read(context, 0, (int)(br.BaseStream.Length - locationtostartreading));
return Encoding.ASCII.GetString(context);
But it starts reading from beginning whatever I do.
Thanks.
|
|
|
|
|
Hi,
1.
I would expect your code to work fine, although I had the experience once some methods rewind their stream parameter (without such being documented). IIRC Image.FromStream() does.
2.
Why do you need a BinaryReader here? FileStream.Read() would return a byte[] anyway.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Maybe your source is not seekable.
byte[] content = new byte[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,0,0,0,0,0,0};
MemoryStream memoryStream = new MemoryStream(content);
BinaryReader reader = new BinaryReader(memoryStream);
byte[] buffer = new byte[6];
reader.BaseStream.Position = 15;
int size = 0;
do {
size += reader.Read(buffer, size, 6 - size);
}
while (size < 6);
|
|
|
|
|
My source is an exe file and I think that should be seekable.
|
|
|
|
|
The code I posted is the correct code for reading from a stream. If the code I posted does not work you have another error that has nothing to do with reading logic.
|
|
|
|
|
I think you have been trying to do this for a couple of days, yes?
I also think you have the wrong idea what a BinaryReader is and what BinaryReader.Read(byte[], int, int) actually does.
A BinaryReader is not intended to read a stream of binary data from a file. It is intended to read primitive types (such as int32, int64 etc) from a file. What you appear to be trying to do needs a straight FileStream or similar.
The BinaryReader.Read(byte[] buffer, int start, int length) reads length bytes into the buffer, starting to fill at buffer[start] - not reads bytes into buffer starting to fill from stream[start].
Search MSDN for BinaryReader; it is all there in English. Or Microsofts' version of English, at least.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thank you for your answer. Yes, I've been working on this for couple of days.
I've tried using FileStream too but again got the same result.
Maybe the problem is the method for looking the location of the string in file. Any suggestions on how the find the location of string in file
|
|
|
|
|
Try this:
using (FileStream fs = new FileStream(@"C:\XXTemp\Test.bin", FileMode.Open))
{
if (fs.CanSeek)
{
fs.Seek(0x53, 0);
byte[] buffer = new byte[8];
fs.Read(buffer, 0, 8);
StringBuilder sb = new StringBuilder();
foreach (byte b in buffer)
{
sb.Append((char) b);
}
MessageBox.Show(sb.ToString());
}
}
The StringBuilder stuff is just to display the buffer and show it works byte by byte.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I just tried your solution too, while debugging at watches it shows that fs's position is the position that I want but it doesn't work that way. It has lots of \0 when converted to string.
|
|
|
|
|
so your string probably uses Unicode, meaning the ASCII character set gets represented by 16-bit numbers with their high byte equal to zero. There are many ways a string can be hidden in an EXE, ASCII and Unicode are the top two.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|