vbTutor

Graphics

Sound

Miscellaneous


BitBlt

BitBlting is good if you want to just stick a picture of somthing in the middle of nowhere. You'll need to cut or copy a the picture from somewhere in the form, then place it somewhere else. First, you'll need to create a module to stick the following into:

Now you can go back into your form. Place an image into picture box and let it be named Picture1. As an example, place an icon (32 x 32 pixels) into it. Remember, this does NOT have to be an icon, but just make it one while you learn. Now, try placing this line of code under Picture1_Click:


What's wrong, don't you know what it means? Well, the first part, hDC means it will be copied into the form. If it had said Picture2.hDC, it would have been placed into Picture2.
The 20 represents the X coordinate where it will be placed on the form (or Picture2), and the 10 represents the Y coordinate.
The first 32 represents how many pixels wide to copy, and the second 32 tells how many pixels tall to copy.
The Picture1.hDC tells where to copy from (that's where the icon or some other image should be).
I don't know what the next 32 means, but I usually make it the same number as those other 32's.
The 0 tells the style of copying. 0 means copy as is (default), 1 says to copy with a transparent background (depending on what the MaskColor property is set to), 2 draws the image dithered with the system highlight color, and 3 draws the image dithered and striped with the highlight color.
Finally, the SRCCOPY means to copy it (you could delete it or something if you wanted).

GetPixel

This is used for testing what color background something is over. First, you need to declare the following line in a module:

The way I think it works is that the hDC part is which part your testing (eg: Picture1.hDC). The X is the X coordinate you want to test and the Y is the Y coordinate you want to test. Simple, isn't it? You call up the function from the form in a similar fasion to the BitBlt example.


Playing Midi (.mid) files

This code can be a bit confusing, especially since there are about 4 parts to it.

To open a file, you would do something like this (changing "YOURNAME" to anything you want):

To play this file do something like the following:

To stop the file, do the same line, but change "play" to "stop". To close the file use the same line, but change "play" to "close".


Playing Wave (.wav) files

This one's pretty easy. First, create a module in your project. In that module, place the following code:

Now, create a button and place the following code into the procedure Command1_Click:

The App.Path part just says to use the directory that you save this project in. If you are planning on using App.Path, you MUST save the project first. Where it says "\youfile.wav", the "\" must stay there. You can change the "yourfile.wav" part to the name of your file. The SND_NODEFAULT and SND_ASYNC are just 2 of the constants you can use. Try playing around with it.


Putting icons in the icon tray

Ever wonder how to place you icon into the right corner of the taskbar? This is something I found on another web page, but it was too complex to put it here. Click here to download this example.