แม่แบบ lt คลาสTBase= CWindow คลาสTWinTraits(&L) = CControlWinTraits gt
คลา CContainedWindowT: TBase สาธารณะ(&G)
พารามิเตอร์
TBase
คลาสพื้นฐานของคลาสใหม่ของคุณ คลาสพื้นฐานเป็นค่าเริ่มต้นคือCWindow?
TWinTraits
คลาสคุณลักษณะที่กำหนดลักษณะสำหรับหน้าต่างของคุณ ค่าเริ่มต้นคือCControlWinTraits?
หมายเหตุnbsp CContainedWindowเป็นการเฉพาะทางของCContainedWindowT ถ้าคุณต้องการเปลี่ยนคุณลักษณะหรือคลาสพื้นฐาน ใช้CContainedWindowTได้โดยตรง(&N)?
CContainedWindowใช้หน้าต่างมีอยู่ภายในวัตถุอื่น CContainedWindowของหน้าต่างวิธีใช้แผนที่แบบข้อความในวัตถุประกอบด้วยการส่งข้อความไปยังตัวจัดการที่เหมาะสม เมื่อตรวจวัตถุCContainedWindowคุณระบุควรใช้แผนที่ที่ข้อความ?
CContainedWindowช่วยให้คุณสร้างหน้าต่างใหม่ โดย superclassing มีคลาสหน้าต่างที่มีอยู่ วิธีการสร้างการลงทะเบียนคลาสหน้าต่างที่จะยึดเป็นคลาสที่มีอยู่ แต่ใช้CContainedWindow::WindowProcก่อน สร้างแล้วสร้างหน้าต่างตามคลาสหน้าต่างนี้ใหม่ แต่ละอินสแตนซ์ของCContainedWindowสามารถซุปเปอร์คลาสคลาสในหน้าต่างที่แตกต่างกัน?
นอกจากนี้CContainedWindowยังสนับสนุน subclassing หน้าต่าง เมธอดSubclassWindowแนบมีหน้าต่างที่มีอยู่ไปยังวัตถุCContainedWindowและการเปลี่ยนแปลงวิธีการหน้าต่างCContainedWindow::WindowProc แต่ละอินสแตนซ์ของCContainedWindowสามารถซับคลาสหน้าต่างแตกต่างกัน?
หมายเหตุnbsp สำหรับวัตถุใด ๆCContainedWindowกำหนด เรียกตัวสร้างหรือSubclassWindow นอกจากนี้คุณไม่ควรเรียกใช้ทั้งสองวิธีบนวัตถุเดียวกัน(&N)?
เมื่อคุณใช้ตัวเลือกเพิ่มตัวควบคุมที่ยึดตามในตัวช่วยสร้างวัตถุ ATL ตัวช่วยสร้างจะเพิ่มข้อมูลสมาชิกCContainedWindowคลาสที่ใช้ตัวควบคุม ตัวอย่างต่อไปนี้จะนำมาจาก SUBEDITอย่างและแสดงหน้าต่างที่มีอยู่ถูกประกาศอย่างไร
class CAtlEdit : ...
{
public:
// Declare a contained window data member
CContainedWindow m_EditCtrl;
// Initialize the contained window:
// 1. Pass "EDIT" to specify that the contained
// window should be based on the standard
// Windows Edit box
// 2. Pass 'this' pointer to specify that CAtlEdit
// contains the message map to be used for the
// contained window's message processing
// 3. Pass the identifier of the message map. '1'
// identifies the alternate message map declared
// with ALT_MSG_MAP(1)
CAtlEdit() : m_EditCtrl(_T("EDIT"), this, 1)
{
m_bWindowOnly = TRUE;
}
// Declare the default message map,
// identified by '0'
BEGIN_MSG_MAP(CAtlEdit)
...
MESSAGE_HANDLER(WM_CREATE, OnCreate)
...
// Declare an alternate message map,
// identified by '1'
ALT_MSG_MAP(1)
MESSAGE_HANDLER(WM_CHAR, OnChar)
END_MSG_MAP()
// Define OnCreate handler
// When the containing window receives a WM_CREATE
// message, create the contained window by calling
// CContainedWindow::Create
LRESULT OnCreate(UINT uMsg, WPARAM wParam,
LPARAM lParam, BOOL& bHandled)
{
...
m_EditCtrl.Create(m_hWnd, rc, _T("hello"),
WS_CHILD | WS_VISIBLE |
ES_MULTILINE | ES_AUTOVSCROLL);
return 0;
}
...
};
| สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ | ดู |
| การสร้างตัวควบคุม | ATL Tutorial |
| การใช้ windows ใน ATL | คลาสหน้าต่าง ATL |
| ATL วัตถุตัวช่วยสร้าง | การสร้างโครงการ ATL |
| Windows | Windowsและหัวข้อที่ตามมาในPlatform SDK |
| Subclassing | หน้าต่างกระบวนงาน SubclassingในPlatform SDK |
| Superclassing | หน้าต่างกระบวนงาน SuperclassingในPlatform SDK |
#รวม lt;atlwin.h>
ดูเพิ่มเติม
CWindow, CWindowImpl, CMessageMap, BEGIN_MSG_MAP, ALT_MSG_MAP