Visual Basic 6 - Editor de niveis 2D

Cambalinho

Power Member
eu estou a criar 1 objecto em visual basic 6: Editor de niveis 2D.
mas preciso de algumas dicas/ideas sobre o deslocamento vertical e horizontal.
neste momento eu tenho o UC com as 2 barras de deslocamento(para deslocar a picturebox) e 1 picturebox(para mostrar 1 imagem).
obrigado
 
Antes de poder dizer seja lá o que for:

Visual Basic 2008 Express

Só depois, estás em condições de iniciar algo interessante como um editor de tiled maps.
Não existe absolutamente razão nenhuma para usares o VB6 ao invés de sentir o poder da framework.
VB6 torna-se brincadeira para crianças ao lado desse colosso.

Para além disso,
Código:
dicas/ideas sobre o deslocamento vertical e horizontal
, há bastantes pormenores a ter em conta, terás de ser mais específico na tua dificuldade.
 
Última edição:
Antes de poder dizer seja lá o que for:

Visual Basic 2008 Express

Só depois, estás em condições de iniciar algo interessante como um editor de tiled maps.
Não existe absolutamente razão nenhuma para usares o VB6 ao invés de sentir o poder da framework.
VB6 torna-se brincadeira para crianças ao lado desse colosso.

Para além disso,
Código:
dicas/ideas sobre o deslocamento vertical e horizontal
, há bastantes pormenores a ter em conta, terás de ser mais específico na tua dificuldade.
desculpa, mas neste momento ainda só trabalho com VB6. honestamente eu consigo trabalhar com tiles e mt mais com ajuda das funções API. quero que veza o meu 2D Sprite(mas tambem vou tentar meter neste forum).
neste momento tenho 1 problema no codigo:
Código:
Private Sub ScrollingHorizontal_Change()
    Dim i As Long
    Dim value As Long
    Debug.Print ScrollingHorizontal.value; value
    For i = 0 To UserControl.Controls.Count - 1
        If UserControl.Controls(i).Name = "Timer1" Or UserControl.Controls(i).Name = "Picture1" Or UserControl.Controls(i).Name = "ScrollingHorizontal" Or UserControl.Controls(i).Name = "ScrollingVertical" Then
        Else
            If value > ScrollingHorizontal.value Then
                UserControl.Controls(i).Left = UserControl.Controls(i).Left + 1
            ElseIf value < ScrollingHorizontal.value Then
                UserControl.Controls(i).Left = UserControl.Controls(i).Left - 1
            End If
        End If
    Next i
    value = ScrollingHorizontal.value
End Sub
este codigo é para fazer o rodar, horizontalmente, todos os objectos no meu UC. mas o problema, estranho, é que clico no butão esquerdo ou direito, desta barra de deslocamento, os objectos movem-se para o mesmo lado.
o meu objectivo é: quando clico no butão esquerdo, desta barra de deslocamento, os objectos se movam para a direita e virce-versa.
eu n percebo o meu erro.
obrigado
 
Última edição:
Assim de raspão, exprimenta trocar os "ElseIf" para "Else" simples, sem a segunda condição.

Isto porque se o "value" for = ao "ScrollingHorizontal.value" abre-se um portal-paradoxo e o IF é ignorado :007:
Ou isso, ou "<=".

Por alguma razão ou por a igualdade que tens no fim, isso pode causar o deslocamento para um dos lados apenas.
 
Última edição:
Assim de raspão, exprimenta trocar os "ElseIf" para "Else" simples, sem a segunda condição.

Isto porque se o "value" for = ao "ScrollingHorizontal.value" abre-se um portal-paradoxo e o IF é ignorado :007:
Ou isso, ou "<=".

