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:
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)).
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.
Right click on your ToolBox and select 'Customize ToolBox' option. From .NET Component tab, with Browse button , select assembly of your control and click OK. It is now added to your toolbox and you can drag and drop it on your form.
For one thing, you didn't hook-up your Paint event handlers. Remember, he's a n00b.
Also, never use events in a derived class - it's too slow and doesn't provide the control you might need (such as NOT calling the base class's OnPaint handler). Instead, always override the related method for an event when deriving from a class:
publicclass MyControl : UserControl
protectedoverridevoid OnPaint(PaintEventArgs e)
base.OnPaint(e); // Allows base class to paint and raise the Paint event.// Draw
Point of clarification: OnPaint is not an event. It's a method that, in the defining class, raises the Paint event before or after optionally performing some action (like any default painting). When you override this, you pre-empt the event being raised (which is why you call base.OnPaint) and actually override all the functionality of that method since it's virtual. If you don't call base.OnPaint, any painting that the base class, or its base class, etc., need to do won't be performed.