How to add ATL control containment support to any window in Visual C++
Article ID | : | 192560 |
Last Review | : | September 2, 2005 |
Revision | : | 3.0 |
This article was previously published under Q192560
SUMMARY
This article explains how to add Active Template Library (ATL) generic control containment capability to any window, so that the window can host ActiveX controls. The control containment support conforms to the OCX 96 specification and supports windowless activation and flicker-free drawing.
MORE INFORMATION
To add control containment, follow these steps:
You can get the IUnknown* of the control via AtlAxGetControl(). To get the IUnknown* of the container, use AtlAxGetHost(). The HWND returned from CreateWindow() for the control is passed as the first parameter in both functions.
1. | Add the following header files and pragma directives to your code. If you want to link to the containment code in Atl.dll, add the following code: Atl.dll must be shipped when you use ATL containment code, regardless of whether you Min Size build or Min Dependency build. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
244955 (http://support.microsoft.com/kb/244955/) ATL projects built for MinDependency need Atl.dll if the projects use ATL control containment code in Visual C++ 6.0 |
2. | Add the following code to the application initialization code, for example in the beginning of WinMain():
|
3. | Create the ActiveX controls: use the WIN32 CreateWindow() function, specify "AtlAxWin" as the class name, and then specify either a GUID, a ProgID, or an URL as the title. For example:
|
4. | If you added _Module.Init(), add the following code in application termination code (for example, in WinMain(), after the message loop):
|
'COM, ATL' 카테고리의 다른 글
Inside com 파워 포인트 강좌(이준근 강사) (1) | 2008.07.26 |
---|---|
COM 개요 (3) | 2008.07.26 |
컴포넌트 기본 개념 (0) | 2008.07.26 |
Registering DLL and ActiveX controls from code (0) | 2008.07.26 |
MSDN, ATL 매뉴얼 (0) | 2008.07.26 |
ATL 컨트롤 포함 FAQ(질문과 대답) (2) | 2008.07.25 |
플래시 로딩 소스(api) (0) | 2008.07.24 |