Question

Developing and testing an ATL Control (ActiveX) on Windows Mobile

Asked by: harryscotter

I have developed an ATL Control that works fine on Windows desktop. I am trying to get this to work on Windows Mobile 5.0 Pocket PC as well.

I have managed to get the ATL to compile on the WM5 PPC emulator successfully and the ATL objects work fine. However, I need to test the ATL Control that is in the same DLL.

I have a C# smart device test app and i'm trying to add the ATL Control to its dialog but the control doesnt appear in the Toolbox in the Dialog editor (visual studio 2005). I tried going to 'Choose Toolbox Items' and selecting the COM object for the ATL Control (which is the one that is registered on the PC) but it never shows up in the Toolbox. I also tried browsing to the DLL that is compiled for Windows Mobile and selecting it but I get a message stating that 'Self-registration' failed.

How do I add the ATL Control to a dialog in Windows Mobile?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-09-21 at 06:11:22ID24748151
Tags

ATL Control ActiveX Windows Mobile PocketPC

Topics

Windows MobileProgramming

,

Windows ATL / WTL / COM Programming

Participating Experts
1
Points
500
Comments
30

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. NULL MODEM CABLE / ActiveSync / Emulator / PPC
    Hello, I am working on PPC using eVB. Since I dont have the device, i have to do development and testing on emulator. Now, i'm trying to sync. "Activesync and Emulator" with the help of null modem cable. I got to know , that null modem cable will help me acheive t...
  2. Pocket PC Emulator
    I want to develop a web site to be accessed on PDA/Pocket PC it will not be an app deployed on the PDA/PPC is there an emulator I can install on my PC that can access the website so I can test the website??
  3. Performance Monitoring Applications for Windows Mobile/…
    I would like to monitor the applications that are running in my Windows Mobile 5.0 or Pocket PC Emulator while deploying from my Visual Studio 2005 IDE. I have an ActiveSync too, which is able to interact with my Emulator. Is there an Utility or a Task Manager kind of thing...
  4. Internet phone for Mobile 5.0 PPCs
    Hi - I recently purchased a XV6700 from Verizon Wireless with unlimited data plan using EVDO. Was wondering if anyone knew of a VOIP service that I can use along with the phone’s Mobile 5 OS. e.g. Skype for PPC. Ideally I would like to be able to call land/mobile lines u...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: alexey_gusevPosted on 2009-09-21 at 06:58:23ID: 25382861

well, never tried to use WinMo controls from toolbar panel in cf.net app, but that's how I used to use them in C++:

http://msdn.microsoft.com/en-us/library/aa454894.aspx

I believe the problem is with proper registration WinMo control for design time

 

by: harryscotterPosted on 2009-09-21 at 07:59:44ID: 25383581

Ive had a look at that link. The only thing I see that helps in C++ is that the toolbox has a 'Custom Control' item that can be used to represent the control. There doesnt seem to be a 'Custom Control' item in C#.

If I was using a C++ test app then how can I refer to the 'Custom Control' from within the code so that I can call methods on it? Where do I #import the DLL from and how do I get from the custom control to the actual control object and call methods?

 

by: alexey_gusevPosted on 2009-09-21 at 08:42:58ID: 25384097

here's my old article :) , maybe it'll be helpful

http://codeguru.earthweb.com/cpp/w-p/ce/pocketpc/print.php/c10817

if you have some header file you could simply use it with smart pointers, or use #import directive in eg stdafx.h

 

by: harryscotterPosted on 2009-09-21 at 09:20:45ID: 25384552

Sorry, but thats not what im looking for.

I have a DLL containing an ATL Control I have developed. The DLL is compiled for Windows Mobile 5 Pocket PC.

The ATL Control has 1 method I want to call called Open().

I need to somehow create the control and then be able to call methods on it.

1: How do I use the ATL control in a C# smart device application?
2: How do I use the ATL control in a C++ smart device MFC application?

 

by: alexey_gusevPosted on 2009-09-21 at 10:37:50ID: 25385390

look at this one: http://msdn.microsoft.com/en-us/library/ms834212.aspx (this is old-ish, but I guess that's the way still)

re. my own article, you can still use CWnd::CreateControl() in MFC to create it dynamically and then use

            LPUNKNOWN lpUnk = m_PlayerWnd.GetControlUnknown();
            HRESULT hr = lpUnk->QueryInterface(__uuidof(IWMP),(void**)&m_spWMPPlayer);

to get the desired interface. Either use #import or header with the interface definition (which has to be generated already) to have the interface similar to what I've used in the article:

#include "PlayerOCX.h"
...
      CComPtr<IWMP> m_spWMPPlayer;


I reckon that if you register your control on the desktop then you'll be able to use it even with the wizard in VS

 

by: harryscotterPosted on 2009-09-22 at 01:38:25ID: 25390659

I have tried that approach. When I do the QueryInterface call I get back E_NOINTERFACE.

 

by: alexey_gusevPosted on 2009-09-22 at 01:44:11ID: 25390689

