|
Hi, I'm seeking a way to emulate "Send To" function.
I just need to pass a file to .MAPIMail (it can pass a file to the default mua). .MAPIMail is normally located in C:\Documents and Settings\Default User\SendTo\ but doesn't have to use them. Simply prepare a file named like foo@test.local.MAPIMail (zero-byte) and drop a file with explorer. It'll attache the file to the default mua.
If anyone knows about this, please let me know. I'm willing run the default e-mail client and a file attached.
Thanks in advance.
|
|
|
|
|
I want Send To function for one of my C# projects too and in that time I couldn't find a .NET way for it, so I wrote a Shell Extension which do some task for my SEND TO function and register it with my application. But as I'm thinking now , those steps are doable in .NET too(not sure). This[^] article show you the VC6 way. If you couldn't translate it to .NET at least you can make that dll in VC6 which handle your job.
Mazy
No sig. available now.
|
|
|
|
|
Thanks Magy. So, it sounds like there is no way in C# and I at least need to import a dll.
|
|
|
|
|
For more help on Shell in C# you could search this site too.
Mazy
No sig. available now.
|
|
|
|
|
Hi,
I have the problem to get the selected text of a TreeNode. I want to put the selected text of a TreeNode into the clipboard. But I found no solution to get the selected text.
Is there anybody who has an idee?
Regards
Frank
|
|
|
|
|
When you say selected text you mean the user has "highlighted" a portion of the node label with the mouse and you want that higlighted text only ?
|
|
|
|
|
Yes, I mean (like in TextBoxes), the part of the text which is selected (with the mouse or with the keyboard).
Only when the TreeNode is in edit mode (SelectedNode.IsEditing).
|
|
|
|
|
Have your tried casting the selected node as TextBox and using the SelectionStart and SelectionLength properties ?
|
|
|
|
|
Another not-so-simple resolution would be to create your own TextBox and handle the edits yourself.
private void tvTestTree_BeforeLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.EndEdit(true);
TextBox MyEdit= new TextBox();
Rectangle IRect = e.Node.Bounds;
MyEdit.Location= new Point(IRect.X,IRect.Y);
MyEdit.Width=IRect.Width+20;
MyEdit.Height=IRect.Height;
MyEdit.Text=e.Node.Text;
tvTestTree.Controls.Add(MyEdit);
}
You will probably have to add an event handler for the TextBox to close it and get the selected text...
|
|
|
|
|
Sorry, I had to work.....
Thank you both for your ideas. I'll try both of your solutions. I thought already at this. But I hoped to get an easier solution.
Whatever thanks for your efforts...
Frank
|
|
|
|
|
You can't cast a TreeNode to a TextBox .
-----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-----
|
|
|
|
|
Sorry replied to myself....
Another not-so-simple resolution would be to create your own TextBox and handle the edits yourself.
private void tvTestTree_BeforeLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
e.Node.EndEdit(true);
TextBox MyEdit= new TextBox();
Rectangle IRect = e.Node.Bounds;
MyEdit.Location= new Point(IRect.X,IRect.Y);
MyEdit.Width=IRect.Width+20;
MyEdit.Height=IRect.Height;
MyEdit.Text=e.Node.Text;
tvTestTree.Controls.Add(MyEdit);
}
You will probably have to add an event handler for the TextBox to close it and
get the selected text...
|
|
|
|
|
This should work, but you can also get the edit control (a TextBox in .NET) that the Tree-View common control uses during label edits by handling the TVN_BEGINLABELEDIT notification message in TreeView.WndProc and then call a P/Invoked SendMessage with the TVM_GETEDITCONTROL :
public class MyTreeView : TreeView
{
private TextBox editBox;
protected override void WndProc(ref Message m)
{
if (m.Msg == TVN_BEGINLABELEDIT)
{
IntPtr hWnd = SendMessage(this.Handle, TVN_BEGINLABELEDIT, 0, 0);
if (hWnd != IntPtr.Zero)
this.editBox = (TextBox)Control.FromHandle(hWnd);
}
else if (m.Msg == TVN_ENDLABELEDIT)
this.editBox = null;
}
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam,
int lParam);
private const TVN_BEGINLABELEDIT = 0x10c5;
private const TVN_ENDLABELEDIT = 0x10c4;
private const TVM_GETEDITCONTROL = 0x110f;
} This way, you're not overlapping controls which can lead to problems, and you'll have to handle all the getting and setting of text.
-----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-----
|
|
|
|
|
This method is what I was referring to when I suggested casting the TreeNode edit control to a TextBox, except you said it correctly, I didn't. My Appologies....
|
|
|
|
|
Sorry, I had to work.....
Thank you both for your ideas. I'll try both of your solutions. I thought already at this. But I hoped to get an easier solution.
Whatever thanks for your efforts...
Frank
|
|
|
|
|
I'd like to perform the following function but without using a temporary text file, can someone point me towards how to do this in memory ? Is it possible ?
private void FillClipBoard()
{
string Line;
bool FoundDollar=false,Start=false;
TextReader trFile = File.OpenText(WorkingDir+CurrentName);
StreamWriter sw = File.AppendText(WorkingDir+"Clipboard.txt");
while((Line=trFile.ReadLine())!=null)
{
if(Line.StartsWith("$"))
FoundDollar=true;
if(FoundDollar)
{
if(!Start && Line.Trim().Length==0)
continue;
if(!Line.StartsWith("$"))
Start=true;
else
Start=false;
}
if(Start)
{
sw.WriteLine(Line);
}
}
sw.Close();
trFile.Close();
Utils.PutClipBoardTextFile(WorkingDir+"Clipboard.txt");
File.Delete(WorkingDir+"clipboard.txt");
}
public static void PutClipBoardTextFile(string Path)
{
TextReader tr = File.OpenText(Path);
Clipboard.SetDataObject(tr.ReadToEnd(),true);
tr.Close();
}
|
|
|
|
|
Why not just read this into a string, or better yet a StringBuilder (which is mutable). If you store the reference to this StringBuilder you can keep appending to it. Just use StringBuilder.ToString() to get the actual String .
Another way would be to use a MemoryStream and wrap your StreamWriter or StreamReader around it.
One unrelated thing to your question: instead of concatenating strings that represents directories, you should use Path.Combine to take into account the OS's path separator (\, :, /) and to ensure that - if the WorkingDir doesn't not end with a path separator - that it is added before appending the filename (or additional directory name(s)).
-----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-----
|
|
|
|
|
Thanx for the tip.
Does it also check whether the path start with \\ or X:?
Guess I can look that up now that I know where to look
>>>-----> MikeO
|
|
|
|
|
Hi there, I'm learning C# and I'm searching equuivalents from MFC/Win32 calls but in .NET.
1) What is the equivalent of Win32 GetSysColor() function in .NET?
2) I would like to have the equivalent in C# (.NET) of the following C++ (MFC) statement:
class CMyWindow : public CWnd
{
...
}
While CWnd is an MFC class that represents a basic window.
I want to write my own control and use it
Thanks for the help
Best regards.
|
|
|
|
|
bouli wrote:
1) What is the equivalent of Win32 GetSysColor() function in .NET?
It is System.Drawing.SystemColors class
bouli wrote:
2) I would like to have the equivalent in C# (.NET) of the following C++ (MFC) statement:
class CMyWindow : public CWnd
{
...
}
While CWnd is an MFC class that represents a basic window.
I want to write my own control and use it
Use System.Windows.Forms.Form for forms(dialogs). But for controls like button, user-controls use System.Windows.Forms.UserControl or Control. Here big difference between MFC and .NET. In MFC can be CWnd dialog and control(I used these for nested dialogs - one dialog owns another), but in .NET only classes delivered from System.Windows.Forms.Form can be dialogs and cannot contain any forms.
Wizard_01
|
|
|
|
|
ok for System.Drawing.SystemColors...
But I don't get it for the derived control.
What I wanna do is to write my own control that will get some methods. these methods will control the drawing.
|
|
|
|
|
bouli wrote:
What I wanna do is to write my own control that will get some methods. these methods will control the drawing
public class myControl : System.Windows.Forms.UserControl
{
public myControl()
{
}
....
private void Control_Paint(object sender,PaintEventHandler e)
{
}
}
Mazy
No sig. available now.
|
|
|
|
|
ok, thanks!
|
|
|
|
|
Hi,
Just one last question about this thread...
Can you show me how can I use the control in the main form?
I have inserted a label and? how can I link it to my new control?
Best regards.
Thanks.
|
|
|
|
|
bouli wrote:
I have inserted a label and? how can I link it to my new control?
What do you mean exactly? You mean you add that label to your UserControl? It is now in your .cs file as a private member. You can use it like this there:
lbale1.Text = "Hello";
User the search textbox at the top of this page to find articles in this site about UserControl for motr information.
Mazy
No sig. available now.
|
|
|
|