Results 1 to 28 of 28

Thread: Pointers, like in C?

Hybrid View

  1. #1
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Pointers, like in C?

    Quote Originally Posted by penagate
    Now if only we could find a way to get around the BAS module limitation... I know you can do it using machine code, so maybe there are ways to do that too.
    The AddressOf keyword only works with procedures in modules. The reason MS implemented it this way is because normally callbacks are called from an API function that runs in a separate thread and as such they can't be used with classes or forms that's created by the main thread in VB.

    Since besides the AddressOf keyword there isn't any other native way to get the address of a function I doubt you will find a way. However I don't think that is much of a limitation. The fact that the callback needs four arguments is not much of a limitation either. All callbacks have a determent signature that you must follow so that doesn't matter much. If you need more arguments you can simply do as the API functions does, pass the address of a UDT (struct).

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

    Re: Pointers, like in C?

    Quote Originally Posted by Joacim Andersson
    The reason MS implemented it this way is because normally callbacks are called from an API function that runs in a separate thread and as such they can't be used with classes or forms that's created by the main thread in VB.
    Why is that? Surely it is possible to get the base address of the class and then add the offset of the function? Or is it because VB shifts them around in memory, so they're not always in the same place?

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