|
-
April 22nd, 2009, 02:10 PM
#16
Re: Destroying objects that was builded in project-mode
thanks my friend
i will see it in weekend. thanks
-
April 25th, 2009, 02:01 AM
#17
Re: Destroying objects that was builded in project-mode
i know programming but sometimes(in these case in VB6), when i program, some strange things appens
like some code is working now, then(without change) isn't....
honestly i don't understand
because now i have some problems in my Sprite control
can you spend some time with me for resolve them?
(if you can use messenger/msn greate, if not that's ok)
thanks
-
April 25th, 2009, 12:00 PM
#18
Re: Destroying objects that was builded in project-mode
You can always go back to your old code, when it was working right
-
April 25th, 2009, 12:08 PM
#19
Re: Destroying objects that was builded in project-mode
 Originally Posted by dglienna
You can always go back to your old code, when it was working right
yeah, thanks for the advice.
i need ask you something...
in UC, i need activate a API functions(like message windows(winproc()), but i don't know what event must use. because the initializate event is only for change the variables(i can't use it for more)... i could use the show event, but the show event is call it when it's created(with or without image/backcolor)?
i know i thing, the terminate event is called when the UC is created... why? can i ignore it(when is created)?
thanks
-
April 25th, 2009, 04:46 PM
#20
Re: Destroying objects that was builded in project-mode
I don't understand the question
-
April 25th, 2009, 04:55 PM
#21
Re: Destroying objects that was builded in project-mode
 Originally Posted by dglienna
I don't understand the question
i'm sorry i will say in other words...
when the UC is created, why the Finalizate event is called? these event can be ignored when the UC is created?
anotherthing when the UC is created the Initializated event is called, but i only can change the variables values.... when the UC is created(Visible can or not be true, doesn't mine), the Show event is always called?
thanks
-
September 21st, 2009, 05:07 PM
#22
Re: Destroying objects that was builded in project-mode
ok.. now i can continue with our conversation
i need build an Destroy method(i don't care if the object was created in Load function or in project-mode). can you advice me?
or give me informations?
thanks
-
September 22nd, 2009, 11:06 AM
#23
Re: Destroying objects that was builded in project-mode
Objects which are created at design-time cannot be destroyed at runtime. However, if you create an array, then additional elements can be loaded and unloaded at runtime. Still, the one you created at design-time must remain.
In the case of your sprites, one could be placed on the form at design-time, with an Index of zero. The other sprites would then be loaded/unloaded at runtime.
<EDIT>
Additionally, a UserControl cannot unload itself. The controls should be loaded and unloaded by the program in which they are used.
Last edited by WizBang; September 22nd, 2009 at 11:24 AM.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
September 22nd, 2009, 02:26 PM
#24
Re: Destroying objects that was builded in project-mode
 Originally Posted by WizBang
Objects which are created at design-time cannot be destroyed at runtime. However, if you create an array, then additional elements can be loaded and unloaded at runtime. Still, the one you created at design-time must remain.
In the case of your sprites, one could be placed on the form at design-time, with an Index of zero. The other sprites would then be loaded/unloaded at runtime.
<EDIT>
Additionally, a UserControl cannot unload itself. The controls should be loaded and unloaded by the program in which they are used.
i'm sorry can you give me a simple(very simple) project that can create objects(with array and without array) simple in run-time?
thanks
-
September 23rd, 2009, 05:26 AM
#25
Re: Destroying objects that was builded in project-mode
Simply place one object on the form, and set the Index property to zero. This will create an array.
Then at runtime:
Code:
Private Sub CreateSprite(X As Long, Y As Long, Color As Long)
Dim I As Long
I = MySpriteArray.UBound + 1
Load MySpriteArray(I)
MySpriteArray.Move X, Y
MySpriteArray.ForeColor = Color
MySpriteArray.Visible = True
End Sub
Private Sub KillSprite(Index As Long)
Unload MySpriteArray(Index)
End Sub
You can create the first element with an Index other than zero, if you want. Note also that elements can be unloaded in any order. So the UBound of the array will not be the same as the Count. In other words, if you have 5 elements (Indexes of 1 to 5), and you unload number 2, the UBound will still be 5, while the Count is 4. This means that you may encounter errors if you try to iterate through an array after unloading one or more elements where the Index is not the UBound.
Objects can be created at runtime without being part of an array, but in that case you will not be able to catch the events without subclassing, which will very likely bring you many headaches.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|