LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Child panel from a different thread hangs application

Hello,

 

I have TestStand sequence that calls an CVI-dll, that displays some text, graphics and has a few buttons.

TestStand calls this DLL in MTA by default.

In order to display an ActiveX Control on the DLLs mainpanel, I create a new thread pool inside this DLL and open a new thread in STA containing a panel with the mentioned ActiveX Control.

So far it works well, as long as both panels (the MTA-panel and the ActiveX Control STA panel) exist separately. (Two panels on different positions on the screen).

 

But actually I don’t want the AxtiveX Control panel to be separated from the mainpanel, so I have tried to make it a child of the mainpanel with SetParent (from SDK), called with PostDeferredCallToThread in a Callback.  In fact it works but only until the mainpanel reaches RunUserInterface(). At this point the whole application hangs (including TestStand).


This is what I have done:


mainpanel:
 

{

   ...

   mainthreadID = CmtGetCurrentThreadID ();

   CmtNewThreadPool (50, &poolHandle);

   CmtScheduleThreadPoolFunction (poolHandle, (ThreadFunctionPtr)CreateActiveXCtrl, 0,

                                      &threadID);

   ...

   RunUserInterface()

   ...

}

 

ActiveXControl panel:
 

int CVICALLBACK CreateActiveXCtrl(....)

{

  ...

CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED);

...

pHandle = NewPanel (...);   

NewActiveXCtrl(...);

...

PostDeferredCallToThread ((DeferredCallbackPtr)MakeChildPanel,0, mainthreadID);

...

}


void CVICALLBACK MakeChildPanel (void *callbackData)

{

                SetParent((HWND)actXPanel, (HWND)mainPanel);

}


Does somebody have an idea how to solve this case? And what’s the reason for this behaviour?

It would be also fine to include the ActiveXControl directly to the mainpanel, but I guess it doen't work because of the mainpanel being in MTA!?!

 

Mathias

0 Kudos
Message 1 of 2
(2,857 Views)
Thread continues here.

Message Edited by IngoS on 11-09-2005 03:15 PM

Ingo Schumacher
Systems Engineering Manager CEERNational Instruments Germany
0 Kudos
Message 2 of 2
(2,818 Views)