Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Dynamically created CExtEdit Collapse All
Subject Author Date
Suhai Gyorgy Dec 1, 2006 - 8:25 AM

I’m trying to create a CExtEdit control dynamically in the OnInitDialog of a CExtResizableDialog. It didn’t act as expected, so I tried it in one of your samples as well (CompoundProperties), with same result. I can see the control appearing, but when hovering over it with the mouse, or putting the focus into it, the editbox doesn’t have any kind of border appearing (it should be a border consistent with the selected paintmanager). This is the code I added to your sample:
MainDlg.h:

	CArray <CWnd *, CWnd *> m_vWnds;
MainDlg.cpp:
CMainDlg::~CMainDlg()
{
	for (int i = 0; i < m_vWnds.GetSize(); i++) {
		if(m_vWnds[i] != NULL) delete m_vWnds[i];
	}
	m_vWnds.RemoveAll();
}
...
BOOL CMainDlg::OnInitDialog() 
{
	...
	CRect rect(700, 472, 800, 492);
	ScreenToClient(&rect);
	CExtEdit *pEdit = new CExtEdit;
	pEdit->Create(WS_VISIBLE|WS_CHILD|WS_TABSTOP|ES_AUTOHSCROLL, rect, this, IDC_EDIT1);
	pEdit->ModifyStyleEx(0, WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY);
	m_vWnds.Add(pEdit);
 
	AddAnchor( IDC_OBJECT_CANVAS, CSize(0,0), CSize(60,100) );
	AddAnchor( IDC_PROPERTY_GRID_CTRL, CSize(60,0), CSize(100,100) );
	...
}
I got the applied styles from another CExtEdit created throught the .rc file (, which works fine). Could you give me any hint on what initialization I’m missing?

Thank you,
Chris

Technical Support Dec 2, 2006 - 11:06 AM

Please replace the following line

pEdit->ModifyStyleEx( 0, WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY );
with this one
pEdit->ModifyStyleEx( 0, WS_EX_CLIENTEDGE|WS_EX_NOPARENTNOTIFY, SWP_FRAME_CHANGED );



Suhai Gyorgy Dec 4, 2006 - 5:47 AM

Am I right to assume that for proper initialization I also need to call SetFont for this dynamically created editbox (and for any dynamically created control)?

Technical Support Dec 4, 2006 - 12:20 PM

By default, the newly created windows have the System font, which does not look good. We recommend you assign the following font:

( (HFONT) ::GetStockObject( DEFAULT_GUI_FONT ) )

Suhai Gyorgy Dec 4, 2006 - 3:16 AM

Thank you, it works great now!

If anyone else ever need this: use SWP_FRAMECHANGED flag instead of SWP_FRAME_CHANGED!