共用方式為


CWindowImpl Class

提供建立或子類別化視窗的方法。

重要

此類別及其成員無法用於在 Windows 執行階段執行的應用程式。

template < 
class T, 
class TBase= CWindow, 
class TWinTraits= CControlWinTraits  
> 
class ATL_NO_VTABLE CWindowImpl : 
public CWindowImplBaseT< TBase, TWinTraits>

參數

  • T
    衍生自 CWindowImpl 、您新創的類別

  • TBase
    類別的基底類別。 根據預設,基底類別是CWindow

  • TWinTraits
    定義視窗樣式的特性類別 。 預設值為 CControlWinTraits

Members

公用方法

名稱

描述

CWindowImpl::Create

建立視窗。

CWindowImplBaseT 方法

DefWindowProc

提供預設訊息處理。

GetCurrentMessage

傳回目前訊息。

GetWindowProc

傳回目前視窗程序。

OnFinalMessage

在最後一則訊息接收之後呼叫 (一般為 WM_NCDESTROY)。

SubclassWindow

子類別化一個視窗。

UnsubclassWindow

還原先前的子類別視窗。

靜態方法

GetWndClassInfo

傳回 CWndClassInfo靜態執行個體,其處理視窗類別資訊。

WindowProc

處理傳送至視窗的訊息。

資料成員

m_pfnSuperWindowProc

指向視窗類別的原始視窗程序。

備註

您可以使用 CWindowImpl 建立視窗或子類別化現有視窗。 CWindowImpl 視窗程序使用訊息對應,將訊息導向至適當的處理常式。

CWindowImpl::Create 建立基於視窗類別資訊的視窗、其視窗類別資訊由 CWndClassInfo管理。 CWindowImpl 包含 DECLARE_WND_CLASS 巨集,其表示 CWndClassInfo 註冊新的視窗類別。 如果您想要 Superclass 現有視窗類別,請從 CWindowImpl 衍生您自己的類別,並包含 DECLARE_WND_SUPERCLASS 巨集。 在這種情況下, CWndClassInfo 註冊了根據現有的類別但使用 CWindowImpl::WindowProc的視窗類別。 例如:

class ATL_NO_VTABLE CMyWindow :
   OtherInheritedClasses
   public CComControl<CMyWindow>
          // CComControl derives from CWindowImpl
{
public:
   // 1. The NULL parameter means ATL will generate a
   //    name for the superclass
   // 2. The "EDIT" parameter means the superclass is
   //    based on the standard Windows Edit box
   DECLARE_WND_SUPERCLASS(NULL, _T("EDIT"))

   // Remainder of class declaration omitted
注意事項注意事項

由於 CWndClassInfo 只處理一個視窗類別的資訊,每個透過 CWindowImpl 執行個體所建立的視窗是以相同的視窗類別為基底。

CWindowImpl 也支援視窗子類別化。 SubclassWindow 方法附加 CWindowImpl 物件的現有視窗,並變更視窗程序至 CWindowImpl::WindowProcCWindowImpl 執行個體可以子類別化不同的視窗。

注意事項注意事項

對於任何指定的 CWindowImpl 物件,請呼叫 CreateSubclassWindow。不要對同一物件叫用兩種方法。

除了 CWindowImpl以外, ATL 提供 CContainedWindow 來建立包含另一個物件的視窗。

基底類別解構函式 (~CWindowImplRoot) 保證在終結物件之前移除視窗。

CWindowImpl 衍生自CWindowImplBaseT,其衍生自 CWindowImplRoot,其衍生自 TBaseCMessageMap

如需詳細資訊

請參閱

建立控制項

ATL 教學課程

使用 ATL 裡的視窗

ATL 視窗類別

ATL 專案精靈

建立 ATL 專案

繼承階層架構

CMessageMap

TBase

CWindowImplRoot

CWindowImplBaseT

CWindowImpl

需求

標題: atlwin.h

請參閱

參考

BEGIN_MSG_MAP

CComControl Class

其他資源

ATL Class Overview