Error when using OCC in a dialog as a control

Hello everybody,

I found a bug which drives me crazy. When OCC is used in a dialog as a control (as found in the example HLR) it shows a weird behaviour:

1) The background of the dialog window is not painted correctly
2) On some systems (and I cannot say under what circumstances) the controls is completely black. This does not depend on the OS Version !

Both effects can be seen on the following screenshots showing the original HLR example (in my application the effect is the same):

I found a workaround for the bug, which is as follows:
Save the Windowproc before you create the WNT_Window and restore it afterwards to the original value:

// Save the window proc pointer
LONG WndProc = GetWindowLong(GetSafeHwnd(), GWL_WNDPROC);

Handle(WNT_Window) aWNTWindow =
new WNT_Window(theGraphicDevice, GetSafeHwnd());

if (!aWNTWindow->IsMapped())


// restore it to the original value
SetWindowLong(GetSafeHwnd(), GWL_WNDPROC, WndProc);

Unfortunately this does not solve my second problem, which makes OpenCascade unusable in dialog windows :-)


Stephane Routelous's picture

Hi Markus,

could you try to download exoTKAD ( ) to see if it is the same ( you can have a dialog box when you select an object in the 3d viewer, RMB and Transparency ).

If not, sorry....



Markus Hagemann's picture

Hi Stephane,

I'm sorry but I can't test it: The executable install has an unresolved external "angular_precision" in TKMath.dll (what version of OCC are you using?) and the source code does not compile here (a lot of compile errors). I use the latest public OCC release.


Stephane Routelous's picture

Did you download the version with OCC ?
the installer is installing the old ones ( I don't remember which version) in the exoTKAD directory, so it should be no conflict with your existing application.
try downloading

If you still have problems, I can send you the "new" one compiled with 5.1



PS : for the problems running exoTKAD, mail me directly :

Markus Nickels's picture

The first part of my problem report seems to be solved: Do not use the MFC function "DDX_Control" to bind a control to an OCC window. Use "CWnd::Create()" instead and take only the coordinates from a control in a window. The OnPaint() function of your control shall look like this:

void COccControl::OnPaint()
CPaintDC dc(this); // important !!!

if (!m_View.IsNull())

The second part of the problem is still under my investigation.

Kind regards

Markus Nickels