Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Mobile / January 2006

Tip: Looking for answers? Try searching our database.

how to access an ActiveX control from script on PIE 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steveg - 10 Jan 2006 14:47 GMT
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>
Rich - 10 Jan 2006 17:42 GMT
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.

> 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).
steveg - 11 Jan 2006 14:28 GMT
> 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'

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.