so it is somehow not registered or you need to check what's the exact name of the interface. it might be _ISomething or CLSID_Something or Something etc etc

you can get the same with few Get functions:

WINOLEAPI StringFromCLSID(REFCLSID rclsid, LPOLESTR FAR* lplpsz);
WINOLEAPI CLSIDFromString(LPOLESTR lpsz, LPCLSID pclsid);
WINOLEAPI StringFromIID(REFIID rclsid, LPOLESTR FAR* lplpsz);
WINOLEAPI IIDFromString(LPOLESTR lpsz, LPIID lpiid);
WINOLEAPI_(BOOL) CoIsOle1Class(REFCLSID rclsid);
WINOLEAPI ProgIDFromCLSID (REFCLSID clsid, LPOLESTR FAR* lplpszProgID);
WINOLEAPI CLSIDFromProgID (LPCOLESTR lpszProgID, LPCLSID lpclsid);
WINOLEAPI_(int) StringFromGUID2(REFGUID rguid, LPOLESTR lpsz, int cbMax);

 

by: harryscotterPosted on 2009-09-22 at 03:08:42ID: 25391063

Ok. I can get further if I specify the full CLSID of the class instead of using __uuidof for some reason.

It works ok on the WM5 emulator. However, it doesnt work on the Pocket PC device. The call to CreateControl on the device causes a crash with the following information in the visual studio output window:

AKY=00001001 PC=03f905b8(coredll.dll+0x000445b8) RA=8001739c(NK.EXE+0x0001739c) BVA=00000001 FSR=00000001
EXCEPTION_RECORD(e06d7363(???),1(EXCEPTION_NONCONTINUABLE),0,3f905b8,3)
ExceptionInformation:
 0 : 19930520
 1 : 1b97e5f8
 2 : 1bcbbc
dwSystemPowerState = 0x10010000

Followed by a memory dump.

I have deployed the DLL to the device so that is not the problem. The app will run on the device fine if I comment out the CreateControl line.

 

by: alexey_gusevPosted on 2009-09-22 at 03:16:27ID: 25391105

the easiest way is to test it on PDA with the Mobile IE and that page generated by default. just add button to it and call your AX object method in JS function. Add alert("HERE") and alert("THERE") before and after the call to AX.Method()

how have you deployed it? I've found that for me it is easier to create a cab and mark the dll as COM self-registered

 

by: harryscotterPosted on 2009-09-22 at 03:20:47ID: 25391138

"the easiest way is to test it on PDA with the Mobile IE and that page generated by default. just add button to it and call your AX object method in JS function. Add alert("HERE") and alert("THERE") before and after the call to AX.Method()"

I have no idea what you mean by this.

I deployed the DLL directly from Visual Studio by selecting Deploy Solution from the build menu. This deploys the DLL onto the device and registers it.

 

by: alexey_gusevPosted on 2009-09-22 at 03:30:25ID: 25391202

what I meant is that: when you create ATL Control, you can embed it into html page, so Mobile IE makes all the job creating it etc. This can be used instead of AX Control Test Container app.

So add something like that to generated htm page:

<OBJECT ID="MyCtrl" CLASSID="CLSID:BCAF8B06-D7DA-4822-A2B4-4195A1AD11FD" width="1" height="1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
function testMe()
{
    alert("BEFORE");
    MyCtrl.Open();
    alert("AFTER");
}
</SCRIPT>

<FORM>
<INPUT TYPE="BUTTON" VALUE="test me" ONCLICK="testMe()">
</FORM>


CLSID should you for your object of course. so update the htm page, copy it to PDA and open it in IE. If after clicking on the button you see both alerts then all is OK. Depending on what and if you draw something in the control, you could see it on the page too. This gives you perfect test if all is properly registered etc.

 

by: harryscotterPosted on 2009-09-22 at 04:09:34ID: 25391423

I get a BEFORE but not an AFTER.

 

by: harryscotterPosted on 2009-09-22 at 04:09:52ID: 25391426

The Open method does nothing. It just returns S_OK.

 

by: alexey_gusevPosted on 2009-09-22 at 04:30:09ID: 25391567

it means it can't create the object

 

by: alexey_gusevPosted on 2009-09-22 at 04:31:15ID: 25391576

to be 100% sure, can use register the object manually, ie LoadLibrary() and DllRegiterServer() ?

 

by: harryscotterPosted on 2009-09-22 at 04:33:25ID: 25391584

Tried that. Also tried creating a CAB file and installing it that way.

I get the same thing on the WM emulator using the html file. I get the BEFORE but not the AFTER. But I can get my test app to work on the emulator but it wont work on the actual device.

Losing the will to live now.

 

by: alexey_gusevPosted on 2009-09-22 at 04:39:22ID: 25391622

ok, let's start from scratch :)

- create dummy ATL Control object
- test it on PDA as described in <SDK DIR>\Samples\ATL\AXSample (ie with PIE)

if that works, use CreateControl() etc, then start adding your features

somewhere it might stop working and we'll get the answer we are after

 

