?
Solved

Add Ocx toComposite Control

Posted on 2002-07-30
4
Medium Priority
?
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 768 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

770 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