Results 1 to 5 of 5

Thread: [DESPERATION] IDE question: hiding classes public methods doesn't work!

  1. #1

    Thread Starter
    Lively Member MartinD's Avatar
    Join Date
    Aug 2005
    Location
    Field north to Tannenberg, 6ft under
    Posts
    74

    [DESPERATION] IDE question: hiding classes public methods doesn't work!

    I do following:
    Make a class, make a method (public function), then make it hidden (Tools->Procedure attributes(select RIGHT procedure in combo)->Advanced->Attributes frame, check hide this member ->OK button..
    It doesn't work!
    Objects made from this class display this method in properties/methods dropdown menu ('properties/methods' list, Ctrl+J)...
    Is it a known bug or I am doing something wrong?
    Last edited by MartinD; Sep 14th, 2005 at 04:06 PM.

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Location
    Lexington, SC
    Posts
    586

    Re: IDE question: hiding classes public methods doesn't work!

    Why would you make it public if you dont want it to be displayed outside of the class?

    Just make it Friend or Private.. friend will only let it be seen to modules in the same project as the class.. private and it can only be accessed from within the class

  3. #3

    Thread Starter
    Lively Member MartinD's Avatar
    Join Date
    Aug 2005
    Location
    Field north to Tannenberg, 6ft under
    Posts
    74

    Re: IDE question: hiding classes public methods doesn't work!

    Unfortunately I can not, I am just trying a MSDN example: HOW TO ENABLE For Each... Next in Collection Module

    Enabling For Each … Next
    Along with robustness, you get For Each … Next back. Once again you can delegate all the work to the Collection object, by adding the following method:

    ' NewEnum must return the IUnknown interface of a
    ' collection's enumerator.
    Public Function NewEnum() As IUnknown
    Set NewEnum = mcolEmployees.[_NewEnum]
    End Function

    The important thing you're delegating to the Collection object is its enumerator. An enumerator is a small object that knows how to iterate through the items in a collection. You can't write an enumerator object with Visual Basic, but because the Employees class is based on a Collection object, you can return the Collection object's enumerator — which naturally enough knows how to enumerate the items the Collection object is holding.

    The square brackets around the Collection object's _NewEnum method are necessary because of the leading underscore in the method name. This leading underscore is a convention indicating that the method is hidden in the type library. You can't name your method _NewEnum, but you can hide it in the type library and give it the procedure ID that For Each … Next requires.

    To hide the NewEnum method and give it the necessary procedure ID

    On the Tools menu, click Procedure Attributes to open the Procedure Attributes dialog box. In Name box, select the NewEnum method.


    Click Advanced to show the advanced features. Check Hide this member to make NewEnum hidden in the type library.


    In the Procedure ID box, type –4 (minus four) to give NewEnum the procedure ID required by For Each … Next. Click OK.
    Important In order for your collection classes to work with For Each … Next, you must provide a hidden NewEnum method with the correct procedure ID.


    It is basically as simple as that... What is written in MSDN doesn't work! Has anyone else tried to hide methods? You may not even try to solve this puzzle for me, just say, have you ever managed to hide a public method! Thanks!
    Last edited by MartinD; Sep 14th, 2005 at 03:10 PM.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [DESPERATION] IDE question: hiding classes public methods doesn't work!

    If you have the collection class in a separate DLL project then it will be visible only in that project. It will not be exposed in an application that references the DLL containing that class.
    Last edited by penagate; Sep 15th, 2005 at 08:18 AM.

  5. #5

    Thread Starter
    Lively Member MartinD's Avatar
    Join Date
    Aug 2005
    Location
    Field north to Tannenberg, 6ft under
    Posts
    74

    Re: [DESPERATION] IDE question: hiding classes public methods doesn't work!

    Ah, an enlightment. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width