Methods overloading?

Hi,
i'm writing an activex control with MS VC++ 6.0,capable of drawing a certain 
number of graphs (max 5 graphs),which i want the user to choose.
I would like to insert the data to be drawn with an InsertData method,but 
i've discovered with a little disappoint that i can't overload activex 
methods:indeed i would like the control to call the appropriate InsertData 
function depending on the number of quantities chosen,and i had thought of 
writing 5 different versions of the InsertData method,but,as already said,it 
isn't possible.
Can you give me some advice? 


0
accia77 (20)
2/9/2006 9:58:51 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
380 Views

Similar Articles

[PageSpeed] 29

Mittik wrote:
> Hi,
> i'm writing an activex control with MS VC++ 6.0,capable of drawing a certain
> number of graphs (max 5 graphs),which i want the user to choose.
> I would like to insert the data to be drawn with an InsertData method,but
> i've discovered with a little disappoint that i can't overload activex
> methods:indeed i would like the control to call the appropriate InsertData
> function depending on the number of quantities chosen,and i had thought of
> writing 5 different versions of the InsertData method,but,as already said,it
> isn't possible.
> Can you give me some advice?

You're confusing what you present in your interface with internal
methods. Say I'm doing a plot one in cartesian co-ordinates and another
in polar co-ordinates. Then I can do the following:

interface IPlot
     DataPoint(int a, int b)

ifPlot->DataPoint(3,45);

CCartesian::DataPoint(int a, int b)
{
   place a point at x = 3, y = 45
}


CPolar::DataPoint(int a, int b)
{
   place a point at r = 3 and angle 45 degrees
}


You see that both methods accept two integers. At the COM level all
that matters is that the signatures conform to the interface. If you're
having problems then it is because you aren't factoring your interfaces
well. That is almost a tenet of COM to isolate the implementation
behind an interface call.

0
rquirk1 (133)
2/9/2006 1:31:47 PM
COM does not support overloading; instead, it supports encapsulation.  So what you need to
do is create a new ActiveX control that embeds the one you want, and call its methods.  It
is then free to do whatever it wants to translate to the contained control.  ActiveX
controls can nest.

There is a strong set of debates as to whether encapsulation or inheritance is a better
methodology.  I tend to favor encapsulation, as an idea, but it is so complex to implement
in ActiveX  that I have avoided it.  It solves a lot of inheritance-related problems, such
as do you call the superclass before, after, or in the middle of, whatever you are doing
to implement the overload?  

[True story: I woke up after two major surgeries in 36 hours, the second to correct
problems caused by the first.  In the haze of post-surgical anaesthesia hangover, massive
amounts of morphine being injected into me, loss of over half my blood due to internal
hemorrhaging, and unbelievable pain, I realized I had a nasogastric tube up my nose
keeping my stomach drained, and another tube keeping my bladder drained.  One thought
sprang crystal-clear into my mind: "Good grief! My input/output methods have been
subclassed!".  This was reassuring, because I realized that given such an insight, I had
probably not suffered any brain damage from the blood loss.  But for the next 24
hours--and I blame this entirely on the drugs--I was in a panic because I couldn't
remember if I had to call the superclass Stomach::Swallow before or after I swallowed...]
				joe
 
On Thu, 9 Feb 2006 10:58:51 +0100, "Mittik" <accia77@hotmail.com> wrote:

>Hi,
>i'm writing an activex control with MS VC++ 6.0,capable of drawing a certain 
>number of graphs (max 5 graphs),which i want the user to choose.
>I would like to insert the data to be drawn with an InsertData method,but 
>i've discovered with a little disappoint that i can't overload activex 
>methods:indeed i would like the control to call the appropriate InsertData 
>function depending on the number of quantities chosen,and i had thought of 
>writing 5 different versions of the InsertData method,but,as already said,it 
>isn't possible.
>Can you give me some advice? 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
2/12/2006 11:30:22 PM
Reply:

Similar Artilces:

