1
votes

I have a problem with CWnd::CreateControl method while loading custom ActiveX control from the MFC application.

I have list of Custom ActiveX controls which are implemented Create method inturn calling CWnd::CreateControl method.

I am having Dialog window, in the OnInitDialog, I have started timer thread using Settimer(). In the OnTimer event, I am loading all the controls by calling respective control's Create method. After opening and closing the dialog window more than 10 times, OnTimer is not able to load the contols.

I checked the return value which is false and the GetLastError which is 0x0 (Operation successful). I was debugging completely and checked all the possiblities of errors before this event. I couldn't find the root cause what made not loading the controls.

1
Thanks friends. I resolved this issue. The problem is with some ActiveX Controls which are not implemented with COM rules. In the InitInstance() method, CoInitialize() method should be called and in the ExitInstance() method CoUninitialize() method should be called. Its not done in some method that causes this issue. Once its done, the problem is resolved.Snabak Vinod

1 Answers

1
votes

You may want to refer the below question similar occurence of the problem Exception while opening file

The similarity being it was working fine but after sometime it would throw exception and when we check the error message it would be no error occured. The issue wont be directly at the line that causes exception. It would be lurking elsewhere in the application.

In my case when i changed the way i was accessing the method and it started working.