?
Solved

Call Javascript from VB6 Active X control

Posted on 2009-02-10
5
Medium Priority
?
1,469 Views
Last Modified: 2013-11-18
Ok I am a little rusty on VB6 because I have spent too much time in .net.

So my question is how can I call some javascript from a vb6 active x control that is placed on a page?

Thanks,

Jonathan
0
Comment
Question by:jmarbutt
  • 3
  • 2
5 Comments
 

Expert Comment

by:TheSaint777
ID: 23635884
Use the Windows API CreateProcess to launch your browser with the java script name in the command line parameter.
0
 
LVL 2

Author Comment

by:jmarbutt
ID: 23636940
Do you have an example?
0
 

Expert Comment

by:TheSaint777
ID: 23681179
Found an easier way. Use the shell command:

Shell "C:\Program Files\Internet Explorer\Iexplore.exe C:\test\JS Test.htm"

The first part is the path to the browser: C:\Program Files\Internet Explorer\Iexplore.exe
The second part is the path to the script file: C:\test\JS Test.htm
 
0
 
LVL 2

Author Comment

by:jmarbutt
ID: 23684511
I think we are going in circles. Let me see if I can explain it a little better.

I have a page that has some javascript and an activex control, I want this active x control to call the javascript that is on the page with it, not open another browser window with in the active x control.

0
 

Accepted Solution

by:
TheSaint777 earned 1500 total points
ID: 23693831
Sorry about that.  There is no easy way that I know of to have an ActiveX control talk to a java script routine.  The ActiveX control is an executable and is thus separate from the Internet Explorer Executable.  Though you can display the ActiveX control on a web page, its still a separate executable.   If you were to launch a web browser instance with your ActiveX control, it might make it easier though Im not sure about that.   So the only way I know how to do it would be to automate your web browser. The traditional way to do that is to use the SendMessage API.   With the SendMessage API, you can send keystrokes(tab, enter etc.) and mouse clicks to any window you can get the handle on.   So what you do is tie a Java Script control like a button(which can be hidden) to your java script code that will get executed when your ActiveX control sends a mouse click to it.

Unfortunately, I dont have an example of how to code up the SendMessage this right now but you should be able to locate some examples on the web.   I do remember though that when you are sending messages, you have to send both the Key or Click down and the Key or Click up separately.  You also need to give the application time to respond so dont send messages  right after one another but give few milliseconds of delay so it can process them.  For example, send the Key down message, wait 10 ms and then send Key up message. So you have to call the SendMessage API twice for every message.   Note that you can use the tab key to set the focus of where you are sending your messages to(i.e. the button).  
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

749 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