[RESOLVED] Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
I have a Standard EXE with a form ("form1") and a labelbox ("label1").
Is it possible to call a subroutine from an ActiveX EXE that can directly modify the labelbox?
(I dont want to raise an event that leads to code within the Standard EXE, i want to do it right from the ActiveX EXE)
Example:
label1.label = "asdf"
If its possible, can someone tell me how?
Thanks
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
You can call methods and properties of an object hosted by the ActiveX EXE. You can't call a subroutine.
If you wanted to make a call that modified a Label control, you'd have to pass it as a parameter. I don't think there is a restriction on this that would prohibit it.
Hard to imagine this being very useful though, but you never know. Why not just return a String value from a property or method call and set the Label's Caption to it back in the caller?
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by dilettante
You can call methods and properties of an object hosted by the ActiveX EXE. You can't call a subroutine.
If you wanted to make a call that modified a Label control, you'd have to pass it as a parameter. I don't think there is a restriction on this that would prohibit it.
Hard to imagine this being very useful though, but you never know. Why not just return a String value from a property or method call and set the Label's Caption to it back in the caller?
sorry, bad use of terms on my part..im still trying to familiarize myself with my terms. thanks for correcting me :)
well see, what i actually wanna do involves .Render with a picturebox but i figured asking about a labelbox would make it simpler to answer. With the .Render, I dont really wanna return any values, but rather just do it on the ActiveX.
Its my understanding that if i use .Render in multiple ActiveX EXE applications (I think this is called an object), i can apply code to my Standard EXE simultaneously.
Why do i want to do that? Well i'm creating a game that involves animation of several characters, and if i use .Render on the Standard EXE, i will only be able to animate one character at a time. I wanna animate all of them at once. I was told that i can achieve this by using ActiveX EXE and "launching multiple objects". My only problem is, I dont know how. The common answer i'm getting from people is try searching "Multi-Threading" or ActiveX on the codebank. I've tried several times to do so, i've downloaded all kinds of code, but i havent made any progress in solving my own problem. I cant seem to identify where the multi-threading code starts...
If anyone could help me...i would appreciate it ALOT!!!!
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
What you could do here is set the parent of a form in an activeX EXE to be a picture box in your app.
What you would do is this:
1) Create ActiveX EXE with a class and form
2) Create a function in ActiveX EXE class like the following:
Code:
Public Sub Initialize(ByVal lngContainerhWnd)
{
Dim frmNew As frmMyForm
Dim lngFormhWnd As long
frmNew = new frmMyForm
frmNew.Load
lngFormhWnd = frmNew.hWnd
//Use the SetParent API here to set the activex exe form to be a child of the container form
//Use SetWindowPosition API here to position the form in the container
frmNew.Show
}
3) Add a call into your main app like:
Code:
Dim objActiveXClass = MyActiveXClass
objActiveXClass = new MyActiveXClass
objActiveXClass.Initialize(Picture1.hWnd)
Then...you let the activeX class do the animation on the activex form.
Woka
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by VBNubcake
.....I wanna animate all of them at once. I was told that i can achieve this by using ActiveX EXE and "launching multiple objects".
I tried doing the same exact thing for a game I was working on. I needed to have several animated objects moving at the same time, like what you want, so I made an ActiveX that basically represented one of the animations. I then embedded three ActiveX's of this animation onto my main application's Form. Although it worked the results were quite inferior compared to just having my one main application do all three of the animations using timers and loops.
Both methods yeild the same end results but the single application actually gave far better results than the three ActiveX's performing the animation on their own.
You can give it a try and see what you get and it may turn out that in your case the ActiveX's are the better way to go.
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by Wokawidget
What you could do here is set the parent of a form in an activeX EXE to be a picture box in your app.
What you would do is this:
1) Create ActiveX EXE with a class and
form
2) Create a function in ActiveX EXE class like the following:
Code:
Public Sub Initialize(ByVal lngContainerhWnd)
{
Dim frmNew As frmMyForm
Dim lngFormhWnd As long
frmNew = new frmMyForm
frmNew.Load
lngFormhWnd = frmNew.hWnd
//Use the SetParent API here to set the activex exe form to be a child of the container form
//Use SetWindowPosition API here to position the form in the container
frmNew.Show
}
3) Add a call into your main app like:
Code:
Dim objActiveXClass = MyActiveXClass
objActiveXClass = new MyActiveXClass
objActiveXClass.Initialize(Picture1.hWnd)
Then...you let the activeX class do the animation on the activex form.
Woka
how would i create a form on an activex exe? where am i getting 'frmMyForm' from?
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by VBNubcake
how would i create a form on an activex exe? where am i getting 'frmMyForm' from?
answered my own question, i had to uncheck unattended execution
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by Wokawidget
What you could do here is set the parent of a form in an activeX EXE to be a picture box in your app.
What you would do is this:
1) Create ActiveX EXE with a class and form
2) Create a function in ActiveX EXE class like the following:
Code:
Public Sub Initialize(ByVal lngContainerhWnd)
{
Dim frmNew As frmMyForm
Dim lngFormhWnd As long
frmNew = new frmMyForm
frmNew.Load
lngFormhWnd = frmNew.hWnd
//Use the SetParent API here to set the activex exe form to be a child of the container form
//Use SetWindowPosition API here to position the form in the container
frmNew.Show
}
3) Add a call into your main app like:
Code:
Dim objActiveXClass = MyActiveXClass
objActiveXClass = new MyActiveXClass
objActiveXClass.Initialize(Picture1.hWnd)
Then...you let the activeX class do the animation on the activex form.
Woka
how do i let the activex class do multiple animations? more than one? like if i launch another activex exe, it does it in another form, how do i get it to a single form?
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
how do i let the activex class do multiple animations? more than one? like if i launch another activex exe, it does it in another form, how do i get it to a single form?
You have to embed the ActiveX's Form onto your app's Form.
In your main app add a reference to the ActiveX.exe
Put some code in your main app like below
Code:
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Boolean
Private Sub Command1_Click()
Dim ABC As ActiveXProject.Class1
Set ABC = New ActiveXProject.Class1
Dim WinHandle As Long
WinHandle = SetParent(Me.hWnd, ABC.hWnd)
'
'
ABC.Go
'
'
End Sub
ActiveXProject is the name of the ActiveX exe
Class1 is a class module in that ActiveX
Go is a Public Sub in the Class1 module.
The SetParent is what allows you to embed the ActiveX's Form onto your app's Form
You can add as many as you like
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by jmsrickland
how do i let the activex class do multiple animations? more than one? like if i launch another activex exe, it does it in another form, how do i get it to a single form?
You have to embed the ActiveX's Form onto your app's Form.
In your main app add a reference to the ActiveX.exe
Put some code in your main app like below
Code:
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Boolean
Private Sub Command1_Click()
Dim ABC As ActiveXProject.Class1
Set ABC = New ActiveXProject.Class1
Dim WinHandle As Long
WinHandle = SetParent(Me.hWnd, ABC.hWnd) '
'
ABC.Go
'
'
End Sub
ActiveXProject is the name of the ActiveX exe
Class1 is a class module in that ActiveX
Go is a Public Sub in the Class1 module.
The SetParent is what allows you to embed the ActiveX's Form onto your app's Form
You can add as many as you like
thx
Will I need to send Winhandle to my ActiveX EXE through
ABC.Go(Winhandle)?
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
No. You just call the Function or Sub Go. The code in Go is your code so you can do what you want but I suppose you cound have a Sub/Function in the ActiveX that could recieve the handle of the Parent (your main app) in case you wanted the ActiveX to do things with that handle. I suppose you could even send the handle of any main app control (like Pictureboxex, Textboxes, etc) for the same purpose.
Keep in mind what I stated in post 5. If your animation is time intensive and speed is important then it may not work out like you would like. It was better for me to just put all of the animations in the main app and manipulate them there as it was when I tried doing it in multiple instances of an ActiveX.
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by jmsrickland
...If your animation is time intensive and speed is important then it may not work out like you would like. It was better for me to just put all of the animations in the main app and manipulate them there as it was when I tried doing it in multiple instances of an ActiveX.
I was planning on using the sleep API within my ActiveX for timed events.
Thx for the clarification
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
The point I am trying to get out is that if you have two or more animations that must animate at the same time and smoothness of simultaneous execution you may not like the side effects of running multiple instances of an ActiveX since the OS will split up the time allocation to each instance and it results in a choppy appearance. I made a slotmachine where I needed each of the spinner wheels spinning at the same time in a very smooth spin yet completely and totally independent of each other. It simply just didn't work using multiple instances of an ActiveX because the OS interrupted each one of then giving a certain time slice to each ActiveX and this resulted in a choppy spin of the wheels. When I finially put all the spinner wheels into one VB application and controled their spin using loops the results were very smooth and nice looking without any choppiness at all. It really depend on the application and what it is supposed to do because in some cases it might turn out very nice. Keep in mind however that embedding multiple instances of ActiveX EXE's is not true multi-threading like you get in Java or other multi-threading languages. It more like multi-tasking which cannot minic true multi-threading in the strict sense.
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by jmsrickland
The point I am trying to get out is that if you have two or more animations that must animate at the same time and smoothness of simultaneous execution you may not like the side effects of running multiple instances of an ActiveX since the OS will split up the time allocation to each instance and it results in a choppy appearance. I made a slotmachine where I needed each of the spinner wheels spinning at the same time in a very smooth spin yet completely and totally independent of each other. It simply just didn't work using multiple instances of an ActiveX because the OS interrupted each one of then giving a certain time slice to each ActiveX and this resulted in a choppy spin of the wheels. When I finially put all the spinner wheels into one VB application and controled their spin using loops the results were very smooth and nice looking without any choppiness at all. It really depend on the application and what it is supposed to do because in some cases it might turn out very nice. Keep in mind however that embedding multiple instances of ActiveX EXE's is not true multi-threading like you get in Java or other multi-threading languages. It more like multi-tasking which cannot minic true multi-threading in the strict sense.
yeah, i just found out that its choppy :S
thanks for all your help
Re: Can an ActiveX EXE set a property on a labelbox in a Standard EXE?
Quote:
Originally Posted by VBNubcake
yeah, i just found out that its choppy :S
thanks for all your help
just for anyone who has similar problems:
i just found out, my problem from the start was with my Sleep API.
In between animations, i used Sleep to stall from image to image (like 50 milliseconds between frames). I did this so that way animations were controlled under a timed event.
This actually causes a conflict with animating more than one thing at once because of the nature of how sleep works...it freezes your application for the specified time (meaning nothing else will execute its code until that specified interval has elapsed)
So after figuring that out, i just imposed a Timer API onto my main application (courtesy of Wokawidget's post in code bank :) ), and then used that timer to call procedures in my ActiveX. Basically, its a solution to the reason why I created this thread (to animate more than one picture at once). I got it animating pretty smoothly, no choppiness....i can even move the form around
But wait a minute, if im just using a Timer API on my main application, why can't I just use the timer control provided by vb? Well, good question. The answer is, I can.
So in the end, just use regular timers....The only purpose you would need "multi-threading" in vb is for very very very long calculations.
I'd like to thank everyone for their help.
This thread is now resolved :wave: