Solved

Initialise ActiveX within a Class...

Posted on 2003-10-22
9
157 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
  • 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
 
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
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.

 
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

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

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 170
withoutTen challenge 14 97
canBalance challenge 34 69
Remove Password Protection from pdf (with password) using an command line executable 5 22
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

919 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

14 Experts available now in Live!

Get 1:1 Help Now