We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 72,245 times

Contents

Related Categories

Skinning (BitBlt Introduction) - BitBlt API

Smile005

BitBlt API

The first API function I'm going to teach you about is BitBlt. If you already know how to use this function then this tutorial will not be of much use to you, otherwise keep on reading. The decleration of BitBlt is a long one, check it out:

Declare Function BitBlt Lib "gdi32" ( _
  ByVal hDestDC As Long, _
  ByVal X As Long, _
  ByVal Y As Long, _
  ByVal nWidth As Long, _
  ByVal nHeight As Long, _
  ByVal hSrcDC As Long, _
  ByVal xSrc As Long, _
  ByVal ySrc As Long, _
  ByVal dwRop As Long) As Long


Don't be scared off by the complex look of it. In practice it's quite easy to use.

Let's start by going through each parameter.

The first is hDestDC and this is just a handle to the container you want to draw onto. This can be any control with a DC (which stands for device context). You can usually get the DC of a control via the hDC property. For my example we will be painting onto the form so we will use the forms hDC property for this parameter.

Then we have to pass the X & Y coordinates (in pixels) for where on the destination we want to start the painting. This is the equivilant of the Top & Left properties of VB controls. In this tutorial we will use 0 for both these values as we want the entire form painted from top to bottom.

We then specify the width & height (nWidth and nHeight) of the painting. This is equivilant to the Width & Height properties of VB controls. If the source image is larger than either of these it will be cropped (cut off at the right or bottom sides). To cover the entire form we will need to set these as the forms height and width.

The next parameter is the source DC (hSrcDC) which is where BitBlt gets the data to be copied over. In this tutorial we will be using the DC of the picture box that contains the image.

Then we have to give BitBlt xSrc & ySrc values, these are the values that BitBlt will start copying over from. For this basic tutorial they will be set as 0 always.
You might have noticed that there is no nSrcWidth or nSrcHeight variables. That is because BitBlt uses the nWidth value for the destination width and source width.

The last parameter is what we use to tell BitBlt how to copy the image over. VB contains it's own constants for this parameter so we might as well use them. You could define your own constants but as VB already provides them I think it's easiest to use the ones already provided. In this tutorial we're only going to use vbSrcCopy.

Apart from my school work I put most of my effort into running my joke site, I'd like to think that it makes someone smile each day. For about 1/2 a year I've been programming more and more in server side languages such as PHP and ASP, this is the partly the reason why I haven't continued any skinning articles. With my half migration to the open source software world (i.e. Linux) I've been forced to spend less time programming in Visual Basic, hopefully I will go back to doing most of my programming in VB soon.

Comments

  • Re: Skinnable VB.NET Form

    Posted by Scotty01 on 07 Feb 2007

    umm.... how do i fix the obstruction problem? help wanted fom any1

  • Skinnable VB.NET Form

    Posted by arizona2005 on 10 Feb 2006


    thanks for the great material you posted but unfortunatelly for me
    it all is in VB6. Can you show me a VB.NET example for this problem

    thanks

  • sample

    Posted by acnetonline on 16 Nov 2005

    there's a sample code in vb.net on this website that changes text to html. maybe you can use it?

  • Posted by DeviousAsti on 17 Jun 2005


    You can use a simple random XOR shift to do the 'encrypting'... as you probably know XOR of XOR gives original, so you can use the same for encoding/decoding provided the shift key is right. If you ...

  • how to encrypt picture using visual basic

    Posted by Sindu on 17 May 2005

    how to encrypt picture files using visual basic so that only certain people who know the password can see the picture