Download advanced visual basic 6 power techniques for everyday programs




















Average rating 4. Rating details. All Languages. More filters. Sort order. David rated it it was amazing Sep 26, Lbrt rated it it was amazing Sep 21, Stuart Calder rated it liked it Jan 09, Robin Guest rated it liked it Nov 01, Tyson A. Nigel rated it it was amazing Aug 24, Josh rated it liked it May 21, Karen Merryman rated it really liked it Mar 27, Cynthia rated it it was amazing Dec 29, Kay rated it it was amazing May 24, Aleksi rated it it was amazing Dec 14, Ken rated it liked it Dec 31, Tim rated it really liked it Sep 25, I'm starting with arrays, not because I think they're the most commonly used construct in and of themselves, but because they allow you to use standard code to make VB modify arbitrary memory locations.

VB automatically allows you to write to the data portion of an array, but you can open up a whole world of direct memory access by reading and writing to the descriptor and the array variable in addition to the data. You'll also see how to best use arrays in straight VB code. The techniques shown in this chapter are used throughout the book to enable and optimize other technologies. IUnknown calls are costly in terms of runtime overhead and code generation so understanding the IUnknown interface is very important.

Visual Basic frequently calls IUnknown for you, even though you don't call it yourself. Familiarity with IUnknown is also required to build COM objects from the ground up, as you'll see in later chapters. Binding to an object implies that code associated with an object class is applied to a specific instance of that class. You'll see how the VB compiler determines when and how to bind, and how to enable fully dynamic binding at runtime.

You'll also see how to bypass the layers that VB puts around a custom control in order to minimize runtime overhead by talking directly to a control's native vtable interface. A well-designed architecture, regardless of the technology employed, is probably the most important factor in the success of your program.

You can refer to your program design philosophy as object-oriented, interface-based, optimized for reuse, or all of the above. Regardless of your phraseology, your goal is to write a stable and easily maintained program.

This chapter looks at VB approaches to the tried-and-true principles of pluggable components, abstraction, and code reuse.

VB natively offers the Implements keyword to provide a shape for your object, and this keyword can take you a long way towards reaching your design goals with interface-based programming. However, you'll find yourself chafing at the inability to achieve easy implementation reuse. I'll take you outside the confines of VB in order to enable full implementation reuse by aggregating existing objects. This gives you the ability to combine multiple implementations into a single object. You will run into circular-reference problems almost every time you design an object model.

If you know in advance how to handle this situation by using strong references normal object variables and weak references pointers to objects , you will have the tools you need to design object systems without any teardown surprises.

To help you compare different approaches, I'll also show you the steps required to solve circular reference problems without pointers including the pitfalls that make this solution incomplete and overly cumbersome. I'll then apply the weak reference techniques to collections, object ownership, and pain-free hierarchical object models. All COM objects can be placed within one of two categories: those inside your project and those outside of your project.

COM objects are never created directly. Instead, COM uses the registry to create class factory objects, which are then used to create actual class instances. It is surprisingly easy to deal directly with the factory in order to load objects directly from ActiveX DLL and OCX components based on the application path rather than the registry.

You'll see how to use aggregation and class factory loading to dynamically specify controls as MDI pages. I'll finish by showing you how to use the CoRegisterClassObject and CoGetClassObject APIs to offer your own application-level singleton objects, creating an easily retrievable context object across multiple components.

You'll see a few simple lightweight objects that give you stack-based local objects, termination code in local- or module-level structures, and the ability to implement arbitrary interfaces that can be aggregated into normal VB objects.

Along the way, you'll see all the steps needed to create arbitrary objects: vtable layout, memory-allocation options, reference counting, interface recognition with QueryInterface, and a number of options for generating and handling errors.

VB class modules are perfect for creating a small number of highly complex objects. But the overhead of each object makes it prohibitively expensive to create a large number of very simple objects. Algorithms ranging from scheduling tools to compilers often require thousands of small objects rather than a few large ones. You'll see how to use a custom memory manager to allocate lightweight objects without compromising the coding experience of consuming those objects.

When you're done with the objects, you can free them individually or use a single call to reclaim the memory used by the entire object system. This chapter describes the use and implementation of a lightweight object that lets you place an object in the ROT and automatically remove it when your object terminates.

The implementation details look at advanced lightweight objects topics, such as support for multiple interfaces in a single lightweight object and how to hold weak references to secondary interfaces safely. VB first offered support for proffering function pointers with the addition of the AddressOf operator in VB5.

