Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Embedding VB application in IE page

Posted on 2004-10-07
3
207 Views
Last Modified: 2013-11-13
This has probably been covered a million times in this forum. What I'm looking for is a complete answer with examples or links to good examples that will help me accomplish what I'm looking to do. Basically, I don't want to have to do much more research after this.

(1) I want to use Winsock in VB from a class. If I don't have a form, I can't use the control. So how can I use Winsock in a UI-less program (complete answer with example, please).

(2) I want to create a web page that enbeds a VB app. The page will have data from the server. The app, using Winsock, will be communicating with another server with more app-specific data. How can I accomplish this (VB and HTLM please)? I had tried a quick test with an ActiveX EXE and DLL and the <object> tag. The form I opened was not embedded in the page as I intended - it opened as a modal form. And IE said it didn't support nonmodal.

  a. Should I create an ActiveX DLL or EXE to embed in the page?
  b. Can I have a form (UI) that is displayed IN the page? Or, must I create a UI-less object that interacts with standard HTML controls? (examples, please)
  c. When an object tag is used, when is the object instantiated? Is that reference enough? When is it destroyed?

(3) Is there anything I'm missing? Again, web page hosted in IE that has, as part of the page, a custom VB app with an interface that communicates via Winsock to another server.

I am offering so many points because I am asking for detailed responses (I tried to offer more, but EE capped me at 500). Let me know if you need more information.

Thanks,
0
Comment
Question by:RhinoInformation
3 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 350 total points
ID: 12249783
1. http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10967841.html


2.
a.create a activex ocx
b. yes if use ocx
c. instantiated when page is loading, destroyed when outof scope

0
 
LVL 17

Assisted Solution

by:inthedark
inthedark earned 150 total points
ID: 12250458
Here is a better example of Winsock within a class. No need to create an ocx.


http://www.freevbcode.com/ShowCode.Asp?ID=109

The key points are:

1) You create an ActiveX DLL (or works just as well from within a standard exe).
2) You add a dummy form to your project with a dummy winsock control on the form.
(Dont put any code in the dummy form)
3) in your dll class when it initialises you need code like this:

Dim frmMyDummyForm As Form
Private WithEvents sckMySock  As Winsock
 
Private Sub Class_Initialize()

    ' instantiate the Winsock Control
    Set MyForm = New frmSck ' MUST use the New clause
    Set sckMySockl = frmMyDummyForm.WinSock1 ' whatever you called you winsock on your dummy form

End Sub

You class will now work using the events just as it would if it was on a form.

Hope this helps:@)
0
 

Author Comment

by:RhinoInformation
ID: 12293432
Thanks for the replies. I should have realized OCX...user control. Duh.

Related to the original Q, how can I set a reference from the OCX to the copy of IE that's hosting it?? Basically, I have a browser session open that has session variables on the server. I need to open a new page from IE that lives in the same session. SO, I need to be able to open a new page from the page that's hosting the OCX in order to be in the same session. I believe that if I create a new IE object that it will be in a different session (the difference between opening multiple copies of the browser versus opening a new browser window from the menu).

inthedark:
Just for your info, I found something a little better on this site:

In the DLL, go to the projects menu, select references and browse.  Browse to mswinsock.ocx in system dir.  You have now added a reference to the winsock library (you can't do this with all controls.)

In your class declare a variable at the General Declarations level.

Private WithEvents Winsock1 as Winsock

You should see the object dropdown on the left of the codepane will now have a Winsock1 entry.  Using the event dropdown on the right, you can enter code to handle all the events for the winsock 'control.'
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

789 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