Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Embedding VB application in IE page

Posted on 2004-10-07
3
Medium Priority
?
213 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 1050 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 450 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

782 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