?
Solved

Passing a form object from an application server

Posted on 1999-11-02
9
Medium Priority
?
115 Views
Last Modified: 2010-05-02
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?
0
Comment
Question by:Subhasundar
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 2179429
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
 
LVL 10

Expert Comment

by:caraf_g
ID: 2179430
"cliend" :-)
0
 

Author Comment

by:Subhasundar
ID: 2179519
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 10

Expert Comment

by:caraf_g
ID: 2179535
No. Sorry....
0
 

Author Comment

by:Subhasundar
ID: 2179555
Sorry, I meant to say that the Client will call the function of the exe server.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2179568
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
 

Author Comment

by:Subhasundar
ID: 2179678
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
 

Author Comment

by:Subhasundar
ID: 2179683
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
 
LVL 10

Accepted Solution

by:
caraf_g earned 150 total points
ID: 2179713
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question