how to access an ActiveX control from script on PIE 2003

S

steveg

I am working on a a web page using VS 2003 and the ASP.NET Mobile Controls
and which will be viewed only on Pocket Internet Explorer 2003 (on an O2 XDA
IIi).

The page has an ActiveX object in it that I have written with VC++ embedded
V4 and I am trying to access this control from JScript.

If I write a plain .htm page, I can access the ActiveX control from the
forms onSubmit attribute (example below). This works fine.

However, if I try to access the ActiveX control from script that is *not* in
the forms onSubmit attribute, the object is Undefined.

The problem is that I cannot use the forms onSubmit attribute in a Mobile
Control page.

I want to to one of following things (most preferable first)...

1) Find out how to reference the ActiveX control from normal script

2) Find a hack that allows me to render and then use the forms onSubmit
attribute to access the control and then kludge this into the other
jscript on the page so that I can postback having accessed the control.

3) Anything else to make it work...

I include a plain htm page below that shows both the working and non working
situations. The page as shown works. If however the line commented with
'works' is commented out and the following line (commented with 'fails') is
commented in the script fails. I know this is not the Mobile Controls page
but if I can get the failing page to work, I can transfer that logic to the
Mobile Controls page

The test pages are on
www.p2cl.co.uk/ppct/skgood.htm (works)
www.p2cl.co.uk/ppct/skbad.htm (does not work)

The ActiveX is available if required as
www.p2cl.co.uk/ppct/armv4sketch.ocx (for arm)
www.p2cl.co.uk/ppct/emsketch.ocx (for emulator) (works but this problem
not tested on emulator)

TIA

------------------------ example --------------------------

<HTML>
<HEAD>
<TITLE>SketcCtl Test</TITLE>

<script language="JavaScript">
<!-- Hide script
function send_Signature( obj_Parm_Image_Data )
{
var theform = document.forms["testForm"];

// use just *one* of the following 2 lines. using first works, using
second fails
// using this next line works (activex referenced in onSubmit)
theform.SIGDATA.value = obj_Parm_Image_Data ; // works
// using this next line fails (with "SketcCtl is Undefined")
// theform.SIGDATA.value = SketcCtl.ImageDataAsString() ; // fails

theform.submit();
}
// End hiding -->
</script>

</HEAD>

<body bgcolor="#66ffff">
<p>Sign in the box below...</p>

<form action="http://www.p2cl.co.uk/ppct/echo.asp"
id="testForm"
method="post"
onSubmit="javascript:send_Signature( SketcCtl.ImageDataAsString() )
;return false;" >

<OBJECT ID="SketcCtl" CLASSID="CLSID:CBF9C2BE-E8CB-11D0-AFAE-00600811D2B6"
height="90"
width="260"
VIEWASTEXT >
Sketch not supported.
</OBJECT>

<input name="submitBTN" id="submitBTN" type="submit" >
<input type="hidden" name="SIGDATA" id="SIGDATA" value="" />

</form>

</BODY>
</HTML>
 
R

Rich

It has been awhile since I did this in ASP.NET 1.1/Windows Mobile 2003 for
PIE, and it wasn't the most elegant, but it went something like this...

There was no straightforward support for ActiveX controls in PIE.

ActiveX controls must be pre-installed on the PDA, cannot be "pulled" from
the IIS server at runtime

What I was trying to do: Start a program on the PDA from PIE, which was the
main user interface. The program controlled sensor associated with the PDA's
CF slot. I could not start the program directly from PIE, but I could invoke
an ActiveX control that could then launch/configure the sensor. The sensor
returned results back to IIS via a web service (and not back through PIE).

You can reference an ActiveX control that is already present on the PDA in a
Panel/DeviceSpecific/Choice construct, as follows
<mobile:panel id="pnlLaunchRFIDReader" runat="server">
<mobile:DeviceSpecific id="dspFrmLaunchReader" runat="server">
<Choice Filter="supportsJavaScript"
Xmlns="http://schemas.microsoft.com/mobile/html32template">
<ContentTemplate>
<SCRIPT language="javascript">
var launcher = new ActiveXObject("MyControl.MyObject");
// if the ActiveX control is already in PDA memory, it is used. No
danger of "newing" up numerous instances of the control.
// the form "command" elements are set in the .aspx page's
code-behind file, and initialize the ActiveX control's properties
launcher.action = window.frmLaunchReader.cmdAction.value;
launcher.actor = window.frmLaunchReader.cmdCareprovider.value;
launcher.scansteps = window.frmLaunchReader.cmdScanTaskStart.value;
launcher.subid = window.frmLaunchReader.cmdSubid.value;
launcher.serverip = window.frmLaunchReader.cmdServerip.value;
// clear the forms "command" elements to reduce UI clutter
window.frmLaunchReader.cmdAction.value = "";
window.frmLaunchReader.cmdCareprovider.value = "";
window.frmLaunchReader.cmdScanTaskStart.value = "";
window.frmLaunchReader.cmdSubid.value = "";
window.frmLaunchReader.cmdServerip.value = "";
// call a method in the ActiveX control
var result = launcher.LaunchManagedApp();
</SCRIPT>
</ContentTemplate>
</Choice>
</mobile:DeviceSpecific>
</mobile:panel>

I hope this helps.
 
S

steveg

Rich said:
It has been awhile since I did this in ASP.NET 1.1/Windows Mobile 2003 for
PIE, and it wasn't the most elegant, but it went something like this...

There was no straightforward support for ActiveX controls in PIE.

[snip]

Thanks for the info. It raises some thoughts with me. At the moment my
ActiveX does not set it's own height/width so there may be issues 'new'ing it
but if my call into MS Support doesn't get anywhere, I'll change the ActiveX
and see how it displays using 'new'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top