Solved

Embedding VB application in IE page

Posted on 2004-10-07
3
203 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now