From: A. W. Dunstan on 12 Feb 2010 13:23 Is it possible to call methods in a class provided in an OCX from a non-MFC, non-GUI application? I have a console mode app (C++, VS 2008 v9.0, XP SP3) that needs to talk to some special hardware (an infrared camera). The vendor provides software to do so, but they've provided it as a .h file and a .ocx file. Unfortunately it mixes both GUI components and camera communication all in one class. I don't want to use the GUI part at all - just the camera control methods. Can this be done? If so, how? I'd like to keep the code as portable as possible, too. While this device (or at least it's software) only works under Windows, if we go with a different camera all the rest of the code would run on Linux just fine. I tried listing the .ocx file as one of the "Additional Dependencies" for the linker (I put it's directory in the Additional Library Directories, too) but building the software gives me an error message that says "fatal error LNK1107: invalid or corrupt file: cannot read at 0x2B8", listing the offending .ocx as the file in question. Any ideas? Thanks in advance. -- Al Dunstan, Software Engineer OptiMetrics, Inc. 3115 Professional Drive Ann Arbor, MI 48104-5131 "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies." - C. A. R. Hoare
From: Igor Tandetnik on 12 Feb 2010 13:38 A. W. Dunstan <no(a)spam.thanks> wrote: > Is it possible to call methods in a class provided in an OCX from a > non-MFC, non-GUI application? Short answer: yes. Some controls will let you use them like a regular non-visual COM object - just create one and start calling its methods. Others insist on being properly hosted (otherwise any method call fails). Still, you can host these on a hidden window. > I'd like to keep the code as portable as possible, too. While this > device (or at least it's software) only works under Windows, if we go > with a different camera all the rest of the code would run on Linux > just fine. So, define your own Camera class with a generic interface, then implement it as needed for different cameras. > I tried listing the .ocx file as one of the "Additional Dependencies" > for the linker That's not how you use COM components. There are probably hundreds of COM tutorials just one Google search away. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
|
Pages: 1 Prev: Create custom macro for message cracker Next: add items to a list view |