SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This book will concentrate on C++ and some C# techniques that will benefit Visual Basic programmers. The author's approach is to cover things that "feel good" in each language and where the languages can enhance each other, then the basics of C++, from a VB programmer's perspective, and finally COM and ActiveX programming in depth. This book should be more practical than most; much of the code shown will be shipping commercially and have a demonstrated application. There will be a great deal of source code, and will include controls and COM objects that can be directly adopted by the reader.
C Programming for Visual Basic Lovers
Introduction.
1. How Did We Get We Here?
A History of Visual Basic and C++.
16 Bit.
32 Bit.
.NET.
Visual Basic's Contribution.
Strengths of Visual Basic.
Weaknesses of Visual Basic.
C++'s Contribution.
Strengths of C++.
Weaknesses of C++.
C#.
Tokens and Elements.
Keywords.
Identifiers.
Constants.
Literals.
Predefined Constants and Macros.
Structure.
Directives.
Code Structure.
Lifetime.
Scope and Visibility.
Functions.
Prototypes.
Definitions.
Invoking Functions.
main, wmain, DllMain.
Function Pointers.
Summary.
Variables and Data.
Type Specifiers and Qualifiers.
Variables and Declarators.
Initialization.
Expressions.
Operators and Precedence.
Precedence.
Conversions and Type Casts.
Statements.
Assignment.
Control and Flow.
Looping.
Summary.
Tokens and Elements.
C++ Keywords.
Identifiers.
Constants and Literals.
Structure.
Directives.
Scope, Visibility, and Lifetime.
Linkage.
Functions.
Prototype.
Variable Number of Parameters.
Overloading.
Variables and Data.
Runtime Type Information.
C++ Definitions and Declarations.
Variables and Declarators.
Namespace.
Expressions.
Operators.
Casting.
Statements.
Error Handling.
C++ Exception Handling.
Structured Exception Handling.
Summary.
Classes.
OOP Concepts.
Basics of Classes.
Names.
Class Members.
Member Variables.
Member Functions.
Member Access Control.
friend Functions.
Derived Classes.
Basics.
Multiple Base Classes.
Using Declaration.
Abstract Classes.
Summary.
How the Windows System Works.
Processes and Threads.
Message Subsystem.
How a Windows Program Works.
Window Class.
Creating a Main Window.
Base Services.
GDI.
Summary.
Tutorial for Creating a Simple C DLL.
Using Visual C++ to Create the DLL.
Exporting the Function from C.
Prototyping the Function.
Writing the Function.
Starting Visual Basic from the C++ Environment.
Declaring and Using a Function from Visual Basic.
Debugging the C++ Code.
Tutorial Summary.
Passing Numeric Variables.
Four-Byte Integers (Longs).
Two-Byte Integers (Integer).
Four-byte Real (Single).
Eight-Byte Real (Double).
Boolean.
Currency.
Using Strings.
Passing C Strings (ByVal).
Handling a BSTR.
Passing Byte Arrays.
Passing and Use Structures (UDTs).
Passing and Using Variants.
Pass and Using Arrays.
Unicode and ANSI 198Conclusion.
Type Libraries and DLLs.
Tutorial for Creating a DLL Including Type Library Information.
Some Finer Points of the IDL File.
Adding Resources to a DLL.
Samples of C DLLs.
Subclassing.
Support of InstallShield.
Extended Stored Procedures.
Callbacks, Hooks, and Other Nasty Things.
Summary.
Basics of Components.
Components and Inheritance.
Inheritance Defined.
Abstraction.
Encapsulation.
Polymorphism.
Inheritance.
Delegation.
Aggregation.
COM.
Interfaces.
Custom Controls.
Methods Used to Build Controls.
Visual Basic 5 and 6.
MFC.
Visual Studio.NET.
ATL Controls in Detail.
Creating the Control Project.
Adding Properties.
Adding Methods.
Implementing Events.
Windows Message Maps.
Handling the Mouse.
Handling the Keyboard.
Property Pages.
Proper Property Persistence.
Enumerated Properties.
Categorizing Properties.
Returning Errors .
Safe for Initialization and Scripting.
Licensing.
IsimpleFrame.
Basing a Control on a Windows Control.
Composite Controls.
The C# Type System.
Value Types in Action.
Reference Types.
Boxing and Unboxing.
Programming Concepts.
Namespaces.
Statements.
Operators.
Arrays.
struct.
Classes.
Object.
Methods.
Properties.
Operators.
Inheritance.
Interfaces.
Delegates.
Summary.
C# WinForm Controls.
Creating the Control Project.
Coding the Control.
Control Elements.
NameSpaces.
Properties and Methods.
Events.
Design Time Support.
Drawing.
Summary.
This book was written for intermediate to advanced Visual Basic programmers. It is not for advanced C and C++ programmers, although intermediate level C programmers might find the book beneficial. Many chapters would be tedious for someone who does not know Visual Basic, because of all the comparisons are drawn to Visual Basic code.
So now that I have the Visual Basic programmer's attention, I want to ask a simple question. Do you want to program in C, C++, or C#? Are these languages that you want on your tool belt? This question may be more difficult to answer than you might expect.
Why should you care about these languages? The short answer is that the C family of languages is the consummate choice of programmers who want to program without restrictions. You can think of anything you want to do in programming and there is a way to get it done in C, C++, and C#. There are very few language families that can make that claim. Given that, isn't C a language that you would like to know?
The longer answer has to do with the evolution of Basic and C. In the past, Visual Basic had definite advantages in designing user interfaces. It was much simpler to do in Visual Basic than in C or C++. Now, C# and Visual Basic (and a number of other languages, for that matter) use the same designer and share the same user interface design capabilities. The advantage has slipped away from Visual Basic in this department.
Visual Basic had some other qualities that made it easier to develop and use end user programs, especially for fairly inexperienced programmers. This advantage has slipped away too. The latest Visual Basic is a magnitude more complicated than previous versions and much harder to get your arms around. Moving to the latest Visual Basic language from Visual Basic 6 may be just as difficult as making the move to C#.
Microsoft says choosing a language is a lifestyle choice now. I think the choice carries more implications than that. C has always been the internal development language at Microsoft--well, C or a derivative of C. First was C, then C++, and now C# is being used extensively at Microsoft. What affect does this have on the language? Just the effect you might expect. If a Microsoft programmer needs a feature in C, C++, or C# to get his job done, he or she typically gets that feature. So now you are faced with a situation where C# is actually more capable than Visual Basic but, because of the designer, it's just as easy to use.
For example, C# can be used to write unmanaged code; Visual Basic cannot. C# can override operators; Visual Basic cannot. C# can access memory directly; Visual Basic cannot. We could go on with this list and we will later, but the point I want to make now is that Microsoft uses C# as the premier development language in the .NET technologies.
Am I advocating that you switch to C# now? I am advocating that you learn a language that is and has been at the top of this game for many years. This book will concentrate on components and about the differences in Visual Basic and C. I will show you how to write routines and objects that you can use to augment your Visual Basic skills. At the same time, there is enough information in this book to shift to C# completely if you want. My main point remains that you will want to know enough about these languages to augment your Visual Basic skills. If you decide to shift to the C family altogether, this is a good way to begin your transition.
The following summary should introduce you to the main aspects of this book.
If you've been thinking about learning to program in C, now is the time to start the journey. You have a steep hill to climb moving from Visual Basic to .NET technologies, and it just might afford you the opportunity to expand your language choice.