Base And protected method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
com add-in vs.net 2003 & outlook 2003 & c#
I need to access to protected method of AxHost, How can I do this?
I get nothing after the dot (base.), Why?
This is my code: I need to set icon on commandBarButton:
I need to get this:
return(stdole.IPictureDisp)base.GetIPictureDispFromPicture(image);
Thank you.


using System;
using System.Drawing;
using System.Windows.Forms;
using stdole;
namespace MatarotToolbar
{
internal class MatarotHost : AxHost
{
public MatarotHost() : base("02FD5840-C1A3-448E-8310-98611DF58281"){ }
public static stdole.IPictureDisp ImageToIPicture(Image image)
{
return(stdole.IPictureDisp)MatarotHost.GetIPictureDispFromPicture(image);
}
public static System.Drawing.Image IPictureToImage(stdole.IPictureDisp
picture)
{
return MatarotHost.GetPictureFromIPicture(picture);
}

// static public stdole.IPictureDisp ImageToPictureDisp(Image image)
// {
// return (stdole.IPictureDisp)GetIPictureDispFromPicture(image);
// }
//
// static public stdole.IPictureDisp IconToPictureDisp(Icon icon)
// {
// return ImageToPictureDisp(icon.ToBitmap());
// }

// public new static IPictureDisp GetIPictureDispFromPicture(Image image)
// {
// return (IPictureDisp)AxHost.GetIPictureDispFromPicture(image);
// }
// public IPictureDisp GetIPictureDispOfPicture(Image image)
//{
// return (IPictureDisp)MatarotHost.GetIPictureDispFromPicture(image);
// }
// public static stdole.IPictureDisp ImageToIpicture(System.Drawing.Image
image)
// {
// return (stdole.IPictureDisp)MatarotHost.GetIPictureDispFromPicture(image);
// }
//
// public static System.Drawing.Image IPictureToImage(stdole.StdPicture
picture)
// {
// return GetPictureFromIPicture(picture);
// }
}
}
 
Hi,
com add-in vs.net 2003 & outlook 2003 & c#
I need to access to protected method of AxHost, How can I do this?
I get nothing after the dot (base.), Why?
This is my code: I need to set icon on commandBarButton:
I need to get this:
return(stdole.IPictureDisp)base.GetIPictureDispFromPicture(image);
Thank you.

using System;
using System.Drawing;
using System.Windows.Forms;
using stdole;
namespace MatarotToolbar
{
internal class MatarotHost : AxHost
{
public MatarotHost() : base("02FD5840-C1A3-448E-8310-98611DF58281"){ }
public static stdole.IPictureDisp ImageToIPicture(Image image)
{
return(stdole.IPictureDisp)MatarotHost.GetIPictureDispFromPicture(image);}

public static System.Drawing.Image IPictureToImage(stdole.IPictureDisp
picture)
{
return MatarotHost.GetPictureFromIPicture(picture);

}

// static public stdole.IPictureDisp ImageToPictureDisp(Image image)
// {
// return (stdole.IPictureDisp)GetIPictureDispFromPicture(image);
// }
//
// static public stdole.IPictureDisp IconToPictureDisp(Icon icon)
// {
// return ImageToPictureDisp(icon.ToBitmap());
// }

// public new static IPictureDisp GetIPictureDispFromPicture(Image image)
// {
// return (IPictureDisp)AxHost.GetIPictureDispFromPicture(image);
// }
// public IPictureDisp GetIPictureDispOfPicture(Image image)
//{
// return (IPictureDisp)MatarotHost.GetIPictureDispFromPicture(image);
// }
// public static stdole.IPictureDisp ImageToIpicture(System.Drawing.Image
image)
// {
// return (stdole.IPictureDisp)MatarotHost.GetIPictureDispFromPicture(image);
// }
//
// public static System.Drawing.Image IPictureToImage(stdole.StdPicture
picture)
// {
// return GetPictureFromIPicture(picture);
// }



}
}- Hide quoted text -

- Show quoted text -

When you inherit from a class, you can acces its protected methods
using the keyword base, calling base.GetIPictureDispFromPicture isn't
working ?
 
No, I don't have after the dot fo base nothing.
I get these answers to from four else :)
"It's a static method - you can't call it on an instance."

As the method you refer to is "static", you should be able to do as you've
already done in one of the methods, extending the AxHost class and using the
classname as identifier.

public new static IPictureDisp GetIPictureDispFromPicture(Image image)
{
return (IPictureDisp)AxHost.GetIPictureDispFromPicture(image);
}
I get nothing after the dot (base.), Why?

Because GetIPictureDispFromPicture isn't an "instance member" but a "class
member".

My answer:
I tried to write this, but it is still not good:
Maybe it is becouse of I don't get this method after the dot? (it's a
protected method)
AxHost. --> I don't have this GetIPictureDispFromPicture(image);
 
Back
Top