Por alguma razão ou por a igualdade que tens no fim, isso pode causar o deslocamento para um dos lados apenas.
o problema foi outro. eu ja resolvi o problema a 100%: essa variavel troquei para HorizontalValue e declarei-a na secção de declaração(declaration section). e quando troco a propriedade Max do deslocamento meto a variavel a 0.
Código:
Private Sub ScrollingHorizontal_Change()
    Dim i As Long
    For i = 0 To UserControl.Controls.Count - 1
        If UserControl.Controls(i).Name = "Timer1" Or UserControl.Controls(i).Name = "Picture1" Or UserControl.Controls(i).Name = "ScrollingHorizontal" Or UserControl.Controls(i).Name = "ScrollingVertical" Then
        Else
            If HorizontalValue > ScrollingHorizontal.value Then
                UserControl.Controls(i).Left = UserControl.Controls(i).Left + (Abs(ScrollingHorizontal.value - HorizontalValue))
            ElseIf HorizontalValue < ScrollingHorizontal.value Then
                UserControl.Controls(i).Left = UserControl.Controls(i).Left - (Abs(ScrollingHorizontal.value - HorizontalValue))
            End If
        End If
    Next i
    HorizontalValue = ScrollingHorizontal.value
End Sub
mas agora tenho 1 grande problema para continuar a fazer o meu controlo.
eu preciso que as barras de deslocamento fiquem activas em momento de projecto(quando estou a utilizar o meu controlo). isto porque o meu controlo pode conter controlos no interior.
tem alguma dica?
obrigado
PS.: Eu não recebi a notifição da sua resposta :(
 
Infelizmente a dica que tenho para ti é: VB2008

Só aí é que me lembro de ver os usercontrols "acessíveis" em dev mode.

Mas porque precisas de os ver? Nunca em ocasião alguma deverá o exterior ter acesso aos objetos dentro da classe. É um dos principais pontos da característica de uma classe: encapsulamento.

Deverás estudar maneiras de manipular seja o que for que precises de manipular através de métodos e propriedades, a unica coisa que deverá estar exposta numa classe.
 
Infelizmente a dica que tenho para ti é: VB2008

Só aí é que me lembro de ver os usercontrols "acessíveis" em dev mode.

Mas porque precisas de os ver? Nunca em ocasião alguma deverá o exterior ter acesso aos objetos dentro da classe. É um dos principais pontos da característica de uma classe: encapsulamento.

Deverás estudar maneiras de manipular seja o que for que precises de manipular através de métodos e propriedades, a unica coisa que deverá estar exposta numa classe.
eu nunca, e n tenho, trabalhei com o VB2008. mas por enquanto continu com o VB6, apesar de ja ter pensado em mudar de versão;).
eu penso que ainda n percebeu. eu preciso de fazer o deslocamento para meter os objectos no local exacto, mas estou a ver que a unica forma é meter e utilizar as propriedades de deslocamento para fazer isso. eu ja tinha pensado em meter estas propriedades, por isso até vai ficar melhor.
por agora vou(só venho daqui a 2 semanas por questões de trabalho).
quaquer dica é sempre bem vinda.
outra coisa, ja viu o meu 2D Sprite(eu estou a trabalhar numa versão mt + interessante)?
o que pensa? bem o unico metodo que faz "confusão" é o destroy, n destroy o objecto só simula :(.
peço desculpa pelo incomodo e obrigado.
PS: Já recebo notificações.
 
Antes de mais nada, o 55 no meu nick não é idade. :001:

Já espreitei o forum onde fala do controlo, mas não tenho VB6 instalado para o poder espreitar.
Também tenho um projecto parecido, mas está mais focado numa linguagem de programação própria para programar NPC.
Os mapas são lidos de ficheiros de texto com identificadores do tipo de terreno no tile específico e tem um sistema para implementar e posicionar os NPC e toda a sua rotina, rotina esta escrita por a dita linguagem propria. Chamei-lhe motor TileX e ScriptX, mas é irrelevante porque nunca sairam do meu disco rígido e não vais encontrar qualquer informação acerca deles.
Por acaso, está em VB6. Abandonei há alguns anos. Se quiseres as sources para tirares umas ideias, não tenho qualquer problema em dar :001: .
Hoje mantenho outros projectos.
 
Última edição:
"Por acaso, está em VB6. Abandonei há alguns anos. Se quiseres as sources para tirares umas ideias, não tenho qualquer problema em dar :001: ." manda vir ;)
mas podes ver ocodigo facilmente. quando selecionas um modulo ou 1 formulario, clicas no butão direito do rato e abres com o bloco de notas. vais encontrar mt codigo interessante e original. é pena que de versão para versão posso mudar propriedades/metodos/eventos mas o objectivo é ser facil de utilização e rapido para construir jogos. posso te dizer que os eventos Move, NotMove, MouseStop e colision são originais. o codigo para strips(são imagens normais, mas estas imagens podem contem subimagens e a soma delas dá 1 animação) tb é original.
o meu control tem mt codigo interessante e original.
obrigado e fica bem(eu voltarei, porque quero acabar/continuar o meu editor de niveis;))
obrigado
 
