OpenGL and ActiveX controls

Hey guys…

OK I’m working on an ActiveX MFC control that basically renders a couple of polys using OpenGL.

Now,in a standard MFC application,I managed to get all of it working.However,when I tried doing the same thing in an ActiveX control project,I don’t see anything.My code compiles fine but still,nothing is rendered.

Anyone here have any source codes or links to this kind of subject?

Thanx in advance for any help

Hi TheGecko !

I did an MFC ActiveX control last year: it is the ActiveX counterpart to my standalone 3D viewer. The thing is, I cannot release the source as it is part of a commercial package…

Can you give pseudo-code so that I can check where the problem might lie ?
If I have time (which is quite unlikely these days…), I’ll try to build a simple ActiveX control using OpenGL…

Regards.

Eric

I’ve done one. Its really not that difficult. First and foremost, if you want the EASIEST way to do it… have the control create a local view (CView or CWnd) on top of itself, and you should be able to simply insert your MFC App view class in its place (or at least cut & paste the code in).

Remember to map messages from the control to the view though - write a generic message forwarding function in the Ctrl class.

If you want to do it without the view class, its trivially more difficult. I’d post up some code, but I’m also bound by contract.

If you want some faster lines of communication on this, you can email me at des@tropel.com.

Siwko

Oh you guys are sweet!

What I did was just create a regular ActiveX control (called Test) using the MFC appwizard and then I just started throwing in my OpenGL code into the TestCtl.cpp file like I did with the view.cpp file of my regualr MFC application.I’m thinking maybe there’s something wrong with this OnCreate function:

int CTestCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;

// TODO: Add your specialized creation code here
RECT rect;

m_hDC = ::GetDC(m_hWnd);
if (!SetupPixelFormat(m_hDC))
  PostQuitMessage (0);

m_hRC = wglCreateContext(m_hDC);
wglMakeCurrent(m_hDC, m_hRC);
GetClientRect(&rect);
InitGL(rect.right, rect.bottom);

ResizeScene( rect.right,rect.left );

DrawScene();

MessageBox(“Finished OnCreate() function!”,“Note”,MB_OK);

return 0;
}

You see,the thing is,my ActiveX control project compiles fine with no problems or warnings.But when I go to test it out in the ActiveX control test container,I don’t see anything.The background color should be black but it’s brown instead I would love to see some source code but like you guys said,you’re bound by contract.

If the above code is correct then I must be doing something else wrong in my project.Thanx for the replies guys!

Oh that reminds me,should there be something in my OnDraw member function or not? This may also be the source of the problem.Can’t be sure though.This is my first ActiveX control.

Thanx again!

All my rendering is done in the OnDraw function. Do you only render once when you create the control ??? If so, try to put the rendering in OnDraw…

You can e-mail me directly if you want faster answers !

Regards.

Eric

Thanx for the help Eric.I’ll email ya later on tonight.

I finally got it to work and display 2 display lists on the screen,but now whenever I test it out in the ActiveX control container after the 2nd or 3rd time,it locks up my computer.Grrr…nothing is ever so simple for me