|
Not exactly.
Yes, delegates are the correct thing to use here, but they do not magically change to reference derived methods. That is a function of how you define your methods.
Here's a small example demonstrating this fact:
using System;
class Example {
static void Main() {
Base b = new Derived();
b.Test();
}
}
class Base {
protected delegate void D();
protected virtual void One() {Console.WriteLine("Base.One");}
protected void Two() {Console.WriteLine("Base.Two");}
public void Test() {
D[] methods = {new D(One), new D(Two)};
foreach(D method in methods) method();
}
}
class Derived : Base {
protected override void One() {Console.WriteLine("Derived.One");}
protected new void Two() {Console.WriteLine("Derived.Two");}
}
When executed it outputs:
Derived.One
Base.Two
Virtual dispatch is unrelated to delegates.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
So....so long as the base method is virtual and the derived method is set to override the base method everything should be cool right? I think that was what I was doing when I was playing with these and it seemed to work, or at least it behaved the way I wanted it too.
|
|
|
|
|
Yes, that's exactly correct. Delegates dispatch just like calling the method directly would. They won't make a non-virtual method dispatch in a virtual manner, but as long as the underlying method is virtual and the derived methods override it then everything works the way you want.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Does anyone know a good method of getting the size (i.e. kb) of a <c>Bitmap<c> object ?
I have found height and width, but no actual property that represents the size of bitmap on disk or memory.
Thanks in advance.
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
|
If it's on disk and you have the filepath you can create a FileInfo object and look at the FileInfo.Length property.
|
|
|
|
|
|
|
Neither will "w x h x bpp" exactly, as it doesn't account for padding or headers. To be fair, the original poster asked about both in memory and on disk, and the FileInfo answer was certainly correct for the on disk case.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Blake Coverett wrote:
as it doesn't account for padding or headers.
What is a couple of bytes between friends?
We are all friends here, arent we?
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I've noticed that Access has a neat text box embedded in the context menu that you can use to enter a filter for your records. I find this extremely swift and handy (shame they don't do the same for search as well) and I was wondering if there is any relatively easy way to incorporate this type on control in my C# project? I'm pretty sure the regular menu controls won't do it so I'm guess I'd have to write a custom control, but does anybody have a good idea of how much work would be involved so I can decide if it's really worth the effort for my application. I've never tried writting my own controls before!!
Thanks
|
|
|
|
|
The standard menu just does not work with embedded child controls. I tried this myself, and the menu class won't budge to display an embedded control --I guess this could be, at least in Windows XP, because the Windows is Layered and thus possible painted on a memory buffer. It's not even possible to spy on the Window menu because is protected by the system. Just setting up the hook for getting the handle to menu window is a task in itself too.
Most custom menu controls don't have support for this either. And yes, you need to write your own custom control and deal with alll the painting and handling of the keyboard to make the menu behave like a standard menu. If you have the time the it is a good learning excercise.
If you don't you can always check the SharpLibrary popup menu control which does offer that feature.
Regards,
Carlos
http://www.sharplibrary.com
|
|
|
|
|
Thanks for the advice. I guess I'll live without for the time being
|
|
|
|
|
The Fluid UI Toolkit[^] menu/commandbar will have this, but it does not exist yet. We are making progress on Fluid, and the commandbar system is high on our list. So bookmark our site, and check back periodically for downloads.
We will also be posting articles on CodeProject about each of our controls as they are completed.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I'll keep an eye on it. Thanks.
|
|
|
|
|
|
Hey Nish,
Sure, I love CodeProject. I just did not appreciate the geeks fighting me over my own code.
Regards,
Carlos.
|
|
|
|
|
|
To me, it's just a matter of having an implied license. Basically, you thought the license was one thing, we thought it was another, and it happens we were correct. But the best thing to do is to have the license be stated beforehand, which is what Chris is working on doing for future CP articles/code.
Good luck with your commercial product!
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I'm trying to access functions of a C# interface from an extened SP written in C++ (Unmanaged) and I'm having problems retrieving the complete string upon reception in the interface.
I am using the MarshalAs attrib but for some reason, I cannot get this to work correctly...
Here is waht I'm doing...
Extended stored proc C++
__int64 nReturnCode;
char Text[20] = ".Net Rules";
pInterface->raw_Command((BSTR)Text, &nReturnCode);
C# interface...
public interface IMyInterface
{
long Command([In, MarshalAs(UnmanagedType.LPWStr)] string strText)
//could be the type that I'm using, but I have tried many and stil cannot get this to work...
};
public clase MyClass : IMyInterface
{
public long Command(string strText)
{
MessageBox.Show(strText);
return 0;
}
};
Messagebox: "????????s"
Please help me out with this one
Cheers
Ribs
Andre Cote
Software Development Manager
Position Technology Inc.
780 Industrial Blvd.
St-Eustache, Quebec, Canada J7R 5V3
Phone: (450) 491-7444
Fax: (450) 491-2509
mailto:acote@postech.ca
http://www.postech.ca
|
|
|
|
|
First, I know nothing about ASP coding or anything like that. What I do know, I need a better way to organize my photos. I have tried many programs, all cumbersome and not friendly to use.
So with that, I am looking at installing this program for my photo album pages.
What I need, is to hire someone to set it all up. I can do 50% up front (upon ref.), another 25% when you show me it works. The last 25% paid when done.
You will need to show/instruct me on how to upload the photos and how the program works.
My site is desertdrifter.com. It is hosted by hostsave.com. If need be, I will change host providers to get this up and running.
Serious inquires only.
I can be reached at jbriggs@desertdrifter.com.
Joel Briggs
www.desertdrifter.com
|
|
|
|
|
hmmm... what if I help you wid out getting payment?
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
I prepare my application for L10N and use System.Resources.ResourceManager.GetString() to retrieve string resources.
Works great, but does not include any compile-time checking: The argument to GetString() is an alphanumeric string identifier. A typo in this ID, and the application will still compile. Only when the string is needed (probably to display crucial details of that critical error), if cannot be found and GetString() returns null.
This is not good. Does anybody know of any tools or preferences that validate the presence of required string resources at compile-time?
TIA,
Bernd
|
|
|
|
|
I have a parent form that I have set the IsMdiContainer property to true. I have 2 other forms that I want to show up inside of the parent form. The first form called frmAnchor will be docked to the top of the parent form. The second form called frmCollect I want to fill the remaining area of the parent form, so I set the DockStyle to fill. When I run the program it looks OK, however once I click on the top form (frmAnchor) it shifts the bottom form (frmCollect) up to fill the entire area (even the area under frmAnchor). So, it is almost like using DockStyle.Fill on the bottom form doesn't know about the top form and fills underneath it.
Here is the code I use to show the child forms. This code is inside the parent form. Any ideas on how to keep the bottom form from shifting up when clicking on the top form?
frmAnchor newMDIChild = new frmAnchor();
// Set the Parent Form of the Child window.
newMDIChild.MdiParent = this;
newMDIChild.Dock = DockStyle.Top;
newMDIChild.Show();
frmCollect newMDIChild2 = new frmCollect();
// Set the Parent Form of the Child window.
newMDIChild2.MdiParent = this;
newMDIChild2.Dock = DockStyle.Fill;
newMDIChild2.Show();
|
|
|
|
|
I want to create a windows application like the project property page of CSharp project in a solution
(right click project in a solution, you will get project property pages).
when you click "common properties" you will get list bot control on the right panel,
when you click "Configuration properties" you will get data grid control on the right panel.
I want to do the similar things. My question is how to create different controls on the same positions?
thanks a lot!
|
|
|
|