SET OBJETO

USUARIO.EXCLUIDOS 24/06/2004 21:07:28
#31156
Pessoal estou desenvolvendo uma ocx onde o objetivo é colocar essa ocx num form e depois escolher uma opção e ao clicar nesta opção deveria carregar uma imagem no form porém está me dando um erro "Object variableor Withblock variable not set" e eu não consigo setar de tal forma que a ocx funcione se alguém puder ajudar sou muito grato.

Wagner


aí vai o código.

[c]
[Private WithEvents mparent As Form
Private Mybmpstyle As Bmpstyleconst
Private Const XBmpStyle = 0

Public Enum Bmpstyleconst
[Imagem0] = 0
[Imagem1] = 1
[Imagem2] = 2
[Imagem3] = 3
[Imagem4] = 4
End Enum

Public Property Get BmpStyle() As Bmpstyleconst
BmpStyle = Mybmpstyle
End Property
Public Property Let BmpStyle(ByVal vData As Bmpstyleconst)

Mybmpstyle = vData
PropertyChanged "BmpStyle"

If BmpStyle = 1 Then
mparent.Picture = LoadResPicture(101, 0)
End If

End Property
Private Sub UserControl_InitProperties()
BmpStyle = XBmpStyle
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("BmpStyle", Mybmpstyle, BmpStyle)
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
BmpStyle = PropBag.ReadProperty("BmpStyle", BmpStyle)

Dim iCnt As Integer
Dim lIdx As Long
If UserControl.Ambient.UserMode Then
Set mparent = UserControl.Parent
For lIdx = 0 To mparent.Controls.Count - 1
iCnt = iCnt + 1
Next
End If
End Sub

Private Sub UserControl_Resize()

With UserControl
.Width = 495
.Height = 495

End With
End Sub]
USUARIO.EXCLUIDOS 25/06/2004 11:19:12
#31221
Resposta escolhida
Você fez isto

Private WithEvents mparent As Form

E o VB não pode gerar eventos de form em RUNTIME

Então aconselho a fazer assim

private Tparent as Form
Private WithEvents mparent As Form

Em runtime tu seta o TParent e em execução o mparent ou tira o withevents se não precisar.
Tópico encerrado , respostas não são mais permitidas