|
-
Oct 3rd, 2021, 12:44 PM
#1
Re: Getting the ball rolling. Which VB6 projects are you working on?
I use UDTs all the time and I've never had any problems at all, and I really don't have any confusion about them.
I guess there are two places that we must be careful with them:
1) The inter-variable padding is a bit strange. But, with a bit of VarPtr use on the variables, it's easy enough to figure it out. Also, on one or two API calls, we've got to be careful with this. However, 99% of the time, it even works perfectly in these cases ... and, for that 1%, there are easy workarounds just using Byte arrays in our UDT. However, if we're the only one using our UDTs, then this inter-variable padding is seldom of any concern.
2) You can't put them in Variants without defining them in a TypeLib. However, as I've shown in the past, we can actually create these TypeLibs with the VB6 IDE (i.e., no need for MIDL).
And, if we learn how to use the Friend declaration, we can pass them just about anywhere we like.
--------------
And just as an FYI, here's how you can use the VB6 IDE to create a typelib:
- Start VB6 Project.
- Under Project/Project1 Properties..., change it to an ActiveX DLL.
- Add a standard module and put a Sub Main in it.
- Add a Class1 module.
- Create any UDTs you like in this Class module, making sure they're declared as Public.
- Under Project/Project1 Properties... again, go to the "Components" tab and check "Remote Server Files".
- Compile the project.
- Voila, a Project1.tlb file appears, with your UDTs available for use (and they'll go into Variants).
You might want to rename this project so it's something other than Project1. That way, it won't conflict with other quick-test projects.
Also, the act of compiling this "Remote Server Files" project registers your new typelib. So, if you move it to other computers, you'll have to re-register it to use it.
The only (main) downside of creating your TypeLib this way is that it needs to be distributed with your compiled project. If you use MIDL, you won't need to distribute the typelib once you're compiled.
Last edited by Elroy; Oct 3rd, 2021 at 01:35 PM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|