USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Zoom no VB
Filipe
não registrado
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.
     
Geronimo
Pontos: 2843
JOINVILLE
SC - BRASIL
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."
     
Filipe
não registrado
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
     
Geronimo
não registrado
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.
     
Geronimo
não registrado
Postada em 14/04/2006 18:36 hs   
Acho que o que vc precisa é de um splitter. Se for abaixo está um exemplo, para testar crie um projeto com um form vazio e 3 pictureboxes, picture1 
a esquerda, picture2 no meio e picture3 a direita, eles devem estar posicionados corretamente no form. Feito isso cole o código abaixo que deve funcionar.


Private Sub Form_Load()

    Picture2.Width = 120
    Picture2.DragMode = 1
    Picture2.MousePointer = 9
    
    Picture1.BorderStyle = 0
    Picture3.BorderStyle = 0
    
End Sub

Private Sub Form_Resize()

    Picture2.Height = Me.ScaleHeight
    Picture1.Height = Me.ScaleHeight
    Picture3.Height = Me.ScaleHeight
    Picture3.Width = Me.ScaleWidth - Picture1.Width - 30
    
End Sub

Private Sub Picture3_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    
    If X > 0 Then
        Picture2.Left = Picture2.Left + X
        Picture1.Width = Picture1.Width + X
        Picture3.Left = Picture2.Left + Picture2.Width
        Picture3.Width = Abs(Picture3.Left - Me.ScaleWidth)
    End If
    
End Sub

Private Sub Picture1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    
    Picture2.Left = X
    Picture1.Width = X
    Picture3.Left = X + Picture2.Width
    Picture3.Width = Abs(Picture3.Left - Me.ScaleWidth)

End Sub


Vc pode trocar picture1 e picture3 pelos seus controles ou até 
colocar mais de um controle dentro de picture1 e picture3 e reposiciona-los 
no evento Resize

     
Geronimo
Pontos: 2843
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."
   
Página(s): 1/2      PRÓXIMA »


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2026   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página