Passing a form object from an application server

I have developed an Active X exe server (Remote).I want a function of an interface to return a form object( containing different controls on it) to the Client application, which will then show the form(obviously on the client side).Is it possible?If so, then how?
SubhasundarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caraf_gCommented:
No. You can't create a form on the server and then show it on the client. Sorry...

What you CAN do, is to create the form on the Client, pass it back to the server which then fills it, and then show it on the cliend. Not recommended.

Best approach is to have your server provide the data through a class, and your client is responsible for representing the data on a form.

What exactly are you trying to achieve?
0
caraf_gCommented:
"cliend" :-)
0
SubhasundarAuthor Commented:
Well caraf_q,what I want to do is to call a function from the EXE-server which will be responsible for creating a form object with controls(text-box, combo...etc)and will "Show" the form to the client machine.Is this possible?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

caraf_gCommented:
No. Sorry....
0
SubhasundarAuthor Commented:
Sorry, I meant to say that the Client will call the function of the exe server.
0
caraf_gCommented:
That is no problem. You can call functions from the exe server and return any sort of object variable from them. I bet you can even return an object variable that points to a "Form" object; I'm not sure you can, but let's say you can for argument's sake...

But, here comes the crunch. The object variable is only part of what is needed to show a form. The object variable is your COM interface with the form. The other part that defines a form is a Window (accessible through its Window handle). Now that window can only be interacted with on the server machine on which it was created. You cannot show a window created on one machine on another machine.

So even if the following was valid code, and you could get it to compile and run:
Call ThatServerFunction(objForm)
objForm.Show
....nothing would happen on your client machine. Perhaps a window might pop up on your server machine. I don't know, I don't know COM well enough to make a definitive statement on this.
0
SubhasundarAuthor Commented:
caraf_q,

I tried your first option .I added the following function in a class of the Actve x exe project:

Public Sub Showform(form As Object)
   form.txtsample.Text = "hello"
End Sub

in the remote cleint I made a reference to the server component,and had the following piece of code :

Private Sub Form_Load() ' of form1-the _ startup form

  Dim db As New sample'sample is the    
           name of the component
  Load Form2 'another form
  On Error GoTo errlvl
  db.Showform Form2
  Form2.Show
  Exit Sub
 errlvl:
  MsgBox Err.Description
 
End Sub

but this gave an error
"Method '~' of object'~'failed "with the component as the source of the error.

Please help me!!
0
SubhasundarAuthor Commented:
caraf_q,

I tried your first option .I added the following function in a class of the Actve x exe project:

Public Sub Showform(form As Object)
   form.txtsample.Text = "hello"
End Sub

in the remote cleint I made a reference to the server component,and had the following piece of code :

Private Sub Form_Load() ' of form1-the _ startup form

  Dim db As New sample'sample is the    
           name of the component
  Load Form2 'another form
  On Error GoTo errlvl
  db.Showform Form2
  Form2.Show
  Exit Sub
 errlvl:
  MsgBox Err.Description
 
End Sub

but this gave an error
"Method '~' of object'~'failed "with the component as the source of the error.

Please help me!!
0
caraf_gCommented:
Yes, that confirms my suspicions.

You really should not do this... it's bad programming practice.

Instead, you should have a class in your activex .exe that simply returns all the data. The best performance can be got by having a single function return all the data you need.

Public Function GetData(strDataForTextBox1 As String, strDataForTextBox2 As string...etcetera (will get nice 'n nasty for things like list views...) As Boolean 'handy so you can return false if anything goes wrong.

Your client then calls this function, and the client fills the controls on Form2 itself.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.