(New Object).Method
Is there a simpler acceptable syntax for (New Class).Method than With New Class .Method End With In VB.NET you can use Call Call (New Class).Method but this syntax is not acceptable in VB6 (with or without the () at the end). FYI I am looking for VB6 and VB.NET answers, if they are different. (Using Call in VB.NET is "acceptable", I'm just wondering if there is an alternative syntax I haven't thought of.) BTW Note that if you define an "identity" function: Function Identity(ByVal C As Class) As Class Identity = C End Function (And...

ReadBinHex method
Hi, I'm trying to read binary information from an XMLTextReader and to save it to a .jpg file, using a FileStream. I don't want to use an XmlDocument because of performance reasons. But the only example code I could find is: byte[] binhex = new byte[1000]; do { binhexlen = reader.ReadBinHex(binhex, 0, 50); for (int i=0; i < binhexlen; i++) Console.Write(binhex[i]); } while (reader.Name == "BinHex"); Is there any way to discover the length of the binary data on beforehand? Or can someone give me a hint on how to complete my code her...

Should my properties be a method or set by a method
I am in the process of building a VB6 class that represents the Windows startbutton. Currently it has two properties, one to set the caption of the button and one to enable or disable it. Currently setting either property sets that property of the actual start button. Should I be setting these properties via a method? "Leo" <Leo@discussions.microsoft.com> wrote > I am in the process of building a VB6 class that represents the Windows > startbutton. Currently it has two properties, one to set the caption of the > button and one to enable or disable it. Cu...

Evaluate Method.
Hi, I need help with evaluate Method. What I am trying to do is write for loop for following. UserForm2.Label1.Caption = "" UserForm2.Label2.Caption = "" UserForm2.Label3.Caption = "" UserForm2.Label4.Caption = "" UserForm2.Label5.Caption = "" UserForm2.Label6.Caption = "" UserForm2.Label7.Caption = "" UserForm2.Label8.Caption = "" I tried this(below) and many other thing, but nothing seem to work. Any suggestion on making this work? For i = 1 T...

Object dosent support this property or method
This code behind a command button should check to see if a record exists and open a form with that data if it does. If record does not exist it will open the form in data entry mode. I don't understand this error??? Private Sub cmdMember_Click() On Error GoTo Err_cmdMember_Click Dim stDocName As String Dim stLinkCriteria As String Dim dbcurrent As DAO.Database Dim rstemp As DAO.Recordset If IsNull([cmdMember]) Then MsgBox "Please enter a Member # before proceeding." Exit Sub Else 'Check to see if a record already exis...

Overtime Methods
I can't seem to find any information on how the overtime methods work in Advanced Payroll. I have read the online manual and looked in Knowledgebase, but I can't find anything about it. Any ideas where I can get help with this? Perhaps a kb number or something? Thanks! Tracey D What manual are you reading? For the overtime rates you need to read the overtime rate manager manual. You should be able to download it from CustomerSource. You can also send an e-mail to me. Take out the "nospam" part of the address. -- Charles Allen, MVP "Tracey D" wrote: ...

change valuation method
1. My company uses standard costing (FIFO periodic) on all items. We want to move to FIFO perpetual for one group of items. We do not want to create brand new items. What is the best way to convert the existing items in Great Plains from FIFO periodic to FIFO perpetual. 2. We tried changing overhead accounts on one item and got the error that you cant edit this account number as there are unposted receipts for this item. What tables do I check for this. We use manufacturing module too and are on GP 8. 3. When we receive an item on purchase receipt, we get PPV and also material overhead entri...

Is there a method in CString equivalent to std::string::replace?
Hi. How can I replace a substring in a CString? Isn't there an equvalent CString method? For example I can write: std::string s("C:\Temp\Some") s.replace(s.begin()+8, s.end(), "*.*", 3); After replacing 's' contains "C:\Temp\*.*"; How to implement this using 'CString'? Thanks in advance Martin No, 'CStringT::Replace' does quite a different thing: A snip from MSDN: int Replace( PCXSTR pszOld, PCXSTR pszNew ); int Replace( XCHAR chOld, XCHAR chNew ); This function replaces instances of the specified character or subs...

CheckHealth Method
Hi All, I want to confirm something related to CheckHealth method. I've read somewhere that if during operation for device say PosPrinter PrintNormal some error/exception occurs and you want to make sure this error is because of device like out of paper use the checkHealth internal method if it gives exception then indeed device is in error case i.e its not healthy. The problem is if I use External Health it gives me correct error in case paper is out but Internal Check Health returns ok. As per my understanding both should return error or exception. Am I right in my understa...

CView method
I have a CView class which is instatiated as a runtime class. I have overridden the OnCreate( ) method but it never gets called. Here is how I the CView (MyView) object is created: pDocTemplate = new CMultiDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(MyDoc), RUNTIME_CLASS(ChildFrame), RUNTIME_CLASS(MyView)); And here is my OnCreate method: int MyView::OnCreate(LPCREATESTRUCT lpCreateStruct) { AfxMessageBox("oncreate is getting called"); } Why is OnCreate not being called? Thanks. Jess Have you provided the entry ON_WM_CREATE in the message map of your view class? -VSP &q...

