Library tutorials & articles
Skinning (BitBlt Introduction)
- Introduction
- BitBlt API
- Example
- Conclusion
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.
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
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
there's a sample code in vb.net on this website that changes text to html. maybe you can use it?
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 supply the file (binary) to this function, then it'll return encoded with the given key.
If you pass the encoded file, it'll return the original file.
[courier new]
Public Function EncodeDecode(Data As String, Key As Long) As String
On Error Resume Next
Dim I As Long, X As Single
Dim CharNum As Integer, RandInteger As Integer
Dim SingleChar As String * 1
Dim ReturnData As String
X = Rnd(-Key)
For I = 1 To Len(Data)
CharNum = Asc(Mid$(Data, I, 1))
RandInteger = Int(256 * Rnd)
CharNum = CharNum Xor RandInteger
SingleChar = Chr(CharNum)
ReturnData = ReturnData & SingleChar
Next I
EncodeDecode = ReturnData
End Function
[/courier new]
But how do you make a key out of password ? Convert it to a number that vastly varies according to the password...
[courier new]
Public Function ConvertPassKey(Key as String) As Long
Dim I As Integer, Num As Long
Key = LCase(Key)
Num = 1
For I = 1 To Len(Key)
Num = Num + (I * Asc(Mid(Key, I, 1)))
Next I
ConvertPassKey = Num
End Function
[/courier new]
Be VERY, VERY WARY of the data you pass to the function. A slight shifting of even a single character will ruin the entire decoding process, and you'll get junk data!!!
I suggest you do multiple "parity" checks before actually give it up for decoding....
Also, encoding/decoding takes some time... that's why i prefer my tried and tested method "mangle da header!"
Enjoy !
how to encrypt picture files using visual basic so that only certain people who know the password can see the picture
hello friends
now i am in trouble.plz help me in convert the doc file into html format using vb
programing code.
plz help me i wait yours reply
This thread is for discussions of Skinning (BitBlt Introduction).