Share via


CMDIChildWnd::Create

Chiamare la funzione membro per creare una finestra figlio MDI Windows e per associarlo all'oggetto CMDIChildWnd.

virtual BOOL Create(
   LPCTSTR lpszClassName,
   LPCTSTR lpszWindowName,
   DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
   const RECT& rect = rectDefault,
   CMDIFrameWnd* pParentWnd = NULL,
   CCreateContext* pContext = NULL 
);

Parametri

  • lpszClassName
    Punta a una stringa di caratteri con terminazione null di denominazione la classe di Windows (una struttura WNDCLASS ).Il nome della classe può essere qualsiasi nome registrato con la funzione globale AfxRegisterWndClass.Deve essere NULL per CMDIChildWndstandard.

  • lpszWindowName
    Punta a una stringa di caratteri con terminazione null che rappresenta il nome della finestra.Utilizzato come testo della didascalia.

  • dwStyle
    Specifica gli attributi stile della finestra.Lo stile WS_CHILD è obbligatorio.

  • rect
    Contiene la dimensione e la posizione della finestra.Il valore rectDefault Windows consente di specificare la dimensione e la posizione di nuovo CMDIChildWnd.

  • pParentWnd
    Specifica il padre della finestra.Se NULL, la finestra principale di viene utilizzato.

  • pContext
    Specifica una struttura CCreateContext.Questo parametro può essere NULL.

Valore restituito

Diverso da zero se ha esito positivo; in caso contrario 0.

Note

Attualmente alla finestra cornice figlio MDI attiva può determinare la barra del titolo della finestra cornice padre.Questa funzionalità è disabilitata disattivando il bit di stile FWS_ADDTOTITLE della finestra cornice figlio.

Il framework chiama la funzione membro in risposta a un comando dell'utente creare una finestra figlio e gli utilizzi del framework il parametro pContext correttamente connettere la finestra figlio all'applicazione.Quando si chiama Crea, pContext può essere NULL.

Esempio

Esempio 1:

// CMainFrame::OnFileNewCMdiChildWnd() is a menu command handler for the 
// CMainFrame class, which in turn is a CMDIFrameWnd-derived class.
// It shows the creation of a standard Windows MDI child window using 
// the registered CMDIChildWnd class.  
void CMainFrame::OnFileNewMdiChildWnd()
{
   CMDIChildWnd* pMDIChildWnd = new CMDIChildWnd;
   VERIFY(pMDIChildWnd->Create(
      NULL,                                        // standard CMDIChildWnd class
      _T("My MDIChildWnd"),                        // caption of MDI child window
      WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, // window styles
      rectDefault,                                 // default rectangle size
      this));                                      // parent window; can be NULL

   // the default PostNcDestroy handler will delete this object when destroyed
}

Esempio 2:

// CMainFrame::OnHello() is a menu command handler for the CMainFrame
// class, which in turn is a CMDIFrameWnd-derived class.
// It shows the creation of a Windows MDI child window using a custom
// window class. The custom window class is registered in 
// CHelloWnd::Create(). CHelloWnd is a CMDIChildWnd-derived class.
void CMainFrame::OnHello()
{
   CHelloWnd *pHelloWnd = new CHelloWnd;
   if (!pHelloWnd->Create(_T("Hello"),
      WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
      rectDefault, this))
      return;

   // the default PostNcDestroy handler will delete this object when destroyed
}
BOOL CHelloWnd::Create(
   LPCTSTR szTitle, 
   LONG style              /* = 0 */,
   const RECT& rect        /* = rectDefault */,
   CMDIFrameWnd* parent    /* = NULL */)
{
   // Setup the shared menu
   SetHandles(::LoadMenu(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_HELLO)),
      NULL);

   // Register a custom WndClass and create a window.
   // This must be done because CHelloWnd has a custom icon.
   LPCTSTR lpszHelloClass =
      AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,
      LoadCursor(NULL, IDC_ARROW),
      (HBRUSH) (COLOR_WINDOW+1),
      LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_HELLO)));

   return CMDIChildWnd::Create(lpszHelloClass, szTitle, style, rect, parent);
}

Requisiti

Header: afxwin.h

Vedere anche

Riferimenti

Classe di CMDIChildWnd

Grafico della gerarchia

CMDIChildWnd::CMDIChildWnd

CWnd::PreCreateWindow