Solved

Add Ocx toComposite Control

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

744 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

10 Experts available now in Live!

Get 1:1 Help Now