Solved

Add Ocx toComposite Control

Posted on 2002-07-30
4
200 Views
Last Modified: 2013-11-25
I have a composite comtrol i build in atl.
i added to the dialog an activex from the registered activex's.
the following has been added to the my h file :
#import "C:\Program Files\CtrlView\CtrlView.ocx" raw_interfaces_only, raw_native_types, no_namespace, named_guids

the control has an IDC_CTRLVIEW1_
How do i create an instance to the control & call it's methods & properties?

Give me please a smaple code.

thanks
0
Comment
Question by:etay
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7188523
If you are using MFC through class wizard you can create the object of the control.
0
 

Author Comment

by:etay
ID: 7188569
im not its atl no mfc
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 256 total points
ID: 7202034
THe #import wil cause a couple of new files to be created in your output directory.  For intance, you might find CtrlVie.tlh and CtrlView.tli

In these file, you will find definitions of the the objects in a C++-compatible form.  For instance, Here is a sequence that creates an ADO opject:

#include <stdio.h>
#include <afxdisp.h>
#import "c:\program files\common files\system\ado\msado15.dll" rename ("EOF","adoEOF") no_namespace

#define CREATEiNSTANCE(sp,riid) { HRESULT _hr =sp .CreateInstance( __uuidof( riid ) ); \
                                  if (FAILED(_hr)) _com_issue_error(_hr); }

struct InitOle {
    InitOle()  { ::CoInitialize(NULL); }
    ~InitOle() { ::CoUninitialize();   }
} _init_InitOle_;       // Global Instance to force load/unload of OLE

void main(){
    _RecordsetPtr   spRS;
    _ConnectionPtr  spCON;
    try{
        CREATEiNSTANCE(spCON,Connection);
        spCON->ConnectionString = L"driver={sql server};SERVER=(local);Database=pubs;UID=sa; PWD=;";
        // spCON->ConnectionString =L"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=authors.MDB;DefaultDir=C:\\test;";
             
        spCON->Open( "", "", "", -1 );

... etc.

After compiling the #import line once, I look into the Debug directory and I find the two files named msado15.th?  In .\Debug\msado15.tlh, i find a definition of _RecordsetPtr and _ConnectionPtr and I can use them as shown above.

-- Dan
0
 

Author Comment

by:etay
ID: 7202578
i already solved it but thanks for the answer anyway
i appreciate it.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question