Boolean parameter in ActiveX method: wrong ole conversion?
Hi, I'm using Visual Studio 2005 and unmanaged C++ to write an MFC ActiveX Control. I want to add a method that takes a boolean parameter. Through the wizard I add this parameter as VARIANT_BOOL and so the wizard adds the following line in my idl file: [id(1), helpstring("method Test")] void Test(VARIANT_BOOL bParam); Moreover, it adds the following line in my control header file: void Test(VARIANT_BOOL bParam); I write the following simple code for the new method: void MyCtrl::Test(VARIANT_BOOL bParam) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); ...

Methods overloading?
Hi, i'm writing an activex control with MS VC++ 6.0,capable of drawing a certain number of graphs (max 5 graphs),which i want the user to choose. I would like to insert the data to be drawn with an InsertData method,but i've discovered with a little disappoint that i can't overload activex methods:indeed i would like the control to call the appropriate InsertData function depending on the number of quantities chosen,and i had thought of writing 5 different versions of the InsertData method,but,as already said,it isn't possible. Can you give me some advice? Mittik wro...

Flow of called methods in MFC
Hi all! Does someone know where I can find the sequence of methods that are called when I use this Microsoft's framework? Thanks in advance. Under what conditions? There are several thousand methods in MFC. For startup, it calls the virtual methods CWinApp::InitInstance, CWinApp::PumpMessage and CWinApp::ExitInstance. You can override these, but in practice you only want to override the InitInstance and ExitInstance. After that, you need to say a lot more about what you want to know. joe On Thu, 25 Sep 2008 09:19:57 -0700 (PDT), ScottBright762 <emersonespinola@gmail.com> ...

ClearContents method on a passed range
I want to create a range of results in one worksheet based on a range of input values in another worksheet in the same workbook. I've 'named' the input and result ranges in Excel but am unable to clear the result range using the following code called from Excel with '=Test1(results)' speciified in a cell: Public Function Test1(RangeResult As Range) RangeResult.ClearContents End Function The code runs o.k. but the range isn't cleared and zero is returned. I thought I was getting the hang of VBA but this has stumped me. bryan wrote... >I want to create a range o...

DLL
Hi, I am stuck. I tried so many different things to no avial. I am getting linker errors when I try to access methods in the .cpp = file. It works fine if access the method is in the .h file. x =3D GetPenthouse()->CallingPenthouse(); //Works because it is a Top = Level class x =3D GetPenthouse()->CallingMezzanine(); //Fails. Method in = Mezzanine.cpp file x =3D GetPenthouse()->CallingBaseInHeader(); //works. Method in Base.h = file *Note that I am using a nifty way of importing/exporting methods from = the DLL I found on Code Project. The following must be added to the stdafx...

Operator[] overloaded but how to access it as pointer?
hi all, I Overloaded the operator [] : double &operator[](DWORD); double &Classname::operator[](DWORD p) { return m_array[p]; } The problem is , I need to know how to access the operator if I yust have a pointer to the object. I want do something like the following : Classname* pObj; pObj = new Classname(); double test = pObj[0]; // that doesnt work , is there any possiblity to realize that? thanks a lot cheers Filip How about (*pObj)[0] -- Hank Williams Quantum Technologies, Inc. HaWilliams(at)spamcop.net "Filip Lyncker" <lyncker@gmx.de> wrot...

alternate series selection method?
I�m changing the Data Series Format of some of the data on a chart wit many series of data. To do this I select the series and right click then change the properties as needed. The problem I�m having is that the chart is heavily populated an sometimes selecting a point is difficult. Is there a way to �tab through the series, once I have one of them selected, so that I don� have to click each one -- Message posted from http://www.ExcelForum.com Hammer - The up and down arrow keys cycle through the series and the other chart elements. You can also select a series using the Chart Element ...