agora tenho 1 pequeno problema :(
eu fiz 2 propriedades para alterar os valores de deslocamento. estas propriedades funcionam bem. mas se a barra de deslocamento horizontal estiver invisivel o valor maximo nao fica correcto. eu vou meter o meu projecto para testar e ver se podem ajudar-me a resolver o problema. obrigado
Código:
Option Explicit
Enum ScrollingBars
    None = 0
    Vertical = 1
    Horizontal = 2
    Both = 3
End Enum
Dim ScrlBars As ScrollingBars
Dim strFileName As String
Dim lngBackColor As Long
Dim VerticalValue As Long
Dim HorizontalValue As Long
Public Property Get ViewWidth() As Long
    ViewWidth = picView.Width
End Property
Public Property Let ViewWidth(ByVal vNewValue As Long)
    picView.Width = vNewValue
    Call ScrollingValues
    PropertyChanged "ViewWidth"
End Property
Public Property Get ViewWidthPosition() As Long
    ViewWidthPosition = ScrollingHorizontal.Value
End Property
Public Property Let ViewWidthPosition(ByVal vNewValue As Long)
    If vNewValue > ScrollingHorizontal.Max Then vNewValue = ScrollingHorizontal.Max
    If vNewValue < 0 Then vNewValue = 0
    ScrollingHorizontal.Value = vNewValue
    PropertyChanged "ViewWidthPosition"
End Property
Public Property Get ViewHeigth() As Long
    ViewHeigth = picView.Height
End Property
Public Property Let ViewHeigth(ByVal vNewValue As Long)
    picView.Height = vNewValue
    Call ScrollingValues
    PropertyChanged "ViewHeight"
End Property
Public Property Get ViewHeigthPosition() As Long
    ViewHeigthPosition = ScrollingVertical.Value
End Property
Public Property Let ViewHeigthPosition(ByVal vNewValue As Long)
    If vNewValue > ScrollingVertical.Max Then vNewValue = ScrollingVertical.Max
    If vNewValue < 0 Then vNewValue = 0
    ScrollingVertical.Value = vNewValue
    PropertyChanged "ViewHeightPosition"
End Property
Public Property Get ShowScrollingBars() As ScrollingBars
   ShowScrollingBars = ScrlBars
End Property
Public Property Let ShowScrollingBars(ByVal vNewValue As ScrollingBars)
    ScrlBars = vNewValue
    If vNewValue = None Then
        ScrollingHorizontal.Visible = False
        ScrollingVertical.Visible = False
        Picture1.Visible = False
    ElseIf vNewValue = Horizontal Then
        ScrollingHorizontal.Visible = True
        ScrollingVertical.Visible = False
        Picture1.Visible = False
    ElseIf vNewValue = Vertical Then
        ScrollingHorizontal.Visible = False
        ScrollingVertical.Visible = True
        Picture1.Visible = False
    ElseIf vNewValue = Both Then
        Picture1.Visible = True
        ScrollingHorizontal.Visible = True
        ScrollingVertical.Visible = True
    End If
    Call UserControl_Resize
    PropertyChanged "ShowScrollingBars"
End Property
Private Sub picView_Resize()
    ViewWidth = picView.Width
    ViewHeigth = picView.Height
End Sub
Private Sub ScrollingHorizontal_Change()
    Dim i As Long
    If HorizontalValue > ScrollingHorizontal.Value Then
        picView.Top = picView.Top + (Abs(ScrollingHorizontal.Value - HorizontalValue))
        
    ElseIf HorizontalValue < ScrollingHorizontal.Value Then
        picView.Top = picView.Top - (Abs(ScrollingHorizontal.Value - HorizontalValue))
    End If
    For i = 0 To UserControl.ContainedControls.Count - 1
        If HorizontalValue > ScrollingHorizontal.Value Then
            UserControl.ContainedControls(i).Left = UserControl.ContainedControls(i).Left + (Abs(ScrollingHorizontal.Value - HorizontalValue)) * Screen.TwipsPerPixelX
        ElseIf HorizontalValue < ScrollingHorizontal.Value Then
            UserControl.ContainedControls(i).Left = UserControl.ContainedControls(i).Left - (Abs(ScrollingHorizontal.Value - HorizontalValue)) * Screen.TwipsPerPixelX
        End If
    Next i
    HorizontalValue = ScrollingHorizontal.Value
End Sub
Private Sub ScrollingVertical_Change()
    Dim i As Long
    If VerticalValue > ScrollingVertical.Value Then
        picView.Top = picView.Top + (Abs(ScrollingVertical.Value - VerticalValue))
    ElseIf VerticalValue < ScrollingVertical.Value Then
        picView.Top = picView.Top - (Abs(ScrollingVertical.Value - VerticalValue))
    End If
    For i = 0 To UserControl.ContainedControls.Count - 1
        If VerticalValue > ScrollingVertical.Value Then
            UserControl.ContainedControls(i).Top = UserControl.ContainedControls(i).Top + (Abs(ScrollingVertical.Value - VerticalValue)) * Screen.TwipsPerPixelX
        ElseIf VerticalValue < ScrollingVertical.Value Then
            UserControl.ContainedControls(i).Top = UserControl.ContainedControls(i).Top - (Abs(ScrollingVertical.Value - VerticalValue)) * Screen.TwipsPerPixelX
        End If
    Next i
    VerticalValue = ScrollingVertical.Value
End Sub
Private Sub Timer1_Timer()
    Picture1.ZOrder 0
    ScrollingHorizontal.ZOrder 0
    ScrollingVertical.ZOrder 0
End Sub
Private Sub UserControl_Initialize()
    lngBackColor = &H8000000F
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    ViewWidth = PropBag.ReadProperty("ViewWidth", 0)
    ViewWidthPosition = PropBag.ReadProperty("ViewWidthPosition", 0)
    ViewHeigth = PropBag.ReadProperty("ViewHeigth", 0)
    ViewHeigthPosition = PropBag.ReadProperty("ViewHeigthPosition", 0)
    ShowScrollingBars = PropBag.ReadProperty("ShowScrollingBars", 0)
    FileName = PropBag.ReadProperty("FileName", "")
    BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
    picView.Picture = PropBag.ReadProperty("Image", Nothing)
End Sub
Private Sub UserControl_Resize()
    ScrollingHorizontal.Top = UserControl.Height / Screen.TwipsPerPixelY - ScrollingHorizontal.Height - 4
    ScrollingHorizontal.Width = UserControl.Width / Screen.TwipsPerPixelX - 4
    ScrollingVertical.Left = UserControl.Width / Screen.TwipsPerPixelX - ScrollingHorizontal.Height - 4
    ScrollingVertical.Height = UserControl.Height / Screen.TwipsPerPixelY - 4
    If ScrlBars = Both Then
        ScrollingVertical.Height = ScrollingVertical.Height - 16
        ScrollingHorizontal.Width = ScrollingHorizontal.Width - 16
    End If
    Picture1.Top = UserControl.Height / Screen.TwipsPerPixelY - Picture1.Height - 4
    Picture1.Left = UserControl.Width / Screen.TwipsPerPixelX - Picture1.Width - 4
    Call ScrollingValues
End Sub
Private Sub UserControl_Show()
    Picture1.ZOrder 0
    ScrollingHorizontal.ZOrder 0
    ScrollingVertical.ZOrder 0
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    PropBag.WriteProperty "ViewWidth", ViewWidth, 0
    PropBag.WriteProperty "ViewWidthPosition", ViewWidthPosition, 0
    PropBag.WriteProperty "ViewHeigth", ViewWidth, 0
    PropBag.WriteProperty "ViewHeigthPosition", ViewHeigthPosition, 0
    PropBag.WriteProperty "ShowScrollingBars", ShowScrollingBars, 0
    PropBag.WriteProperty "FileName", FileName, ""
    PropBag.WriteProperty "BackColor", BackColor, &H8000000F
    PropBag.WriteProperty "Image", Image, Null
    PropBag.WriteProperty "Image", picView.Image, Nothing
End Sub
Public Property Get FileName() As String
    FileName = strFileName
End Property
Public Property Let FileName(ByVal vNewValue As String)
    strFileName = vNewValue
    picView.Picture = LoadPicture(strFileName)
    picView.AutoSize = True
    picView.AutoSize = False
    Call ScrollingValues
    HorizontalValue = ScrollingHorizontal.Value
    VerticalValue = ScrollingVertical.Value
    PropertyChanged "FileName"
End Property
Public Property Get BackColor() As OLE_COLOR
    BackColor = lngBackColor
End Property
Public Property Let BackColor(ByVal vNewValue As OLE_COLOR)
    lngBackColor = vNewValue
    picView.BackColor = lngBackColor
    Call ChangeBackcolor(picView, lngBackColor)
    PropertyChanged "BackColor"
End Property
Private Sub ScrollingValues()
    ScrollingVertical.Max = picView.Height - UserControl.ScaleHeight
    If ScrlBars = Vertical Or ScrlBars = Both Then ScrollingVertical.Max = ScrollingVertical.Max + 17
    ScrollingHorizontal.Max = picView.Width - UserControl.ScaleWidth
    If ScrlBars = Horizontal Or ScrlBars = Both Then ScrollingHorizontal.Max = ScrollingHorizontal.Max + 17
    If picView.ScaleHeight <= UserControl.ScaleHeight Then ScrollingVertical.Max = 0
    If picView.ScaleWidth <= UserControl.ScaleWidth Then ScrollingHorizontal.Max = 0
End Sub
Public Property Let Image(ByVal img As Picture)
    Set picView.Picture = img
    PropertyChanged "Image"
End Property
Public Property Get Image() As Picture
    Set Image = picView.Image
End Property
 
Última edição:
problema resolvido...
Código:
Option Explicit
Enum ScrollingBars
    None = 0
    Vertical = 1
    Horizontal = 2
    Both = 3
End Enum
Dim ScrlBars As ScrollingBars
Dim strFileName As String
Dim lngBackColor As Long
Dim VerticalValue As Long
Dim HorizontalValue As Long
Public Property Get ViewWidth() As Long
    ViewWidth = picView.Width
End Property
Public Property Let ViewWidth(ByVal vNewValue As Long)
    picView.Width = vNewValue
    Call ScrollingValues
    PropertyChanged "ViewWidth"
End Property
Public Property Get ViewWidthPosition() As Long
    ViewWidthPosition = ScrollingHorizontal.Value
End Property
Public Property Let ViewWidthPosition(ByVal vNewValue As Long)
    If vNewValue > ScrollingHorizontal.Max Then vNewValue = ScrollingHorizontal.Max
    If vNewValue < 0 Then vNewValue = 0
    ScrollingHorizontal.Value = vNewValue
    PropertyChanged "ViewWidthPosition"
End Property
Public Property Get ViewHeigth() As Long
    ViewHeigth = picView.Height
End Property
Public Property Let ViewHeigth(ByVal vNewValue As Long)
    picView.Height = vNewValue
    Call ScrollingValues
    PropertyChanged "ViewHeight"
End Property
Public Property Get ViewHeigthPosition() As Long
    ViewHeigthPosition = ScrollingVertical.Value
End Property
Public Property Let ViewHeigthPosition(ByVal vNewValue As Long)
    If vNewValue > ScrollingVertical.Max Then vNewValue = ScrollingVertical.Max
    If vNewValue < 0 Then vNewValue = 0
    ScrollingVertical.Value = vNewValue
    PropertyChanged "ViewHeightPosition"
End Property
Public Property Get ShowScrollingBars() As ScrollingBars
   ShowScrollingBars = ScrlBars
End Property
Public Property Let ShowScrollingBars(ByVal vNewValue As ScrollingBars)
    ScrlBars = vNewValue
    If vNewValue = None Then
        ScrollingHorizontal.Visible = False
        ScrollingVertical.Visible = False
        Picture1.Visible = False
    ElseIf vNewValue = Horizontal Then
        ScrollingHorizontal.Visible = True
        ScrollingVertical.Visible = False
        Picture1.Visible = False
    ElseIf vNewValue = Vertical Then
        ScrollingHorizontal.Visible = False
        ScrollingVertical.Visible = True
        Picture1.Visible = False
    ElseIf vNewValue = Both Then
        Picture1.Visible = True
        ScrollingHorizontal.Visible = True
        ScrollingVertical.Visible = True
    End If
    Call UserControl_Resize
    PropertyChanged "ShowScrollingBars"
End Property
Private Sub picView_Resize()
    ViewWidth = picView.Width
    ViewHeigth = picView.Height
End Sub
Private Sub ScrollingHorizontal_Change()
    Dim i As Long
    If HorizontalValue > ScrollingHorizontal.Value Then
        picView.Left = picView.Left + (Abs(ScrollingHorizontal.Value - HorizontalValue))
    ElseIf HorizontalValue < ScrollingHorizontal.Value Then
        picView.Left = picView.Left - (Abs(ScrollingHorizontal.Value - HorizontalValue))
    End If
    For i = 0 To UserControl.ContainedControls.Count - 1
        If HorizontalValue > ScrollingHorizontal.Value Then
            UserControl.ContainedControls(i).Left = UserControl.ContainedControls(i).Left + (Abs(ScrollingHorizontal.Value - HorizontalValue)) * Screen.TwipsPerPixelX
        ElseIf HorizontalValue < ScrollingHorizontal.Value Then
            UserControl.ContainedControls(i).Left = UserControl.ContainedControls(i).Left - (Abs(ScrollingHorizontal.Value - HorizontalValue)) * Screen.TwipsPerPixelX
        End If
    Next i
    HorizontalValue = ScrollingHorizontal.Value
End Sub
Private Sub ScrollingVertical_Change()
    Dim i As Long
    If VerticalValue > ScrollingVertical.Value Then
        picView.Top = picView.Top + (Abs(ScrollingVertical.Value - VerticalValue))
    ElseIf VerticalValue < ScrollingVertical.Value Then
        picView.Top = picView.Top - (Abs(ScrollingVertical.Value - VerticalValue))
    End If
    For i = 0 To UserControl.ContainedControls.Count - 1
        If VerticalValue > ScrollingVertical.Value Then
            UserControl.ContainedControls(i).Top = UserControl.ContainedControls(i).Top + (Abs(ScrollingVertical.Value - VerticalValue)) * Screen.TwipsPerPixelX
        ElseIf VerticalValue < ScrollingVertical.Value Then
            UserControl.ContainedControls(i).Top = UserControl.ContainedControls(i).Top - (Abs(ScrollingVertical.Value - VerticalValue)) * Screen.TwipsPerPixelX
        End If
    Next i
    VerticalValue = ScrollingVertical.Value
End Sub
Private Sub Timer1_Timer()
    Picture1.ZOrder 0
    ScrollingHorizontal.ZOrder 0
    ScrollingVertical.ZOrder 0
End Sub
Private Sub UserControl_Initialize()
    lngBackColor = &H8000000F
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    ViewWidth = PropBag.ReadProperty("ViewWidth", 0)
    ViewWidthPosition = PropBag.ReadProperty("ViewWidthPosition", 0)
    ViewHeigth = PropBag.ReadProperty("ViewHeigth", 0)
    ViewHeigthPosition = PropBag.ReadProperty("ViewHeigthPosition", 0)
    ShowScrollingBars = PropBag.ReadProperty("ShowScrollingBars", 0)
    FileName = PropBag.ReadProperty("FileName", "")
    BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
    picView.Picture = PropBag.ReadProperty("Image", Nothing)
End Sub
Private Sub UserControl_Resize()
    ScrollingHorizontal.Top = UserControl.Height / Screen.TwipsPerPixelY - ScrollingHorizontal.Height - 4
    ScrollingHorizontal.Width = UserControl.Width / Screen.TwipsPerPixelX - 4
    ScrollingVertical.Left = UserControl.Width / Screen.TwipsPerPixelX - ScrollingHorizontal.Height - 4
    ScrollingVertical.Height = UserControl.Height / Screen.TwipsPerPixelY - 4
    If ScrlBars = Both Then
        ScrollingVertical.Height = ScrollingVertical.Height - 16
        ScrollingHorizontal.Width = ScrollingHorizontal.Width - 16
    End If
    Picture1.Top = UserControl.Height / Screen.TwipsPerPixelY - Picture1.Height - 4
    Picture1.Left = UserControl.Width / Screen.TwipsPerPixelX - Picture1.Width - 4
    Call ScrollingValues
End Sub
Private Sub UserControl_Show()
    Picture1.ZOrder 0
    ScrollingHorizontal.ZOrder 0
    ScrollingVertical.ZOrder 0
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    PropBag.WriteProperty "ViewWidth", ViewWidth, 0
    PropBag.WriteProperty "ViewWidthPosition", ViewWidthPosition, 0
    PropBag.WriteProperty "ViewHeigth", ViewWidth, 0
    PropBag.WriteProperty "ViewHeigthPosition", ViewHeigthPosition, 0
    PropBag.WriteProperty "ShowScrollingBars", ShowScrollingBars, 0
    PropBag.WriteProperty "FileName", FileName, ""
    PropBag.WriteProperty "BackColor", BackColor, &H8000000F
    PropBag.WriteProperty "Image", Image, Null
    PropBag.WriteProperty "Image", picView.Image, Nothing
End Sub
Public Property Get FileName() As String
    FileName = strFileName
End Property
Public Property Let FileName(ByVal vNewValue As String)
    strFileName = vNewValue
    picView.Picture = LoadPicture(strFileName)
    picView.AutoSize = True
    picView.AutoSize = False
    Call ScrollingValues
    HorizontalValue = ScrollingHorizontal.Value
    VerticalValue = ScrollingVertical.Value
    PropertyChanged "FileName"
End Property
Public Property Get BackColor() As OLE_COLOR
    BackColor = lngBackColor
End Property
Public Property Let BackColor(ByVal vNewValue As OLE_COLOR)
    lngBackColor = vNewValue
    picView.BackColor = lngBackColor
    Call ChangeBackcolor(picView, lngBackColor)
    PropertyChanged "BackColor"
End Property
Private Sub ScrollingValues()
    ScrollingVertical.Max = picView.ScaleHeight - UserControl.ScaleHeight
    ScrollingHorizontal.Max = picView.ScaleWidth - UserControl.ScaleWidth
    If ScrlBars = Both Then
        ScrollingHorizontal.Max = ScrollingHorizontal.Max + 17
        ScrollingVertical.Max = ScrollingVertical.Max + 17
    End If
    If picView.ScaleHeight <= UserControl.ScaleHeight Then ScrollingVertical.Max = 0
    If picView.ScaleWidth <= UserControl.ScaleWidth Then ScrollingHorizontal.Max = 0
End Sub
Public Property Let Image(ByVal img As Picture)
    Set picView.Picture = img
    PropertyChanged "Image"
End Property
Public Property Get Image() As Picture
    Set Image = picView.Image
End Property
obrigado
 
eu consigo meter o nome de 1 objecto numa propriedade do tipo string. mas posso usar esse nome(em string) para alterar as propriedades desse objecto?
obrigado
 
isto já n é a 1º vez que me acontece :(.
quando uso 1 timer(neste caso com intervalo mt curto) em construção de 1 objecto, eu noto 1 problema quando utilizo este objecto em projecto. ou seja, por exemplo, quando estou a escrever o nome de 1 objecto e insiro o ".", a pequena lista aparece, mas em menos de 1 segundo desaparece. eu preciso do timer e com este intervalo, mas cm posso evitar este problema?
obrigado
 
Back
Topo