[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Using an ActiveX control in VC++

Posted on 2002-04-30
11
Medium Priority
?
726 Views
Last Modified: 2013-11-20
When trying to use my ActiveX control in Visual C++, I noticed that when inserting the control in the dialog the control will not be created which causes the m_hWnd to be NULL which causes problems in my control behavior at design time. What shall I do to overcome this problem? Any ideas?
0
Comment
Question by:Daed
[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
  • 5
  • 4
11 Comments
 
LVL 6

Expert Comment

by:Triskelion
ID: 6980250
How did you bind the class to the control?
0
 

Author Comment

by:Daed
ID: 6980263
I didn't understand what do you mean. Plz explain more.
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6980280
When you put the control on the (I'm assuming) CFormView, did you create a class for it to be controlled or are you attempting to access it directly/only by its handle?
0
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 

Author Comment

by:Daed
ID: 6980315
I added the control to a dialog based project by choosing “Add to project” from the “Project” menu, then chose “Components and Controls” then “Registered ActiveX Controls”. When clicking Ok the system will insert the .cpp and .h files of the control. In MyDialog.h, I created an instance of the control as follows:
MyControlCtl* ptrControl1;
In the OnInitDialog in MyDialog.cpp, I wrote the follows:
ptrControl1 = (MyControlCtl *) GetDlgItem(controlID);

0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6981498
Can you use the class wizard to attach a variable to the control.
I see that you're doing it manually with the GetDlgItem, but does Class Wizard see the thing?
0
 

Author Comment

by:Daed
ID: 6982701
Yes, the ClassWizard can see the control and i can add it as a member variable from there. May be the problem is in the control code not the application?!
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6983132
Can you add ANY other Active X control that works properly?
Do you have the Active X test container thingy?
0
 

Author Comment

by:Daed
ID: 6991108
Yes I can add other ActiveX controls that works properly and I tried my Control in Text container and everything worked fine.
0
 

Author Comment

by:Daed
ID: 11687647
Please delete this question. I found out that my problem was that the control was not created at design-time, that's why the m_hWnd was always NULL. I solved the problem by adding the following lines of code in the OnDraw:

    if(!AmbientUserMode() && !m_hWnd)
    {
        // This drawing code creates the window and has it draw its
        // child windows into it.
        _AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
        ASSERT(pThreadState != NULL);
        pThreadState->m_pWndPark = new CWnd;
        pThreadState->m_pWndPark->m_hWnd = pcdc->GetWindow()->GetSafeHwnd();
   }
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11708544
PAQed, with points refunded (100)

Netminder
Site Admin
0

Featured Post

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!

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

656 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