the Clear method for the Queue class
Hello! Can somebody explain what this text mean ? When you call the Clear method for a Queue object, the capacity of the Queue object is not changed. //Tony "Tony Johansson" <johansson.andersson@telia.com> wrote in message news:u7iQCYIGLHA.6120@TK2MSFTNGP04.phx.gbl... > Can somebody explain what this text mean ? > > When you call the Clear method for a Queue object, the capacity of the > Queue object is not changed. The capacity of the Queue starts out at a certain amount. As you enqueue items, the capacity may need to increase to hold a...

hlookup or other method
I have a spread sheet of 100 rows & 60 columns Bottom row is years 2008 thru 2068 -- Range A1:BH100 Columns have numbers scattered randomly. Most numbers are 0 Some rows have only one column with a number, others have several columns with numbers. The numbers are of different values and are not in ascending or decending value. How can I start in a1 and locate the first column,in the row, with a number greater than 0 and then identify the year? I need to start with " If(A1 = 0 ----. I have tried lookup, hlookup & match but probably am not doing something right. First of al...

Onkey method
How do you assign a short cut key to a macro I created. I am tryin to learn VBA and am working on writing code. I have been reading about the onkey method. Where in the code to you enter the short cut key? After the Dim Statement? Could some one give me a couple of easy examples or tell where I can find the code or symbols used for short cut keys? What happens if I use a key that is already assigned to do something else? Can it recognize when to use it to run a macro and when to use it for it original purpose? I am just learning VBA and trying to learn to code macros. I have manged to c...

Method of retriving specific data from a worksheet
Dear All, I have a worksheet with many many rows. Did anyone know how to retrieve specific data out and placed on another cell. Example: Column1 Column 2 Column 3 Column 4 Row1 David Man 30 50 Row2 William Man 5 4 Row3 David Man 5 20 Row4 Andy Woman 20 20 .... Outcome Result: RowA David Man 30 50 RowB David Man 5 20 I...

Extension method for static method?
I have a feeling the answer is "No" but is there way to create an extension method for a *static* method--say, if I wanted to extend the File class by adding a static Length method to it? On 2010-03-02 22:15, Harlan Messinger wrote: > I have a feeling the answer is "No" but is there way to create an > extension method for a *static* method--say, if I wanted to extend the > File class by adding a static Length method to it? The answer is indeed no. And the reason is that while instance extension methods allowed you to do something you couldn't do b...

Can we assign a value to a static variable in a static method.
Can we assign a value to a static variable in a static method. class Employee { public: static int getNumEmployees() {return numEmployees;} private: static int numEmployees; }; int Employee::numEmployees = 0; int Employee::getNumEmployees() { numEmployees = 15; // Doesnt allow you to do this??? return numEmployees;} int main() { int nNum = Employee::getNumEmployees(); return 0; } Regards, Alamelu N What happens if you change your code to this: >class Employee { >public: > static int getNumEmployees(); >private: > static int numEmployees; >}; ...

Ed Crowley method 2000-to-2003?
Would there be any problem trying to use the "Ed Crowley" exchange move method to upgrade an Exchange 2000 server to an Exchange 2003 server? Thanks. On Fri, 28 Oct 2005 14:54:50 -0400, Scamp@nospam.com wrote: >Would there be any problem trying to use the "Ed Crowley" exchange >move method to upgrade an Exchange 2000 server to an Exchange 2003 >server? > >Thanks. > Nope. Go for it. There are just a couple extra steps: - need to do the adprep if not on win2003 DCs - need to do the schema fixup prior to running exchange setup /forestprep - need ...

method to sequence
One column has cells which display either a number greater than 1, or 0. I need to have another column where the cells show the same numbers as those greater than one, and for the zeros, a number equal to one plus the last number for the last 0 (e.g. the first time a 0 is located in column A, the cell in column b, same row, = 1, next time 0 is located, column b value = 2, etc.). Thanks very much, Jayne G. Hi enter the following in B1 =IF(A1>1,A1,COUNTIF($A$1:$A1,0)) and copy down -- Regards Frank Kabel Frankfurt, Germany Jayne G. wrote: > One column has cells which display either ...