[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
www.undertowsoftware.com • View topic - Creating non-visual instance?

Creating non-visual instance?

A forum made available for users of the MapPro OCX SDK to exchange ideas, ask each other questions, etc.

Creating non-visual instance?

Postby jkenneally » Thu Aug 04, 2011 12:00 pm

Hi Guys,

I'm just tinkering with the mappro80.ocx at the moment. Registering it/Importing it into Visual Studio 2008 and creating a visual instance on a C# application was easy enough. However, I'm hoping to instantiate it non-visually through C++. Does anyone have an example of doing this? I don't have a TLB or any info related to it's CLSID, IID's, etc..

Cheers!
User avatar
jkenneally
New User
New User
 
Posts: 5
Joined: Thu Aug 04, 2011 10:35 am

Re: Creating non-visual instance?

Postby SamDee » Thu Aug 04, 2011 1:17 pm

jkenneally wrote:Hi Guys,

I'm just tinkering with the mappro80.ocx at the moment. Registering it/Importing it into Visual Studio 2008 and creating a visual instance on a C# application was easy enough. However, I'm hoping to instantiate it non-visually through C++. Does anyone have an example of doing this? I don't have a TLB or any info related to it's CLSID, IID's, etc..

Cheers!

Hmm... We use non-visual instances in our projects here, but as far as I know, it's all done through C#, so I am nor personally certain how one would do it in C++. Let me ask a couple of the other developers (they work on different projects) and see if they have used it in a similar manner. Actually, if you asked undertow directly, they'd probably be able to help you. They've been pretty good at answering our specific questions in the past. Unfortunately, they don't come by here too often :-(
User avatar
SamDee
Active User
Active User
 
Posts: 35
Joined: Wed Sep 29, 2010 8:33 am

Re: Creating non-visual instance?

Postby artmart » Thu Aug 04, 2011 2:08 pm

Nope, don't expect the UnderTow support and development teams to peruse this forum. This is usually a marketing thing and us forum users try to help each other out and an occasional moderator might come in here to make sure we all play nice or participate in something specific on behalf of us forum members.

Like SamDee suggests, send an email to support@undertowsoftware.com with your technical questions and you can probably get help from them if us forum members (like me) can't help.

We'd like you to post the solution here if you can get it resolved. This way other forum members can appreciate some of the legwork you did in getting this resolved if they have a similar issue/question.
Art Martinez
Murrieta, CA
User avatar
artmart
Executive User
Executive User
 
Posts: 840
Joined: Tue Jul 20, 2010 1:43 pm
Location: Murrieta, CA

Re: Creating non-visual instance?

Postby jkenneally » Fri Aug 05, 2011 9:41 am

Hi Guys,

I sent an email to support yesterday as you suggested. I haven't heard back yet, but through a combination of scouring the internet and experimentation I think I have a basic working example of creating the ocx instance non-visually through C++. It's not exactly a straight forward process and might be tricky if you aren't familiar with the details of COM itself. Here is some code that I put together based on a similar example I found:

Code: Select all
// disable a whole bunch of unnecessary (for me) stuff  by no_*
#import "C:\\WINDOWS\\system32\\MAPPRO80.OCX"  \
             no_namespace no_smart_pointers raw_interfaces_only \
             raw_native_types no_implementation named_guids

bool TestLoadOCX()
{
   CoInitialize(0);

   //IMapPro, CLSID_MapPro, IID_IMapPro are all from mappro80.tlh
   HRESULT hr = CoCreateInstance( CLSID_MapPro, CLSCTX_ALL, IID_IMapPro,  reinterpret_cast<void**>(&m_IMapPro) ) ;

   bool retVal = ( SUCCEEDED(hr) ) ;

   if(retVal == true)
   {
        m_IMapPro->AboutBox();

        m_IMapPro->Release();
   }

   CoUninitialize();

  return retVal ;
}


The real 'missing puzzle piece' was the #import directive. When you point that to the ocx, it will generate a 'tlh' file at compile time (and implicitly include it) that contains all the CLSID's, IID's, etc needed to interact with the ocx through raw COM. The real trick at this point is that the header file comes with no documentation, so you need to make educated guesses about which CLSID's and interface ID's to use, etc. The function sigs are not the same either, as they use COM conventions such as BSTR instead of language specific str's, etc.

Hope this helps!
User avatar
jkenneally
New User
New User
 
Posts: 5
Joined: Thu Aug 04, 2011 10:35 am

Re: Creating non-visual instance?

Postby jkenneally » Fri Aug 05, 2011 10:34 am

Woops...I put that example together from a more elaborate class-based implementation. m_IMapPro is an instance of "IMapPro *", and should have been declared in this example before the CoCreateInstance call.

Cheers
User avatar
jkenneally
New User
New User
 
Posts: 5
Joined: Thu Aug 04, 2011 10:35 am

Re: Creating non-visual instance?

Postby SamDee » Fri Aug 05, 2011 2:15 pm

Thanks for sharing. I was just wondering, what development environment are you using? If it's one of the VS environments, why couldn't you just add the instance to your toolbox, without adding a visual instance of the control on a form or anything. Wouldn't that create the needed interface, which you could then use in your project, without having to ever use the visual instance?

Sorry if that sounds naive, I am just trying to understand why you opted to do it this way (I'm sure you have your reasons).
User avatar
SamDee
Active User
Active User
 
Posts: 35
Joined: Wed Sep 29, 2010 8:33 am

Re: Creating non-visual instance?

Postby jkenneally » Mon Aug 08, 2011 10:06 am

Hi SamDee,

I may have gone that route if I had seen an easy way to do it using a native Win32 C++ project. As I mentioned in my first post I had added it as you described to a C# project and used it visually. In that same project I'm sure I could have created it non-visually with little effort. The issue I had was that even after adding the ocx to my toolbox in the c++ environment, I had no headers or source to reference in order to create a runtime instance.

I was hoping someone would know what was missing to do as you describe when I originally posted, as it would give me the slightly higher level interface. Short of that I knew I could fall back on raw COM to get at what I needed so I started down that path. If Undertow gets back with a simpler solution I'll post it as well.

Cheers!
User avatar
jkenneally
New User
New User
 
Posts: 5
Joined: Thu Aug 04, 2011 10:35 am

Re: Creating non-visual instance?

Postby SamDee » Wed Aug 10, 2011 10:12 am

Hmm... I am not a C++ developer, but I quickly added the OCX to my toolbox, started a new C++ project and the added as a reference to my project (no visual instance of the OCX on the form). The interface was created and I was good to go! I'm probably missing something very basic here.
User avatar
SamDee
Active User
Active User
 
Posts: 35
Joined: Wed Sep 29, 2010 8:33 am

Re: Creating non-visual instance?

Postby jkenneally » Thu Aug 11, 2011 4:39 pm

Hi SamDee,

I think the type of project might be part of the issue. Specifically what kind of C++ project did you create? When you said you 'added as a reference to your project' you mean in the 'project properties' dialog, under 'Common Properties->Framework and References', then clicking the 'Add new reference' button? If so, my issue is that with my project type I have no 'COM' tab on the resultant dialog to add my OCX reference from. I've gone through these steps with Undertow tech support as well.

For what it's worth I've been able to better test the lower level interface I described earlier and it seems to work fine, so I'll probably run with it unless an obvious fix comes up for adding a reference directly to the project.

Thanks
User avatar
jkenneally
New User
New User
 
Posts: 5
Joined: Thu Aug 04, 2011 10:35 am

Re: Creating non-visual instance?

Postby Gyrotech » Thu Aug 11, 2011 4:49 pm

Yeah, you won't see that "COM" tab, unless your project is a Windows Form Application. For example, if it's just a Win 32 Project, you'll never be able to just add the OCX by adding a reference. You'll need to import the control/interface, they way you did it. Let's put it this way, I spent a long time trying to figure out if I could do that, with a number of different Active-X controls, not just undertow's, and I never found any information on how it could be done.

The good thing is, as you said, that importing the interface at that lower level works just fine, so you can continue with your project.

If you *ever* find out that it is doable by adding reference, please post a message here and let me know.
User avatar
Gyrotech
Frequent User
Frequent User
 
Posts: 52
Joined: Mon May 03, 2010 11:23 pm


Return to MapPro OCX

Who is online

Users browsing this forum: No registered users and 2 guests

cron