Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 72,689 times

Contents

Related Categories

Skinning (BitBlt Introduction) - Example

Smile005

Example

Create a new VB project and in the decleration section of the form (at the top, before any functions or sub-routines) add the BitBlt decleration:

Private 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


Now add another form, and fill it with a picture box. Name the new form 'frmPic' and the picture box 'pbxPic'. Make this new form and picture box larger than the first form. Add a picture of your choice to the picture box and return to the code of the first form.

In the Form_Load event of the first form, add:

frmPic.Show
Me.Refresh


Then in the Form_Paint event (to get the form paint event, select 'Form' from the drop-down menu on the top left of the code window and then 'Paint' from the drop-down menu on the right of the code window.) add this:

BitBlt Me.hDC, 0, 0, Me.Width * Screen.TwipsPerPixelX, Me.Height * Screen.TwipsPerPixelY, frmPic.pbxPic.hDC, 0, 0, vbSrcCopy

(We multiply the width by the twips per pixel to convert the twips value from the form to the pixel value that BitBlt accepts.) Lastly, add the Form_MouseDown event and put this code into it:

Me.Refresh

You can now run the program. For best results put both forms apart on the screen and click on the first form. The image should be painted to the first form.

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