|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/21/2008 8:26:14 AM
Posts: 3,
Visits: 6
|
|
| Can anyone advise me how to capture a screen shot of the current ActiveX session and load it into a PictureBox in VB6 please? Thanks in advance
|
|
|
|
|
Supreme Being
      
Group: Administrators
Last Login: Yesterday @ 9:54:11 PM
Posts: 864,
Visits: 1,419
|
|
| I don't know VB, but just in case here is a .Net C# code: using (Bitmap bmp = Bitmap.FromHbitmap(new IntPtr(vncCtrl.ScreenBitmap))) { //do something with bmp } ScreenBitmap property returns HBITMAP handle of a current screen bitmap.
 Kindest Regards, SmartCode Solutions Support
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/21/2008 8:26:14 AM
Posts: 3,
Visits: 6
|
|
| Thanks for the reply, this is how I guessed it should work when looking at the help file. The problem I have is then converting the HBITMAP handle to an image in VB6, I have searched the web and cannot seem to find a VB example?
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/21/2008 6:56:03 AM
Posts: 1,
Visits: 1
|
|
Try CreatePicture function from here:
Private Declare Function OleCreatePictureIndirect _
Lib "olepro32.dll" (Pic As PictDesc, _
RefIID As Guid, _
ByVal fPictureOwnsHandle As Long, _
IPic As IPicture) As Long
Private Type PictDesc
Size As Long
Type As Long
hImage As Long
Data1 As Long
Data2 As Long
End Type
Private Type PicBmp
Size As Long
Type As Long
hBmp As Long
hPal As Long
End Type
Private Type PicIcon
Size As Long
Type As Long
hIcon As Long
End Type
Private Type PicWmf
Size As Long
Type As Long
hMeta As Long
xExt As Long
yExt As Long
End Type
Private Type PicEmf
Size As Long
Type As Long
hEmf As Long
End Type
Private Type Guid
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Const S_OK As Long = 0
Public Function CreatePicture(ByVal hImage As Long, _
Optional ByVal PicType As PictureTypeConstants = vbPicTypeBitmap, _
Optional Data1 As Long = 0, _
Optional Data2 As Long = 0) As IPicture
Dim Pic As PictDesc
Dim IPic As IPicture
Dim IID_IDispatch As Guid
' Fill in with IDispatch Interface ID
With IID_IDispatch
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
' Fill PictDesc struct with necessary parts
With Pic
.Size = Len(Pic) ' Length of structure
.Type = PicType ' Type of Picture
.hImage = hImage ' Handle to image
.Data1 = Data1
.Data2 = Data2
End With
' Create and return Picture object
If OleCreatePictureIndirect(Pic, IID_IDispatch, False, IPic) = S_OK Then
Set CreatePicture = IPic
End If
End Function
Public Function CreateBitmapPicture(ByVal hBmp As Long, _
Optional hPal As Long = 0) As IPicture
Dim Pic As PictDesc
Dim IPic As IPicture
Dim IID_IDispatch As Guid
' Fill in with IDispatch Interface ID
With IID_IDispatch
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With
' Fill PicBmp struct with necessary parts
With Pic
.Size = Len(Pic) ' Length of structure
.Type = vbPicTypeBitmap ' Type of Picture
.hImage = hBmp ' Handle to bitmap
.Data1 = hPal ' Handle to palette (may be null)
End With
' Create and return Picture object
If OleCreatePictureIndirect(Pic, IID_IDispatch, True, IPic) = S_OK Then
Set CreateBitmapPicture = IPic
End If
End Function
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/21/2008 8:26:14 AM
Posts: 3,
Visits: 6
|
|
| That worked great! Many thanks for the help
|
|
|
|