Solved

Add Ocx toComposite Control

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Embarcadero WebBroker REST server endpoint parameters 2 96
Problem to open text file 11 136
C# LINQ ForEach() question 6 84
Why use this lambda? 12 62
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

749 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