Solved

Initialise ActiveX within a Class...

Posted on 2003-10-22
9
159 Views
Last Modified: 2013-11-20
Hi,

I have an interesting issue that I am having problems with ...

I have created a Class called DBConnect - which is used as a communications Class.  Within this class I wish to create a reference to a Database ActiveX control.  The 'DBConnect' Class provides a simple interface to the ActiveX control..

Now, I have created a private variable 'm_DB' which is an instance of the Database ActiveX, which is held within the DBConnect Class.

Public Functions if DBConnect will then be used to access the ActiveX.

Sounds fairly straight forward - he says - however it appears that I somehow need to 'Initialise' the ActiveX - as currently, I will get Assertions due to the Control not being ready...

How do I do this?  In previous cases I use the 'Create' function, but there is no hWnd to tie it to - or have a missed something...

Any help would be very much appreciated...

James
0
Comment
Question by:jatkin
[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
  • 6
  • 2
9 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9597800
You need to use window handler supplied by client - add function like:
Create(HWND, RECT)
to DBConnect class and create an ActiveX control in it.

If your class should be wrapper to existing ActiveX control added by user to dialog/form using designer, add function
Attach(<ActiveX control pointer>).

You may use both functions allowing to user both ways.
0
 
LVL 4

Author Comment

by:jatkin
ID: 9597828
The first option sounds like what I am after...

Can you please supply a snippit of example code?

Thanks again,

James
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9609319
Why do you need a window?  It sounds like your class purely functional behind-th-scenes... not U/I related at all.

-- Dan
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:jatkin
ID: 9612325
You're right, the Class is purely functional, however I understood that the 'Create' function needed a handle - I am obviously mis-understanding something.

If it is possible to simply initialise the ActiveX within the Class as a member variable (as in VB - Set myObj = New TheObject) then this is exactly what I am after.  I looked for info on doing this some time back, but as I found no information at all, I assumed that it couldn't be done that way...
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 9612387
If you want ActiveX Control to be invisible and you need it for some purpose inside of the class, create invisible window and keep the control in it.
0
 
LVL 4

Author Comment

by:jatkin
ID: 9612429
Can you please give an example - I've been a C/C++ programmer for many years, but my knowledge of MFC is still getting there....
0
 
LVL 4

Author Comment

by:jatkin
ID: 9903307
Hi,

The original requirement for this (dbConnect) is no longer an issue - I have extended the CDatabase class to cater for my requirements, howeverI still have this issue for another control - can anybody help?

It is associated with MSComm, which is created at runtime.  The handle to the control is held in m_pMainWnd, and created during the InitInstance function.  Obviously, by doing this, it works Ok, but generates a number of First Chance Exceptions.

To remove them, I need to Create the instance, but not attempt to display it in any way...  The current call is as folows:
   myCOM.Create("COMx", WS_VISIBLE, CRect(10,10,15,15), m_pMainWnd, IDC_COMX);

I believe that this is possible, but I am using the wrong parameters (WS_VISIBLE for one!)

Please can anybody help...

Best regards,

James
0
 
LVL 4

Author Comment

by:jatkin
ID: 9903437
Don't worry - if I change the call to ...

   myCOM.Create(NULL, WS_VISIBLE, CRect(0,0,0,0), m_pMainWnd, IDC_COMX);

I get no Exception warnings..

James
0
 
LVL 4

Author Comment

by:jatkin
ID: 11610716
Tidy up time on open questions...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 97
Get filename and folder into excel 7 87
viewing source code from eclipse 13 111
Problem to open Excel file 15 259
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 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