Solved

Add Ocx toComposite Control

Posted on 2002-07-30
4
199 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now