Screen Capture


Author
Message
tstokes
tstokes
Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)
Group: Forum Members
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

Yury Averkiev (s-code)
Yury Averkiev (s-code)
Supreme Being (213K reputation)Supreme Being (213K reputation)Supreme Being (213K reputation)Supreme Being (213K reputation)Supreme Being (213K reputation)Supreme Being (213K reputation)Supreme Being (213K reputation)Supreme Being (213K reputation)Supreme Being (213K reputation)
Group: Administrators
Posts: 1.9K, Visits: 3.6K
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.

http://www.s-code.com/App_Themes/Default/images/blue_line.gif
Regards,

Yury Averkiev, SmartCode

tstokes
tstokes
Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)
Group: Forum Members
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?
retinax
retinax
Supreme Being (245 reputation)Supreme Being (245 reputation)Supreme Being (245 reputation)Supreme Being (245 reputation)Supreme Being (245 reputation)Supreme Being (245 reputation)Supreme Being (245 reputation)Supreme Being (245 reputation)Supreme Being (245 reputation)
Group: Forum Members
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
tstokes
tstokes
Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)Supreme Being (595 reputation)
Group: Forum Members
Posts: 3, Visits: 6
That worked great!

Many thanks for the help

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Explore
Messages
Mentions
Search