New events
New events
New events
New events
New events
New events New events New events New events New events New events New events New events
New events New events
New events
Go Back  Xtreme Visual Basic Talk > > > New events


Reply
 
Thread Tools Display Modes
  #1  
Old 02-11-2008, 04:14 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default New events


hello my name is Joaquim.. i'm portuguese...
i'm building a activex control, but i need 3 events:
-create(when the object is created);
-destroy(when the object is destroyed);
-move(when the object moves).
these object(is name is Sprite control) is for create games more easy...
can any one help me?
thank you...
Reply With Quote
  #2  
Old 02-12-2008, 02:25 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

You can use UserControl_Initialize and UserControl_Terminate to raise custom events for create/destroy.

Im not sure about move. You could just run a sub in your main app everytime the position changes. This might work better because you could be updating the .top and .left of your control and using an event would mean the event fires twice where you only want it to fire once
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #3  
Old 02-14-2008, 04:04 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

thank you... about the Move event, i found a code... but about the other 2 events, i can't hunderstand how use it...
i combine what you said, but the problem is that doesn't work... i don't know why... the create event is ignored: i put a sprite control and i program the create event... when i execute the project, the create event is ignored, but why?
for the Destroy event, i put a method(this method only call the terminate event, but don't destroy the object(in execute (project) mode) for destroy the event... but the problem is that he ignore the code, i don't know why....

i know that theres another way for doing these: in form load event i can create the control and when i want i can destroy the control(using load/unload respectively), but i wanted in more easy way...
i need these way:
-when i execute the project(when the control is normaly created), the create event must be call;
-when i destroy the object(using the destroy method), must call the destroy event(and of course destroy the object).
if i creat the object in project mode, i must be liberty to destroy the object in excute mode.
can you help me?
Can you give me a usercontrol project example(just with create and destroy(inclued the method destroy) events)?
thank you...
Reply With Quote
  #4  
Old 02-15-2008, 01:58 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

It sounds like you want something slightly different to what i thought. When you say "event" do you mean you already have code to destroy the object but you want another sub in your app to be run when you destroy it? Or do you mean you want the code to actually destroy the object?
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #5  
Old 02-15-2008, 02:19 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

its difficulty to explain for me... i will give you a project... you will see the project and you will see what i need... the create event must be call in execute mode(i don't care if the control is created in a project mode or execute mode)...
for the destroy event must be call with the destroy method(the object must be destroyed, i don't care if the object is created in a project mode or in execute mode)
i don't know destroy a object i use unload function, but it give me a error, because was created in project mode... please help me...
thank you
Attached Files
File Type: zip New control.zip (5.0 KB, 6 views)
Reply With Quote
  #6  
Old 02-15-2008, 03:56 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

You cant use unload to unload a control that was created at design time. I think you might want a control array. The idea is that you have a control that remains hidden but it acts kind of like a template for the other controls. You can then load and unload new controls in the same array as you need to.

Understanding control arrays
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #7  
Old 02-15-2008, 04:17 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

Quote:
Originally Posted by the master View Post
You cant use unload to unload a control that was created at design time. I think you might want a control array. The idea is that you have a control that remains hidden but it acts kind of like a template for the other controls. You can then load and unload new controls in the same array as you need to.

Understanding control arrays
thank you... but i still have a problem... know i hunderstand that i can't destroy the control, but i can destroy "vertuality" the control, right?
can i hidden the object without change the Visible propertie?
can i associate the load event(like the form) to my object?(i wanted that the Created event was call when the object was created or when the form was load)...
thank you...

P.S: i'm sorry if i bored you with my questions, but i'm trying build a simple control, must be easy to use... using the unload/load control is more complex when we work with it events.
Reply With Quote
  #8  
Old 02-15-2008, 04:32 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

You cant hide an object without hiding it. If you really must make the control dissapear but keep .visible=true then you can move it to a position on the form where you cant see it (under another object or off the form). I dont recommend doing this though because the user can still tab to the control and fire events.

When using control arrays you can have a sub (mycontrol_create for example) and simply call that sub right after loading the control. You can even pass the index too.
Code:
private sub mycontrol_create(byval Index as integer) 'This is your create event end sub 'Somewhere else you can load a control and raise the create event load mycontrol(1) mycontrol_create(1)

You can do the same when unloading too.

PS: I dont often get bored of helping people
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #9  
Old 02-15-2008, 05:46 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

Quote:
Originally Posted by the master View Post
You cant hide an object without hiding it. If you really must make the control dissapear but keep .visible=true then you can move it to a position on the form where you cant see it (under another object or off the form). I dont recommend doing this though because the user can still tab to the control and fire events.

When using control arrays you can have a sub (mycontrol_create for example) and simply call that sub right after loading the control. You can even pass the index too.
Code:
private sub mycontrol_create(byval Index as integer) 'This is your create event end sub 'Somewhere else you can load a control and raise the create event load mycontrol(1) mycontrol_create(1)

You can do the same when unloading too.

PS: I dont often get bored of helping people

thank you, but i was thinking in other soluction, and i found a soluction for the destroy event...
using a destroy method i call the destroy event and then the usercontrol terminate event, but i inclued a variable of boolean type and if the control is "destroyed" it will ignore every events and actions and works fine...
when i have time i will think about the create event...
thank you my friend
Reply With Quote
  #10  
Old 02-15-2008, 05:53 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

I dont know exactly what your doing but it sounds like you would be better unloading the object when you dont need it anymore instead of making it ignore everything the app is telling it to do
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #11  
Old 02-16-2008, 09:17 AM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

yes you have right... i only i'm a simulate a object destruction(with other words, the object is hidden and it ignores events and properties)... i know that i can use load/unload is more efficient but will block one thing that i call "easely games constrution"... i know that i can't destroy an object that i create in project mode then i create a destrotion simulation...
i think more and i know why the create event is ignored, the event ins't ignored, but is call when i put the object in project mode... but i found an information that i need more about this: the execute mode call the load event(like the form load event), can we create a load(like the form load event) event for a new activex control?
thank you...
Reply With Quote
  #12  
Old 02-16-2008, 12:51 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

The point im making is that you shouldnt need to unload objects that you create at designtime. If you do need to unload some objects then you should load them at runtime too. If you do that then you will be able to unload them too
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #13  
Old 02-16-2008, 02:40 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

Quote:
Originally Posted by the master View Post
The point im making is that you shouldnt need to unload objects that you create at designtime. If you do need to unload some objects then you should load them at runtime too. If you do that then you will be able to unload them too
yes i hunderstand what you said... if i load/unload the object then without a problem is call the create/destroy event respectively....
i'm sorry, but can you give a example like this one:
-create a control(array or not, you decide) in runtime, but this control can't be created in designtime....
thank you...
P.S.: your sugestion is better than my... thanks
Reply With Quote
  #14  
Old 02-16-2008, 02:55 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

I think this is what you were looking for. I have attached a quick demo that shows how you have an object that is used as a "template" and you can load it as many times as you want.

You must remember that you have to set the index property of your template control to 0. I have already done this in the demo so run the app and see what happens
Attached Files
File Type: zip Array Demo.zip (1.6 KB, 7 views)
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #15  
Old 02-16-2008, 03:10 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

thank is what i need thank you my friend...
i don't hunderstand why these 1 lines:
Me.Show 'this is for show the form(in form load we can force the form to be show and then do_ the rest of event)
DoEvents 'i don't know nothing about this word, and i don't know why you use it...
thank you my friend
Reply With Quote
  #16  
Old 02-16-2008, 03:13 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

I put the code in form_load. That sub is run *before* the form is shown on the screen so you wouldnt have seen the demo correctly. "me.show" tells the form to show itself and "doevents" tells it to wait for the form to show before carrying on with the code.

If you add another command button to the form and move the code from form_load into command2_click then you dont need those 2 lines
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #17  
Old 02-16-2008, 03:19 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

thank you my friend, thank you
P.S.: how can i put this post [RESOLVED]?
Reply With Quote
  #18  
Old 02-16-2008, 03:22 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

You cant. These forums dont support thread statuses like that. When your problem has been solved you simply say "thankyou it worked" or similar. Its in the forum rules that you should read the whole thread before posting so other users will see that you have a solution but they may add extra information or an alternative solution
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #19  
Old 02-16-2008, 03:24 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

ok thank you my friend... is what i need thank you
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
New events
New events
New events New events
New events
New events
New events New events New events New events New events New events New events
New events
New events
 
New events
New events
 
-->