Поделиться через


CWnd::CreateEx

Creates an overlapped, pop-up, or child window with the extended style specified in dwExStyle.

virtual BOOL CreateEx(
   DWORD dwExStyle,
   LPCTSTR lpszClassName,
   LPCTSTR lpszWindowName,
   DWORD dwStyle,
   int x,
   int y,
   int nWidth,
   int nHeight,
   HWND hWndParent,
   HMENU nIDorHMenu,
   LPVOID lpParam = NULL 
);
virtual BOOL CreateEx(
   DWORD dwExStyle,
   LPCTSTR lpszClassName,
   LPCTSTR lpszWindowName,
   DWORD dwStyle,
   const RECT& rect,
   CWnd* pParentWnd,
   UINT nID,
   LPVOID lpParam = NULL
);

Параметры

  • dwExStyle
    Specifies the extended style of the CWnd being created. Apply any of the extended window styles to the window.

  • lpszClassName
    Points to a null-terminated character string that names the Windows class (a WNDCLASS structure). The class name can be any name registered with the global AfxRegisterWndClass function or any of the predefined control-class names.

  • lpszWindowName
    Points to a null-terminated character string that contains the window name.

  • dwStyle
    Specifies the window style attributes. See Window Styles and CWnd::Create for a description of the possible values.

  • x
    Specifies the initial x-position of the CWnd window.

  • y
    Specifies the initial top position of the CWnd window.

  • nWidth
    Specifies the width (in device units) of the CWnd window.

  • nHeight
    Specifies the height (in device units) of the CWnd window.

  • hwndParent
    Identifies the parent or owner window of the CWnd window being created. Use NULL for top-level windows.

  • nIDorHMenu
    Identifies a menu or a child-window identifier. The meaning depends on the style of the window.

  • lpParam
    Points to the data referenced by the lpCreateParams field of the CREATESTRUCT structure.

  • rect
    The size and position of the window, in client coordinates of pParentWnd.

  • pParentWnd
    The parent window.

  • nID
    The ID of the child window.

Возвращаемое значение

Nonzero if successful; otherwise 0.

Заметки

The CreateEx parameters specify the WNDCLASS, window title, window style, and (optionally) initial position and size of the window. CreateEx also specifies the window's parent (if any) and ID.

When CreateEx executes, Windows sends the WM_GETMINMAXINFO, WM_NCCREATE, WM_NCCALCSIZE, and WM_CREATE messages to the window.

To extend the default message handling, derive a class from CWnd, add a message map to the new class, and provide member functions for the above messages. Override OnCreate, for example, to perform needed initialization for a new class.

Override further OnMessage message handlers to add further functionality to your derived class.

If the WS_VISIBLE style is given, Windows sends the window all the messages required to activate and show the window. If the window style specifies a title bar, the window title pointed to by the lpszWindowName parameter is displayed in the title bar.

The dwStyle parameter can be any combination of window styles.

Пример

void CMyDlg::OnCreateExtendedControl() 
{
   // m_pWndStaticEx is a CWnd* member of CMyDlg
   m_pWndStaticEx = new CStatic;
   m_pWndStaticEx->CreateEx(WS_EX_CLIENTEDGE, // Make a client edge label.
      _T("STATIC"), _T("Hi"),
      WS_CHILD | WS_TABSTOP | WS_VISIBLE,
      5, 5, 30, 30, m_hWnd, (HMENU)2345);
}

Требования

Header: afxwin.h

См. также

Основные понятия

CWnd Class

CWnd Members

Hierarchy Chart

CWnd::Create

CreateWindowEx