|
Why don't you show them in a RichTextBox if they are i RTF format ? With its LoadFile() function you can show stream of data.
Mazy
No sig. available now.
|
|
|
|
|
If this is only RTF, you could use System.Text.Encoding.ASCII or System.Text.Encoding.Unicode (depending on how the RTF is stored) to convert to byte[] array to text and assign it to the RichTextBox.Rtf property.
If you need to use Word instead, you'll have to save this to a temporary file. The only way to load a stream is with a structured storage document, which RTF isn't (only compound documents like Word Documents are). Since you would be using the Office PIAs, however, you'll have to create an instance of Word.Application. Since you have that reference, you can attach events to know when the application is closed, or even if a document is closed. In this event handler, you can delete the temporary file.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thenx you both, it really helped me a lot. I do not know but I forgot about such a thing as RichTextBox!!
|
|
|
|
|
Hi, I'd like to pass files to the default mail user agent.
What trying to do exactry is to do the same in Windows XP (Open "My Pictures" and select files then click on "E-mail this file" link in the task pane menu on the left).
If you know a good way to solve, please let me know.
Thanks in advance for your kindness.
|
|
|
|
|
P/Invoke
ShellExecute(0,"open","mailto:?file=\"c:\autoexec.bat\"", NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
|
Where can i find the shellexecute function
(which namespace)
Jonathan Slenders
|
|
|
|
|
ShellExecute is one of shell functions so you have to import it via DllImport ,so check for it in MSDN. But I don't know why he didn't recommend you the .NET way: Process.Start()
Mazy
No sig. available now.
|
|
|
|
|
Mazdak,
Does Process.Start() can handle it? If you know how to, please let me know.
What I am trying to is to emulate one of Windows XP function ("e-mail this file").
|
|
|
|
|
Jonathan,
FYI: http://www.codeproject.com/managedcpp/pinvoke.asp
|
|
|
|
|
Thanks > Dmitriy,
However I'm not willing to use P/Invoke. I haven't tested yet but I'd like to use managed code.
I tried with Process.Start() but no luck so far.
Is there any other way?
#BTW: Is following command (with cmd.exe) can be used to test?
cmd> explorer.exe mailto:?file=\"c:\autoexec.bat"
|
|
|
|
|
You can do it either way using the following:
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
public class Send
{
private static void Main(string[] args)
{
if (args.Length != 1) return;
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = string.Concat("mailto:?file=", Path.Combine(
Environment.CurrentDirectory,
args[0]));
psi.FileName = psi.FileName.Replace(" ", "%20");
Console.WriteLine("Executing '{0}'...", psi.FileName);
Process.Start(psi);
}
} The problem with this method is that not every client (like Outlook) support the file segment in a URL this way.
If you want to do this the right way, you'll have to use MAPI which most major email readers support (in order to be a default mail reader, they have to). There are several articles on this on CodeProject. Just try this search: http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=MAPI[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath,
Thanks a lot.
I'll read the articles of MAPI. I hope I don't have to import MAPI32.DLL.
|
|
|
|
|
I'm just starting to get my teeth in to C# and so far I think its going quite well. I used to do quite a bit of coding in Delphi which brings me on to my current problem.
In Delphi you used to be able to create your own class using a Thread class as its base
example:
<br />
-------------------------------- <br />
TMyClass = Class(TThread) <br />
.... <br />
Public <br />
FVariable : string; <br />
End; <br />
<br />
Var<br />
MyClass : TMyClass; <br />
<br />
MyClass := TMyClass.Create(True); <br />
MyClass.FVariable := 'Test'; <br />
-------------------------------- <br />
MyClass now has all the functions/procedures and variables of a normal thread class. I would like to do the same thing in C# but I can't inherit from system.threading.thread because it's sealed. I suspect there might be another approach to this but I can't find much on google. I guess I am not searching for the right things here. I guess I'm trying to do this the Delphi way when I should be doing them the C# way!!!
Any ideas anyone?
Thanks
|
|
|
|
|
In C# threads are handled differently. You create an instance of System.Threading.Thread and pass ThreadStart delegate to the constructor. ThreadStart delegate represents a method that thread will run.
public static void RunMe()
{
{
}
}
public static Main()
{
Thread myTread = new Thread(new ThreadStart(RunMe));
}
|
|
|
|
|
If you are looking for the syntax of classes for C#, the following is a simple example:
public class TrafficLight
{
TrafficLight(){}
private Color _color;
public Color LightColor
{
get{return _color;}
set{_color = value;}
}
public virtual void ChangeColor(Color newColor)
{
LightColor = newColor;
}
}
public class DeluxeLight : TrafficLight
{
DeluxeLight(){}
public overrides void ChangeColor(Color myColor)
{
}
}
- Nick Parker My Blog
|
|
|
|
|
Hey
Does anyone know how to select a node in a TreeView, inside the application?
Just like a mouse click event on the node.
I have tryed the different combination of
theTreeView.SelectedNode = theTreeView.Nodes[0];
But it does not work
Thanks
Thomas
|
|
|
|
|
It does work (I use it for a few things) but you won't notice unless 1) your TreeView has the focus, or 2) if another control has the focus you must set TreeView.HideSelection to false (default is true ), otherwise it is selected but you just won't see that it is.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
I mentioned that in my first reply.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
I have this MDI application that has child form, how can I disable one of the menu option in the parent window from the child window.
Thanks
|
|
|
|
|
The easiest way - albeit not a very well-designed way - is to cast the Form.MdiParent property to your MDI parent's Form -derivative class, then access the Form.Menu property and - through the provided properties - disable the MenuItem you want.
A good design would use a modular design pattern in such a way that services are provided to the MDI child forms allowing them easily access the menu, or use the MenuItem.Merge method to merge menus defined on the MSI children with the menu for the parent form. See Form.MergedMenu property for more information.
Using the latter methods allows client forms to provide menus to the parent that they want to use. This is VERY common for most MDI applications. Just open Microsoft Word. Look at the menus available. Now close just the document (leaving the application window open). Your options are greatly decreased (although this process uses the concepts of Active Document containers and servers, but the idea is the same).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi!!!
Maybe somebody use Scintilla and C#...
I need some idea how to do this!
Greetings
S_W
|
|
|
|
|
|
Just wondering did you find any examples? Yet? I'm currently working on this, however having a nightmare trying to interface through C++.
|
|
|
|