+ if ( parent )
+ parent->AddChild(this);
+
+ // translate wxWin style flags to MSW ones, checking for consistency while
+ // doing it
+ long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP;
+ if ( m_windowStyle & wxTE_MULTILINE )
+ {
+ wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER),
+ wxT("wxTE_PROCESS_ENTER style is ignored for multiline "
+ "text controls (they always process it)") );
+
+ msStyle |= ES_MULTILINE | ES_WANTRETURN;
+ if ((m_windowStyle & wxTE_NO_VSCROLL) == 0)
+ msStyle |= WS_VSCROLL;
+ m_windowStyle |= wxTE_PROCESS_ENTER;
+ }
+ else
+ msStyle |= ES_AUTOHSCROLL;
+
+ if (m_windowStyle & wxHSCROLL)
+ msStyle |= (WS_HSCROLL | ES_AUTOHSCROLL);
+
+ if (m_windowStyle & wxTE_READONLY)
+ msStyle |= ES_READONLY;
+
+ if (m_windowStyle & wxHSCROLL)
+ msStyle |= (WS_HSCROLL | ES_AUTOHSCROLL);
+ if (m_windowStyle & wxTE_PASSWORD) // hidden input
+ msStyle |= ES_PASSWORD;
+
+ // we always want the characters and the arrows
+ m_lDlgCode = DLGC_WANTCHARS | DLGC_WANTARROWS;
+
+ // we may have several different cases:
+ // 1. normal case: both TAB and ENTER are used for dialog navigation
+ // 2. ctrl which wants TAB for itself: ENTER is used to pass to the next
+ // control in the dialog
+ // 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation
+ // 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to
+ // the next control
+ if ( m_windowStyle & wxTE_PROCESS_ENTER )
+ m_lDlgCode |= DLGC_WANTMESSAGE;
+ if ( m_windowStyle & wxTE_PROCESS_TAB )
+ m_lDlgCode |= DLGC_WANTTAB;
+
+ // do create the control - either an EDIT or RICHEDIT
+ wxString windowClass = wxT("EDIT");
+
+#if wxUSE_RICHEDIT
+ if ( m_windowStyle & wxTE_RICH )
+ {
+ static bool s_errorGiven = FALSE; // MT-FIXME
+
+ // only give the error msg once if the DLL can't be loaded
+ if ( !s_errorGiven )
+ {
+ // first try to load the RichEdit DLL (will do nothing if already
+ // done)
+ if ( !wxRichEditModule::Load() )
+ {
+ wxLogError(_("Impossible to create a rich edit control, "
+ "using simple text control instead. Please "
+ "reinstall riched32.dll"));
+
+ s_errorGiven = TRUE;
+ }
+ }
+
+ if ( s_errorGiven )
+ {
+ m_isRich = FALSE;
+ }
+ else
+ {
+ msStyle |= ES_AUTOVSCROLL;
+ m_isRich = TRUE;
+
+ int ver = wxRichEditModule::GetLoadedVersion();
+ if ( ver == 1 )
+ {
+ windowClass = wxT("RICHEDIT");
+ }
+ else
+ {
+#ifndef RICHEDIT_CLASS
+ wxString RICHEDIT_CLASS;
+ RICHEDIT_CLASS.Printf(_T("RichEdit%d0"), ver);
+#ifdef wxUSE_UNICODE
+ RICHEDIT_CLASS += _T('W');
+#else // ANSI
+ RICHEDIT_CLASS += _T('A');
+#endif // Unicode/ANSI
+#endif // !RICHEDIT_CLASS
+
+ windowClass = RICHEDIT_CLASS;
+ }
+ }
+ }
+ else
+ m_isRich = FALSE;
+#endif // wxUSE_RICHEDIT
+
+ bool want3D;
+ WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
+
+ // Even with extended styles, need to combine with WS_BORDER for them to
+ // look right.
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
+ msStyle |= WS_BORDER;
+
+ // NB: don't use pos and size as CreateWindowEx arguments because they
+ // might be -1 in which case we should use the default values (and
+ // SetSize called below takes care of it)
+ m_hWnd = (WXHWND)::CreateWindowEx(exStyle,
+ windowClass,
+ NULL,
+ msStyle,
+ 0, 0, 0, 0,
+ GetHwndOf(parent),
+ (HMENU)m_windowId,
+ wxGetInstance(),
+ NULL);
+
+ wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create text ctrl") );
+
+#if wxUSE_CTL3D
+ if ( want3D )
+ {
+ Ctl3dSubclassCtl(GetHwnd());
+ m_useCtl3D = TRUE;
+ }