Win32 , C++

프로그램 실행 중 ActiveX 로드하기

김모작자 2006. 8. 4. 19:14
Classwizard 도움없이

CAxWindow.Create 로 실제 보여줄 윈도우를 만들고
CAxWindow 의 IAxWinHostWindow 를 쿼리해서 얻고
IAxWinHostWindow 에서 CreateControl 로 필요한 컨트롤을 생성한다

CAxWindow axObject;
CComPtr<IAxWinHostWindow>       spHost;

axObject.Create(m_hWnd, rect, NULL, WS_CHILD | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

axObject.QueryHost(&spHost);
spHost->CreateControl( [CLSID], axObject, NULL );

axObject.QueryControl( [interface implemented object] );

-----------------
CAxWindow, CComPtr 은 atlbase.h 를 포함해야 한다.

-----------------
Dialog 등에 ActiveX 컨트롤을 올리기 보다 위에 방식으로 올리게 되면 실제 사용시만 로드하면 되기 때문에 초기 로드 시간 등을 줄일 수 있다.