IMAGEM DO FORMULARIO EM UM PICTURE BOX

JEAN.JEDSON 07/07/2005 19:16:24
#92805
dai pessoal...

estou necessitando colocar em um picturebox uma imagen de um form... mas teria que ser sem arquivo de imagem: ou seja, quero ter um snapshot do form sem usar imagem... é possível?

peço desculpas se não fui claro o suficiente.
USUARIO.EXCLUIDOS 07/07/2005 19:28:47
#92806
Tipo navegador do photoshop?
JEAN.JEDSON 07/07/2005 19:43:23
#92809
naun sei dizer...
o que preciso é ter uma imagem do meu form1 em um picturebox no form2 - mas sem usar arquivo de imagem...
JEAN.JEDSON 08/07/2005 16:18:06
#93016
alguém?
USUARIO.EXCLUIDOS 09/07/2005 04:23:06
#93071
Resposta escolhida
Este código não é meu, mas já o testei e funciona.
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_NONCLIENT = &H2&
Private Const PRF_CLIENT = &H4&
Private Const PRF_CHILDREN = &H10&
Private Const PRF_OWNED = &H20&
Private Sub cmdSnapShot_Click()
SnapShot Form1, Picture1
End Sub

Private Sub SnapShot(ByRef Source As Form, ByRef Dest As PictureBox)
Dim rv As Long
Dim sm As Integer
Dim ar As Boolean
Const BorderWidth = 60

On Error GoTo Exit_Sub
Me.ScaleMode = vbTwips

With Dest
.AutoRedraw = True
.ScaleMode = vbTwips
.Move .Left, .Top, Source.Width + BorderWidth, Source.Height + BorderWidth
End With

With Source
ar = .AutoRedraw
sm = .ScaleMode
.AutoRedraw = True
.ScaleMode = vbTwips

rv = SendMessage(.hwnd, WM_PAINT, .hDC, 0)
.Picture = .Image
Dest.PaintPicture .Picture, BorderWidth, .Height - .ScaleHeight - BorderWidth
rv = SendMessage(.hwnd, WM_PRINT, Dest.hDC, _
PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED Or PRF_NONCLIENT)
.AutoRedraw = ar
.ScaleMode = sm
End With

Exit_Sub:
If Err.Number Then MsgBox Err.Description, vbOKOnly
Dest.Picture = Dest.Image
Dest.Visible = True
End Sub


Substitua o Form1 pelo nome do form que quer colocar no picture1
JEAN.JEDSON 09/07/2005 12:02:20
#93084
obrigado miguel... estarei verificando na próxima semana o código que vc postou
MARIOZNETO 09/07/2005 12:41:22
#93095
Este código funciona legal...
JEAN.JEDSON 11/07/2005 11:27:35
#93317
obrigado miguel... aparentemente funcionou
Tópico encerrado , respostas não são mais permitidas