|
My SMTP server is having problems right now so I'll just post it here.
Sample Project
Here’s what I did to create the sample.
Create a new Windows Application, right click on the project in the solution explorer and choose Add UserControl, call it BaseUserControl.cs.
On the BaseUserControl set the ForeColor to the System palettes Highlight color. Resize the canvas so it is 232x40 pixels. Now add a new label control to it and place it at (8, 8) with the default size. Change the Text on the label to say “base”.
Build the project.
Now Add another UserControl to the project (right click on the project choose Add UserControl). Call it ExtendedUserControl.cs.
Now close the designer for it, right click on ExtendedUserControl in the solution explorer and choose View Code.
Now change the class declaration so that it inherits from BaseUserControl instead of System.Windows.Forms.UserControl.
public class ExtendedUserControl : System.Windows.Forms.UserControl
changes to
public class ExtendedUserControl : BaseUserControl
Build the project again. Now open up the designer for the ExtendedUserControl (double click ExtendedUserControl in the solution explorer).
When you open up the designer for the ExtendedUserControl you should see the BaseUserControl, now add another label placing it at (120, 8) with the default size. Change the Text to read “extended”.
Now click on the background of the UserControl, and set the ForeColor to the System palette’s ControlText color.
Build the project again.
Now open up Form1 by double-clicking on it in the Solution Explorer. In the toolbox you should see two new entries at the bottom; these are the new UserControls you just created. Drag one of each onto the form.
VS.NET will tell you when you make a change that requires a build for you to see it; but to be on the safe side I always do a build.
If you have any other questions feel free to ask.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Hi James!
I'm sorry but it doesn't work for me. I did everything as you did (and I was doing the same before). When I double-click ExtendedUserControl in the solution explorer I'm getting an error:
ExtendedUserControl - The base class test.BaseUserControl coud not be loaded. Ensure the assembly has been referenced or built it is part of the project.
Jerzy
|
|
|
|
|
Did you remember to build the project?
That is the error message I get when I forget to do that step.
Give my sample project a try (you'll have to build it before you can view the user controls though).
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Hi James!
I'm scared to write to you again but belive me it still doesn't work for me. I'm doing exactly the same things as you.
When I open your project I can easily create another subclass of ExtendedUserCotrol.
I don't know what's going on. I tried on different machines with the same result. I was thinking maybe I have different setting in IDE. My Microsoft .NET framework is 1.0 ver. 1.0.3705, Development Environment 2002 ver. 7.0.9466
Thanks
Jerzy
Btw: I found another way of subclassing (but still only in your project): you can 'Add New Item' and choose Inherited Control and select base ExtendedUserControl for example.
|
|
|
|
|
JerzyPeter wrote:
I'm scared to write to you again but belive me it still doesn't work for me.
Nah don't be scared, I don't bite I'm curious as to why it isn't working for you when I have no problems doing it.
JerzyPeter wrote:
My Microsoft .NET framework is 1.0 ver. 1.0.3705, Development Environment 2002 ver. 7.0.9466
Same versions I'm showing. Did your box have another version of .NET on it before (one of the betas or an RC)? I repaved this one about 2 weeks ago. Funky things happen when you mix a pre 1.0 beta with the final
JerzyPeter wrote:
Btw: I found another way of subclassing (but still only in your project): you can 'Add New Item' and choose Inherited Control and select base ExtendedUserControl for example.
Yeah, I forgot about that one. I was thinking it was only there for forms.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Hi all,
I was wondering if there is some way to implement ownerdraw buttons in C#.
I've searched around but didn't find anithing.
Any idea?
Thanks in advance and Kind Regards
Severino
|
|
|
|
|
This should give you a base to start from.
using System;
using System.Windows.Forms;
namespace Namespace {
public class MyButton : Button {
public MyButton() : base() {
SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true );
}
protected override void OnPaint(PaintEventArgs e) {
}
}
} HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Is there any way to access the shell in C# ?
I want to list the contents of the desktop....
Thanks!
|
|
|
|
|
Well this isn't done via the shell but you can get this list by doing this.
public string [] GetFilesOnDesktop() {
string desktop = System.Environment.GetFolderPath( System.Environment.SpecialFolder.DesktopDirectory );
return System.IO.Directory.GetFiles(desktop);
} I'm not familiar with the Shell API but you should be able to also use PInvoke to call the functions you would normally.
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Thanks for the answer! I did try that, but the idea is to create a little explorer-like application in C#, with a tree listing of all contents of the desktop (the virtual directory, not the physical!).
So the question was in fact: how do I access virtual folders like desktop, my computer, my documents,...
|
|
|
|
|
Anonymous wrote:
So the question was in fact: how do I access virtual folders like desktop, my computer, my documents,...
OK, I believe the shell functions are nothing more than a COM object, so you can use the COM object via PInvoke.
Unfortunately I can't give you any more than that, PInvoke and Shell programming are both something I haven't delved into much (PInvoke) or at all (Shell programming).
I can however point you to a place that might have already answered or question, or if it hasn't been answered you can ask it there. The DOTNET mailing list is probably the best mailing list out there dealing with .NET.
Hope I pointed you in the right direction,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Thanks, great link!
However, something else.. using COM-objects, is that good programming practice...? I mean, this way you put some Windows-only code into the application, or am I wrong...?
|
|
|
|
|
Anonymous wrote:
I mean, this way you put some Windows-only code into the application, or am I wrong...?
Correct, but you'll have to use different methods for getting a list of files on the desktop for each operating system anyway. If you place all your OS specific stuff in a separate assembly then you can load the proper assembly at runtime.
FWIW I'm not sure how much of Windows.Forms is going to be ported; it isn't a part of the CLI specs but I believe the Mono project is going to port some of it over anyway.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Okay, now I understand. Depending on the operating system, you still have to write different code.
Thank you very much for your remarks!
Kind Regards,
Ludwig
|
|
|
|
|
What new system files are required to use C# apps on Win95 Win98 WinMe etc... or do they run normally using only the ordinary system files.
Basically is it worth using C# if it needs loads of extra libraries that have to be included in the installer
.NET or not .NET? MFC is the question......
|
|
|
|
|
The .NET Framework needs to be installed, about a 19mb download.
I don't think Win95 is supported as a .NET platform.
Michael
|
|
|
|
|
19meg!!! Does XP have this already? Is it in the Service packs for Win2K? Is it really worth moving to C#. Is it free to distribute on CD with a C# app?
.NET or not .NET? MFC is the question......
|
|
|
|
|
XP doesn't have it yet.
The last service pack for Win2k doesn't have it.
I don't know of any Microsoft applications or products that distribute it yet - apart from Visual Studio.
I would expect to see it in a service pack soon and probably in the next version of IE.
Michael
|
|
|
|
|
Hehe lets hope so. It also seems that .NET server has it already and will have it. On my beta it has 'The .NET Framework' however I have not dabbled in that realm as of yet.
.NET or not .NET? MFC is the question......
|
|
|
|
|
The latest version of the user interface library for C# is now available. It includes source code and articles for a TabControl, Docking Windows and hand built menu code. You can achieve the VS.NET IDE look and feel quickly and easily. (And its free!)
www.dotnetmagic.com
Phil Wright
phil.wright@dotnetmagic.com
|
|
|
|
|
How can I write a FTP client program, which can connect to the FTP server for uploading and downloading file? Which class(es) should I be choosen for writing this program?
Best regards,
Frankie Leung.
|
|
|
|
|
Trying to create a custom listbox control, but have run into a roadblock here. The popup list cannot be made to float as the common control's version does. Is there not some style to be applied to a window resulting in not being clipped by its container? The framework is obviously capable, looking at the menu component and the dotnet combobox, but I need to know where to look.
|
|
|
|
|
How to convert "string" to "int"?
Alexandr
|
|
|
|
|
I know several functions:
- atof - converts to double
- atoi - converts to int
- _atoi64 - converts to __int64
- atol - long
or function from Shell API
- StrToInt - you must attach SHLWAPI.LIB library to the project
I don't know if they exist in C#. Try them.
Good luck
|
|
|
|
|
I think that's not possible.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|