Windows API Tutorial - Part Two
The truth? You wanna know the truth? Hah, you can't handle the truth.
Still, it's going to be a very short conclusion if I don't tell you so here goes: Visual Basic isn't really Visual Basic. Oh no.
<Reader: So who is it, Karl? Who?>
You see Visual Basic is really just... <Karl steps over to VB and pulls off the wig. There is a mass gasp> ... that's right, a whole bunch of API statements in a very good disguise.
Oh yes. Although Visual Basic hides all the intricacies of its complex API calls under the hood, they're always sitting there, waiting.
Every time you run - Form1.Print "Hello" Visual Basic tootles off and calls the TextOut API function, passing all the required parameters.
And when a user clicks your Command Button, Windows sees this. It then sends a message (via the very popular SendMessage function) to Visual Basic saying, "Hey, some geek just clicked your button". VB analyses the message, realises what's happening then raises the Click event of your Command Button, thereby executing any code within it.
And phew! - the list goes on.
As you can see, Visual Basic hides a lot of stuff from you. In fact, Windows is all really just a whole bunch of API calls cobbled on top of each other.
And in this two-part series, we've taken a peek at some of the things our favourite programming language manages to cover up so very well.
More specifically, today we've looked at giving our application the Office look, discovered how to retrieve the Windows path, plus checked out how to display the desktop background on a form all via the API. We went on to fiddle with a few activity projects, plus found out where you can take your skills from here.
I hope this tutorial has helped you understand more about the API and if I've done my job right, you won't feel too nervous about utilising its potential in future projects.
At times it might seem about as pointless as French marriage vows, but bear with it. You're going under the hood, touching those parts regular code can't reach. And that takes a bit of work but it can be very rewarding too.
People have used the API for allsorts. From simply enhancing their regular programs to building little add-ons that run on top of other applications, such as certain AOL utilities. Some even use the API in conjunction with ActiveX controls (see our tutorial here - www.vb-world.net/activex/controls/) to build lightweight, reusable components.
And now you have the knowledge to do this too. Whatever you get up to please let us know by posting feedback on the bulletin board. You can also mail me personally - firstname.lastname@example.org
But until the next time, this is Karl Moore signing off, concluding this API tutorial and wishing you all the very best in anything you may do. Goodnight!
Page 9 of 9