In addition to its primary purpose of enabling a host of Win32 API calls from within VB AddressOf also enables you to create the vtables for lightweight objects. This chapter defines a lightweight object that turns the tables on VB by letting you call a function pointer as well as provide one. Function pointers open the door to a number of possibilities, such as dynamically loading and unloading DLLs, writing arbitrary sort routines, using explicit stack allocation in VB, and calling inline assembly code.

The ability to call standard function pointers still leaves a couple of holes, so I'll also show you how to associate an object instance with a function pointer greatly simplifying standard operations, such as subclassing windows , and how to call cdecl functions, enabling you to call entrypoints in MSVCRT and other cdecl DLLs. Somewhere in between Implements, which offers no implementation reuse, and aggregation, which offers full implementation reuse, lies partial implementation reuse, which is one of the key benefits of inheritance.

The usefulness of inheritance relies heavily on a derived class's ability to override the implementation of specific functions in order to make calls to the base class's functions reach the derived class first.

This chapters shows you how to override functions either by using function pointers to redirect calls from the base class or by customizing the aggregation techniques for individual objects in order to override functions without any cooperation from the base class.

You have to write a little extra code to use inheritance in VB6, but that's far better than not being able to do it at all. This chapter tries to make some sense of the term multithreaded, and shows you how to make full use of VB's threading capabilities.

I'll also show you how to launch worker threads in a DLL with cross-thread object support offering optimal programming flexibility orwithout object support offering optimal performance. Visual Basic makes string manipulation very easy. You have a number of operators and string functions at your disposal. However, this does not mean that string manipulation is free. Every string is a block of memory, and larger strings are much more expensive than smaller strings.

Automatic string caching can lull you into a false sense of security that vanishes instantly when strings grow beyond the cache size. Learn the true costs associated with VB's String type and how to minimize your string overhead, including how to treat a string as an array of numbers for blazingly fast string algorithms.

Although VB relies on type libraries to compile components and to expose those components to external applications, the day-to-day work of consuming and generating typelibs takes place almost completely behind the scenes. Integrated typelib generation is almost always the right thing, but in most large projects there will be times when you desperately need to get a hand inside a typelib. This chapter shows you how to create typelibs for VB to consume and the reasons why you might want to make custom edits to binary compatibility files and the typelibs that are generated with all ActiveX projects.

Instead, it lays out the requirements for the actions you can perform with these tools. Most client-side VB programs are built around windows. In fact, VB gained its first foothold in the programming world because it made it so easy to create Windows applications by separating you from the complexities of direct interaction with window objects. But this protective layer brings with it a certain amount of frustration if you try to interact with windows at the level of creation and window procedure.

This chapter applies the function pointer, direct memory access, lightweight object, and function overriding techniques from earlier chapters to window objects in general and custom controls in particular.

You'll learn about a lightweight and pain-free subclassing approach to control incoming window messages.

With subclassing tamed, I'll move on to custom window creation and creating windowless controls that act just like windowed controls. The VBoost objects are a small library of functions that provide the base technology pieces required for many of the techniques in the book.

Dll and a VB implementation in VBoost. Bas, which allows you to remove the external VBoost dependency. Both implementations provide everything you need to perform aggregation, custom IUnknown hooking, and function overriding. You also get two optimized memory-management variations and a set of assignment and arithmetic functions that greatly simplify the manipulation of pointers in VB.

In addition to the code, VBoost includes a set of typelibs categorized by functionality. These typelibs enable easy compilation of all the files in the Code directory on the CD. I would like to thank first and foremost my talented and beautiful wife Lynn for putting her own endeavors on a compressed schedule while this one mushroomed and took on a life of its own. Thanks to my daughter Elizabeth, who has grown during this book from dragging me away from the computer to telling me when it's time to come play.

Shipping dimensions: pages, 9. Published: July 13, Publisher: Pearson Education. Language: English. Appropriate for ages: All ages. ISBN - Customer Reviews. Select Parent Grandparent Teacher Kid at heart. Age of the child I gave this to:. Additional order info. Buy this product. K educators : This link is for individuals purchasing with credit cards or PayPal only. Building Blocks.

Phantom Pointers. Pearson offers affordable and accessible purchase options to meet the needs of your students.



0コメント

  • 1000 / 1000