|
|
Postada em 14/04/2006 02:45 hs
Tenho um programa aqui com uma picturebox com labels e images dentro e eu queria fazer um zoom nesses objetos, como resolver isso?
Obrigado.
Filipe.
|
|
|
|
|
|
|
|
Postada em 14/04/2006 13:02 hs
Veja se isto resolve : Para testar desenhe 2 pictureboxes, 1 commandbutton e 1 textbox num form vazio e cole o seguinte código:
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal hStretchMode As Long) As Long
Const STRETCHMODE = vbPaletteModeNone
Private Sub Form_Load()
Picture1.BorderStyle = 0 Picture1.AutoRedraw = True Picture2.AutoRedraw = True Picture1.AutoSize = True ' Troque para a sua imagem Picture1.Picture = LoadPicture("C:imagem.gif") Command1.Caption = "Redimensiona" Text1.Text = "100" End Sub
Sub Redimensiona(picOrigem As PictureBox, picDestino As PictureBox, NWidth As Long, NHeight As Long)
Dim OrigWdt As Long Dim OrigHgt As Long OrigWdt = picOrigem.Width / Screen.TwipsPerPixelX OrigHgt = picOrigem.Height / Screen.TwipsPerPixelY SetStretchBltMode picDestino.hdc, STRETCHMODE StretchBlt picDestino.hdc, 0, 0, NWidth, NHeight, picOrigem.hdc, 0, 0, OrigWdt, OrigHgt, vbSrcCopy picDestino.Refresh
End Sub
Private Sub Command1_Click()
Dim NX As Long Dim NY As Long Dim P As Integer Dim PW As Long Dim PH As Long ' Pega o fator do zoom (em porcentagem) P = Val(Text1) If P < 1 Then Exit Sub ' Converte os valores de himetric pra pixel PW = ScaleX(Picture1.Picture.Width, vbHimetric, vbPixels) PH = ScaleX(Picture1.Picture.Height, vbHimetric, vbPixels)
' Calcula o tamanho NX = (PW * P) / 100 NY = (PH * P) / 100 ' Zera a imagem destino Set Picture2.Picture = LoadPicture("") ' Copia Redimensiona Picture1, Picture2, NX, NY End Sub
"O pior inimigo que você poderá encontrar será sempre você mesmo."
|
|
|
|
|
|
Postada em 14/04/2006 17:28 hs
Você me passou o código para fazer zoom em imagens, mas o q eu queria msm é fazer com objetos, entendeu? Se vc puder me ajudar ficarei muito grato, mais do que já estou.
Obrigado. Filipe
|
|
|
|
|
|
Postada em 14/04/2006 18:33 hs
Deixa ver se entendi, você quer aumentar um objeto ou seja redimencionar o tamanho dele ou você quer que digamos ao clicar com o mouse em uma parte dele somente esta parte seje aumentada.
|
|
|
|
|
|
Postada em 14/04/2006 18:36 hs
|
|
|
|
Geronimo
|
JOINVILLE SC - BRASIL
|
|
ENUNCIADA !
|
|
|
Postada em 14/04/2006 18:41 hs
Tem mais esta dica : Num form vazio desenhe 2 pictureboxes, no Picture1 insira uma imagem de tamanho razoável (pelo menos 300x200 pixels) e cole o código abaixo no form.
' -------------------------------------------------------------- ' Lente de Aumento ' ' Baseado no código de Lukasz Bula ' Adaptado e Traduzido por Walter Staeblein ' ' http://www.codex.com.br ' ' -------------------------------------------------------------- ' Use as teclas de 1 a 5 para aumentar e diminuir a magnificação ' Use Insert para ligar a lente de aumento e Delete para desligar ' --------------------------------------------------------------
Dim Magnif As Single Dim Flag As Boolean
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode Case 49 To 53 Magnif = KeyCode - 48 UpdateCaption
Case vbKeyInsert OnOFF True Case vbKeyDelete OnOFF False End Select End Sub
Private Sub Form_Load()
Me.KeyPreview = True Picture1.Left = 0 Picture1.Top = 0 Picture2.Height = 1500 Picture2.Width = 1500 Picture1.ScaleMode = 1 Picture2.ScaleMode = 1 Picture1.Visible = True Picture2.Enabled = False Picture2.Visible = False Magnif = 3 UpdateCaption End Sub
Sub OnOFF(F As Boolean)
Flag = F If Flag Then Picture2.Visible = True Picture2.Left = 10 Picture2.Top = 10 Picture2.PaintPicture Picture1, 0, 0, Picture2.Width * Magnif, Picture2.Height * Magnif, Picture2.Left + 300, Picture2.Top + 300, Picture2.Width, Picture2.Height UpdateCaption Else Picture2.Visible = False UpdateCaption End If
End Sub
Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then If Flag = True Then If X < Picture1.Width - Picture2.Width 2 And Y < Picture1.Height - Picture2.Height 2 Then If X > Picture2.Width 2 And Y > Picture2.Height 2 Then Picture2.Move (X - Picture2.Width 2), (Y - Picture2.Height 2) Picture2.PaintPicture Picture1, 0, 0, Picture2.Width * Magnif, Picture2.Height * Magnif, Picture2.Left + 300, Picture2.Top + 300, Picture2.Width, Picture2.Height End If End If End If End If
End Sub
Sub UpdateCaption()
If Flag Then Xtra = "L" Else Xtra = "Desl" Me.Caption = "Lente de Aumento " & Xtra & "igada (" & Magnif & "x)"
End Sub
Ou esta outra :
"O pior inimigo que você poderá encontrar será sempre você mesmo."
|
|
|
|
|