by: harryscotterPosted on 2009-09-22 at 05:20:05ID: 25391893

Created a very simple test DLL and even it doesnt work. Here are the steps followed:

- Created a new C++ Smart Device ATL Smart Device Project
-- Windows Mobile 5.0 Pocket PC SDK
-- DLL

- Added a new Smart Device ATL Control Class to the project
-- Name = MyDummyControl
-- Standard Control
-- Single Threaded
-- No changes to any other default settings.

- Added the preprocessor definition _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to the project.

- Added a method to the IMyDummyControl interface called TestOpen. Takes no parameters. Did not add any additional code for this to the MyDummyControl class so the TestOpen method just returns S_OK.

- Compiled successfully.
- Selected Deploy Solution from the build menu to deploy to the WM5 emulator. Success.

- Updated the test.html file to use the CLSID of the MyDummyControl class and to call TestOpen in the testMe method. Put the test.html file on the WM5 emulator storage card.

- Opened test.html in the emulator and presed the test me button. BEFORE appears. Pressed ok. No AFTER message appears.

 

by: harryscotterPosted on 2009-09-22 at 06:56:19ID: 25392841

Here is a link to a zip file containing the sample DLL project:

http://www.filesavr.com/dummyatl

The code in the test.html file is:

<OBJECT ID="MyCtrl" CLASSID="CLSID:9CE095EC-4259-44C4-A6E6-092B9FFED843" width="200" height="200"></OBJECT>
 
<SCRIPT LANGUAGE="JScript">
function testMe()
{
    alert("BEFORE");
	MyCtrl.TestMe();
    alert("AFTER");
}
</SCRIPT>
 
<FORM>
<INPUT TYPE="BUTTON" VALUE="test me" ONCLICK="testMe()">
</FORM>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:

Select allOpen in new window

 

by: harryscotterPosted on 2009-09-22 at 06:58:05ID: 25392857

Sorry wrong test.html code. The correct test.html file code is:

<OBJECT ID="MyCtrl" CLASSID="CLSID:869E6011-037C-44C6-A43D-357898FF69DB" width="200" height="200"></OBJECT>
 
<SCRIPT LANGUAGE="JScript">
function testMe()
{
    alert("BEFORE");
	MyCtrl.TestOpen();
    alert("AFTER");
}
</SCRIPT>
 
<FORM>
<INPUT TYPE="BUTTON" VALUE="test me" ONCLICK="testMe()">
</FORM>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:

Select allOpen in new window

 

by: alexey_gusevPosted on 2009-09-22 at 07:01:03ID: 25392892

please check attached sample, it at least worked with PIE (remove all .txt extensions first)

 

by: harryscotterPosted on 2009-09-22 at 07:20:05ID: 25393091

Ah, ok. Seems I didnt add <HTML> and <BODY> tags into the test.html file. Works fine once I added them.

Will try the original control again now.

 

by: harryscotterPosted on 2009-09-22 at 09:08:00ID: 25394402

The original control works fine in the test.html file now.

However, I still cant get it to work in the C++ test app.

So I tried making the C++ test app use the MyDummyControl to see what happens and it also crashes. The debug output window has the following in it:

CoCreateInstance of OLE control {869E6011-037C-44C6-A43D-357898FF69DB} failed.
>>> Result code: 0x80004002
>>> Is the control is properly registered?

I dont see why this appears when the control is clearly registered properly since it works in the test HTML file.

 

by: alexey_gusevPosted on 2009-09-22 at 09:31:31ID: 25394630

it all depends on crafty things like ProgID etc
try various things where __uuidof() is, get it via ProgID for instance (from those methods above)

 

by: harryscotterPosted on 2009-09-22 at 10:19:15ID: 25395150

I dont think that is the problem. I am using the full GUID of the control in the call to CreateControl.

I have tried using the progid as well and it also does not work.

I've tried using __uuidof as well and I get the same result.

 

by: alexey_gusevPosted on 2009-09-22 at 11:29:43ID: 25395940

another thing - have you checked ActiveX controls when created the app? Or called CoInitialize() ? Just to confirm you're not trying to initialize COM object when COM is not initialized :)

 

by: harryscotterPosted on 2009-09-23 at 02:30:46ID: 25401181

Yes I ticked the ActiveX controls option when creating the project. What code does this add to the project?

I added a call to CoInitialize even though I dont think that is the issue because that would return a different error code. The added call to CoInitialize doesnt make any difference.

 

by: alexey_gusevPosted on 2009-09-23 at 03:45:27ID: 25401560

http://www.filesavr.com/dummyatl_1

this does work and uses your DummyATL project

 

by: harryscotterPosted on 2009-09-29 at 02:48:48ID: 25447215

I'm going to assume that the ActiveX control is working in my project and that the issues i'm experiencing are related to the fact I cannot debug on the device.

 

by: harryscotterPosted on 2009-09-29 at 02:51:07ID: 31634759

Was able to get the ActiveX control working as described using Internet Explorer. However, was still not able to get it working in a C++ or C# application.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...